:root {
  --azul-900: #16233d;
  --azul-700: #1e3a5f;
  --azul-500: #2f5d8a;
  --azul-50: #eef3f9;
  --laranja: #dd7e2c;
  --laranja-escuro: #b8631a;
  --verde: #2f8f5b;
  --verde-bg: #e7f5ed;
  --vermelho: #c0392b;
  --vermelho-bg: #fbeae8;
  --cinza-900: #1f2430;
  --cinza-600: #6b7280;
  --cinza-400: #9aa2b1;
  --borda: #e6e9ef;
  --sombra: 0 1px 2px rgba(22, 35, 61, 0.04), 0 4px 16px rgba(22, 35, 61, 0.06);
  --raio: 14px;
}

* { box-sizing: border-box; }

body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: linear-gradient(180deg, #f4f6fa 0%, #eef1f6 100%);
  color: var(--cinza-900);
  -webkit-font-smoothing: antialiased;
}

h3, h4, h5 { font-family: "Inter", sans-serif; }

/* ---------- topo ---------- */

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(120deg, var(--azul-900), var(--azul-700));
  color: white; padding: 16px 28px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icone {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--laranja);
}
.brand-titulo { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: rgba(255,255,255,0.65); margin-top: 1px; }

.sessao-usuario { display: flex; align-items: center; gap: 14px; color: rgba(255,255,255,0.9); font-size: 13px; font-weight: 600; }
.role-switch { display: flex; gap: 8px; }
.role-btn {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); color: white;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
  font-family: inherit; transition: background 0.15s;
}
.role-btn:hover { background: rgba(255,255,255,0.18); }
.role-btn.active { background: white; color: var(--azul-700); font-weight: 700; border-color: white; }

/* ---------- layout geral ---------- */

main#app { max-width: 1140px; margin: 28px auto; padding: 0 24px 70px; }

.secao-titulo { font-size: 15px; font-weight: 700; color: var(--azul-700); margin: 26px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.secao-sub { font-size: 12px; font-weight: 400; color: var(--cinza-600); }

.subnav { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--borda); }
.subnav-btn {
  background: transparent; border: none; padding: 10px 6px; margin-right: 18px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--cinza-600);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav-btn.active { color: var(--azul-700); border-bottom-color: var(--laranja); }
.subview { animation: fadein 0.15s ease-in; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.controls-row { display: flex; gap: 24px; margin-bottom: 22px; align-items: flex-end; flex-wrap: wrap; }
.controls-row label { font-size: 12px; font-weight: 600; color: var(--cinza-600); display: flex; flex-direction: column; gap: 6px; }
.controls-row select {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--borda); min-width: 240px;
  font-family: inherit; font-size: 13.5px; background: white; color: var(--cinza-900);
}

/* ---------- cards ---------- */

.cards-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.card {
  background: white; border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 18px 20px; min-width: 175px; flex: 1; box-shadow: var(--sombra);
}
.card .valor { font-size: 28px; font-weight: 800; color: var(--azul-700); letter-spacing: -0.02em; }
.card .rotulo { font-size: 12px; color: var(--cinza-600); margin-top: 6px; line-height: 1.4; }

.empresa-card {
  background: white; border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 18px 20px; min-width: 230px; flex: 1; box-shadow: var(--sombra);
}
.empresa-card h4 { margin: 0 0 8px; color: var(--azul-700); font-size: 14.5px; }
.progress-bar { background: #eef0f3; border-radius: 8px; height: 9px; overflow: hidden; margin-top: 8px; }
.progress-fill { background: linear-gradient(90deg, var(--laranja-escuro), var(--laranja)); height: 100%; border-radius: 8px; transition: width 0.3s; }
.fase-label { font-size: 12px; color: var(--cinza-600); margin-top: 8px; line-height: 1.5; }

/* ---------- tabela ---------- */

table.tabela {
  width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--borda);
  border-radius: var(--raio); overflow: hidden; box-shadow: var(--sombra);
}
table.tabela th, table.tabela td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--borda); font-size: 13.5px; }
table.tabela tbody tr:last-child td { border-bottom: none; }
table.tabela tbody tr:hover { background: #fafbfd; }
table.tabela th { background: var(--azul-50); color: var(--azul-700); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.risco-badge { background: var(--vermelho-bg); color: var(--vermelho); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.ok-badge { background: var(--verde-bg); color: var(--verde); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }

/* ---------- painel do aluno / empresa ---------- */

.empresa-painel {
  background: linear-gradient(120deg, var(--azul-700), var(--azul-500));
  color: white; border-radius: var(--raio); padding: 20px 24px; margin-bottom: 18px; box-shadow: var(--sombra);
}
.empresa-painel h3 { margin: 0 0 6px; font-size: 18px; }
.empresa-painel .fase-label { color: rgba(255,255,255,0.85); }
.empresa-painel .progress-bar { background: rgba(255,255,255,0.2); }
.empresa-painel .progress-fill { background: white; }

.badges-row { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.badge-pill { background: var(--azul-50); color: var(--azul-700); padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600; box-shadow: var(--sombra); }

/* ---------- unidades / atividades ---------- */

.unidade-card { background: white; border: 1px solid var(--borda); border-radius: var(--raio); margin-bottom: 14px; overflow: hidden; box-shadow: var(--sombra); }
.unidade-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; cursor: pointer; background: var(--azul-50); transition: background 0.15s; }
.unidade-header:hover { background: #e4ecf5; }
.unidade-header h4 { margin: 0; color: var(--azul-700); font-size: 14.5px; font-weight: 700; }
.unidade-header .meta { font-size: 12px; color: var(--cinza-600); font-weight: 600; }
.lock-badge { font-size: 12px; margin-left: 4px; }
.unidade-bloqueada .unidade-header { background: #f3f4f6; }
.unidade-bloqueada .unidade-header h4 { color: var(--cinza-600); }
.unidade-body { padding: 20px; display: none; }
.unidade-body.aberta { display: block; animation: fadein 0.15s ease-in; }

.materiais-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.material-card { border: 1px solid var(--borda); border-radius: 12px; overflow: hidden; background: #fafbfd; }
.material-card .material-titulo { padding: 10px 14px; font-size: 12.5px; font-weight: 700; color: var(--azul-700); display: flex; align-items: center; gap: 6px; }
.material-card iframe.video-frame { width: 100%; display: block; border: none; background: #000; aspect-ratio: 16/9; }

.material-preview {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16/9; background: #eef0f4; overflow: hidden; position: relative;
  text-decoration: none; cursor: pointer;
}
.material-preview img { width: 100%; height: 100%; object-fit: contain; background: white; display: block; }
.material-preview .abrir-tag {
  position: absolute; bottom: 8px; right: 8px; background: rgba(22,35,61,0.82); color: white;
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
}
.material-preview-fallback {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--cinza-600); font-size: 12.5px; font-weight: 600; width: 100%; height: 100%;
}
.material-preview-fallback .icone-grande { font-size: 34px; }

.material-card .material-acoes { padding: 8px 14px 12px; }
.material-card a.link-download { font-size: 12px; color: var(--azul-500); text-decoration: none; font-weight: 600; }
.material-card a.link-download:hover { text-decoration: underline; }
.material-vazio { border: 1px dashed var(--borda); border-radius: 12px; padding: 18px; text-align: center; color: var(--cinza-400); font-size: 12.5px; background: #fafbfd; }

.atividade-box { border: 1px solid var(--borda); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; background: #fdfdfe; }
.atividade-box h5 { margin: 0 0 10px; font-size: 14px; }
.atividade-bloqueada {
  background: #f3f4f6; color: var(--cinza-600); border-radius: 8px; padding: 12px 14px;
  font-size: 13px; font-weight: 600;
}
.questao { margin-bottom: 14px; }
.questao p { font-weight: 600; margin-bottom: 8px; font-size: 13.5px; }
.questao label { display: block; font-size: 13px; margin-bottom: 6px; cursor: pointer; padding: 4px 0; }
textarea { width: 100%; min-height: 90px; padding: 10px; border-radius: 8px; border: 1px solid var(--borda); font-family: inherit; font-size: 13.5px; resize: vertical; }
input[type="text"], input[type="url"] { font-family: inherit; font-size: 13.5px; }

button.acao {
  background: var(--azul-700); color: white; border: none; padding: 9px 18px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600; margin-top: 8px; font-family: inherit;
  transition: background 0.15s, transform 0.05s;
}
button.acao:hover { background: var(--azul-500); }
button.acao:active { transform: scale(0.98); }
button.acao.secundario { background: white; color: var(--azul-700); border: 1px solid var(--borda); }
button.acao.secundario:hover { background: var(--azul-50); }
button.acao.perigo { background: white; color: var(--vermelho); border: 1px solid var(--vermelho-bg); }
button.acao.perigo:hover { background: var(--vermelho-bg); }

a.acao {
  display: inline-block; background: var(--azul-700); color: white; border: none; padding: 9px 18px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
  text-decoration: none; transition: background 0.15s, transform 0.05s;
}
a.acao:hover { background: var(--azul-500); }
a.acao.secundario { background: white; color: var(--azul-700); border: 1px solid var(--borda); }
a.acao.secundario:hover { background: var(--azul-50); }

.resultado { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--verde); }

.submissao-status { border-radius: 10px; padding: 12px 14px; font-size: 13px; font-weight: 600; margin-top: 4px; }
.submissao-status.pendente { background: #fdf1e6; color: #8a5a1a; }
.submissao-status.corrigido { background: var(--verde-bg); color: var(--verde); }
.submissao-status .feedback-texto { font-weight: 500; font-style: italic; display: inline-block; margin-top: 4px; }

/* ---------- mentor ---------- */

.mentor-box { margin-top: 14px; border-top: 1px dashed var(--borda); padding-top: 14px; }
.mentor-box .mentor-titulo { font-size: 11.5px; color: var(--cinza-600); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; font-weight: 700; }
.mentor-msgs { max-height: 230px; overflow-y: auto; margin-bottom: 10px; padding-right: 4px; }
.msg { padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; font-size: 13px; max-width: 85%; line-height: 1.45; }
.msg.aluno { background: var(--azul-50); margin-left: auto; text-align: right; color: var(--azul-700); }
.msg.mentor { background: #fdf1e6; color: #5c3a12; }
.mentor-input-row { display: flex; gap: 8px; }
.mentor-input-row input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--borda); }

/* ---------- painel de gestão de conteúdo ---------- */

.conteudo-secao {
  background: white; border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--sombra);
}
.conteudo-secao h4 { margin: 0 0 4px; color: var(--azul-700); font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.conteudo-secao .ajuda { font-size: 12px; color: var(--cinza-600); margin: 0 0 14px; }
.form-linha { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.form-linha input[type="text"], .form-linha input[type="url"] {
  flex: 1; min-width: 220px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--borda);
}
.material-atual { display: flex; align-items: center; gap: 10px; background: var(--verde-bg); color: var(--verde);
  padding: 8px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; margin-bottom: 12px; }
.material-atual .lixeira { cursor: pointer; color: var(--vermelho); font-weight: 700; margin-left: auto; }
.form-linha input[type="number"] {
  min-width: 160px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--borda);
}
.form-linha textarea {
  flex: 1; min-width: 260px; min-height: 60px; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--borda); font-family: inherit; resize: vertical;
}

/* ---------- gestão das unidades (criar/editar/mover/excluir) ---------- */

.lista-unidades { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.unidade-gestao-card {
  background: white; border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px 18px;
}
.unidade-gestao-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.unidade-gestao-linha strong { color: var(--azul-700); font-size: 13.5px; }
.unidade-gestao-acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.unidade-gestao-acoes button { font-size: 11.5px; padding: 5px 10px; margin-top: 0; }
.unidade-gestao-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--borda); }
.unidade-gestao-form-nova { margin-top: 10px; }

.pontuacao-check {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--azul-700); cursor: pointer;
}
.pontuacao-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.pontuacao-max {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--azul-700);
}
.pontuacao-max input {
  width: 70px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--borda); font-family: inherit;
}
.pontuacao-max input[type="date"] { width: 132px; }

/* ---------- tabela de pontuação (aba Conta) ---------- */

.tabela-pontuacao { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.tabela-pontuacao th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--cinza-600); padding: 8px 10px; border-bottom: 2px solid var(--borda);
}
.tabela-pontuacao td {
  padding: 10px; border-bottom: 1px solid var(--borda); vertical-align: middle;
}
.tabela-pontuacao tr:last-child td { border-bottom: none; }
.unidade-nome-cell { font-weight: 700; color: var(--azul-700); font-size: 13px; white-space: nowrap; }
.unidade-nome-cell .unidade-subtitulo { font-weight: 500; color: var(--cinza-600); font-size: 11.5px; }
.pontuacao-cell {
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 8px; min-width: 220px;
}
.pontuacao-cell .pontuacao-check { grid-column: 1 / -1; }
.pontuacao-cell .pontuacao-max input { width: 100%; box-sizing: border-box; }
.pontuacao-cell .pontuacao-prazo { grid-column: 1 / -1; }

/* ---------- login ---------- */

#view-login { display: flex; justify-content: center; padding-top: 40px; }
.login-box {
  background: white; border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 32px 32px 28px; width: 100%; max-width: 380px; box-shadow: var(--sombra);
}
.login-tabs { display: flex; gap: 6px; margin-bottom: 22px; background: var(--azul-50); border-radius: 10px; padding: 4px; }
.login-tab { flex: 1; background: transparent; border: none; padding: 9px; border-radius: 8px; font-family: inherit;
  font-size: 13px; font-weight: 700; color: var(--azul-700); cursor: pointer; }
.login-tab.active { background: white; box-shadow: var(--sombra); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { font-size: 12px; font-weight: 600; color: var(--cinza-600); display: flex; flex-direction: column; gap: 6px; }
.login-form input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--borda); font-family: inherit; font-size: 14px; }
.login-form button.acao { width: 100%; }
.login-erro { color: var(--vermelho); font-size: 12.5px; font-weight: 600; min-height: 16px; }
.login-ajuda { font-size: 12px; color: var(--cinza-600); text-align: center; margin: 0; }

/* ---------- listas de admin (empresas / alunos) ---------- */

.lista-admin-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--borda);
  font-size: 13px; flex-wrap: wrap;
}
.lista-admin-item:last-child { border-bottom: none; }
.lista-admin-item .principal { font-weight: 700; color: var(--azul-700); min-width: 160px; }
.lista-admin-item .secundario { color: var(--cinza-600); font-size: 12.5px; }
.lista-admin-item .codigo-pill {
  background: var(--azul-50); color: var(--azul-700); font-family: monospace; font-weight: 700;
  padding: 3px 10px; border-radius: 6px; font-size: 12px; letter-spacing: 0.02em;
}
.lista-admin-item .acoes-item { margin-left: auto; display: flex; gap: 8px; }
.lista-admin-item button { font-size: 11.5px; padding: 5px 10px; margin-top: 0; }
.lista-vazia { color: var(--cinza-400); font-size: 12.5px; padding: 8px 4px; }

/* ---------- editor de quiz (admin) ---------- */

.questao-admin-item { border: 1px solid var(--borda); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fafbfd; }
.questao-admin-cabecalho { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.questao-admin-numero { font-weight: 700; color: var(--azul-700); font-size: 13px; }
.questao-admin-texto { font-weight: 600; font-size: 13.5px; flex: 1; }
.questao-admin-cabecalho .acoes-item { margin-left: auto; flex-shrink: 0; }
.questao-admin-opcoes { margin: 0; padding-left: 20px; font-size: 12.5px; color: var(--cinza-600); }
.questao-admin-opcoes li { padding: 2px 0; }
.questao-admin-opcoes li.correta { color: var(--verde); font-weight: 700; }
.questao-admin-opcoes li.correta::marker { color: var(--verde); }

.quiz-form { border-top: 1px dashed var(--borda); padding-top: 14px; margin-top: 4px; }
.quiz-form > input.q-enunciado { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--borda); margin-bottom: 10px; font-family: inherit; font-size: 13.5px; }
.q-opcoes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.q-opcao-linha { display: flex; align-items: center; gap: 8px; }
.q-opcao-linha input[type="text"] { flex: 1; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--borda); font-family: inherit; font-size: 13px; }
.q-remover-opcao { cursor: pointer; color: var(--cinza-400); font-size: 13px; padding: 0 4px; }
.q-remover-opcao:hover { color: var(--vermelho); }

/* ---------- correções ---------- */

.correcao-item { background: white; border: 1px solid var(--borda); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--sombra); }
.correcao-item.corrigida { background: #fafbfd; box-shadow: none; }
.correcao-cabecalho { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.correcao-cabecalho .principal { font-weight: 700; color: var(--azul-700); font-size: 13.5px; }
.correcao-cabecalho .secundario { color: var(--cinza-600); font-size: 12.5px; }
.correcao-texto { font-size: 13px; background: var(--azul-50); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; white-space: pre-wrap; }
.correcao-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.correcao-form input.correcao-nota { width: 110px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--borda); }
.correcao-form input.correcao-feedback { flex: 1; min-width: 200px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--borda); }
.correcao-form button.acao { margin-top: 0; }
