:root {
  --navy: #1B3260;
  --navy-dark: #12213f;
  --green: #2D8B5E;
  --green-dark: #226c48;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2534;
  --text-muted: #6b7686;
  --border: #e2e6ed;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 50, 96, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

h1 { font-size: 22px; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 18px; margin: 0 0 8px; color: var(--navy); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-placeholder {
  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; flex-shrink: 0; overflow: hidden;
}
.logo-placeholder img { width: 100%; height: 100%; object-fit: contain; }
.topbar-title { font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-subtitle { font-size: 12px; color: rgba(255,255,255,0.65); }
.btn-icon {
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer;
}

/* Layout */
#app { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
.tela-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card.aviso { border-left: 4px solid var(--danger); }

/* Botões */
.btn {
  border: none; border-radius: 10px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
a.btn { text-decoration: none; display: inline-block; }
.btn-primario { background: var(--green); color: #fff; }
.btn-primario:hover { background: var(--green-dark); }
.btn-secundario { background: #eef1f6; color: var(--navy); }
.btn-secundario:hover { background: #e2e7f0; }
.btn-largo { width: 100%; padding: 15px; font-size: 16px; }
.btn-pequeno { padding: 8px 12px; font-size: 13px; }
.btn-link { background: none; border: none; color: var(--text-muted); text-decoration: underline; cursor: pointer; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Lista de pesquisas */
.lista-pesquisas { display: flex; flex-direction: column; gap: 10px; }
.pesquisa-item {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer;
}
.pesquisa-item:hover { outline: 2px solid var(--green); }
.pesquisa-item-info { min-width: 0; }
.pesquisa-item-nome { font-weight: 700; color: var(--navy); }
.pesquisa-item-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.badge-status { font-size: 11.5px; padding: 3px 9px; border-radius: 20px; font-weight: 700; white-space: nowrap; }
.editar-texto { width: 100%; margin-top: 10px; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14.5px; font-family: inherit; }
.editar-texto:focus { outline: none; border-color: var(--green); }
.btn-apagar-grande { background: #fdecea; color: var(--danger); }
.versao { text-align: center; color: var(--text-muted); font-size: 11px; margin-top: 24px; }
.btn-apagar { background: #fdecea; color: var(--danger); border: none; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-apagar:hover { background: #f9d6d2; }
.badge-aberta { background: #e4f5ec; color: var(--green-dark); }
.badge-encerrada { background: #eef1f6; color: var(--text-muted); }
.texto-vazio { color: var(--text-muted); text-align: center; margin-top: 40px; }

/* Campos */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo span { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.campo input, .campo textarea, .campo select {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 12px; font-size: 15px;
  font-family: inherit; background: #fff; color: var(--text);
}
.campo input:focus, .campo textarea:focus, .campo select:focus { outline: none; border-color: var(--green); }
.campo-cor input[type="color"] { width: 64px; height: 38px; padding: 2px; border: 1px solid #cfd6e2; border-radius: 8px; cursor: pointer; background: #fff; }
.campo-titulo { font-size: 13px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .03em; }
.campo-titulo-linha { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.logo-espaco {
  border: 1.5px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}
.logo-upload { display: flex; align-items: center; gap: 14px; }
.logo-upload-preview {
  width: 56px; height: 56px; border-radius: 12px; border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
  background: #fff; overflow: hidden;
}
.logo-upload-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-upload-botoes { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.logo-upload-label { cursor: pointer; }
.tela-header-acoes { display: flex; gap: 8px; flex-wrap: wrap; }

/* Modelo escolha */
.modelo-opcoes { display: grid; grid-template-columns: 1fr; gap: 10px; }
.modelo-opcao {
  border: 1.5px solid var(--border); background: #fff; border-radius: 12px; padding: 14px; text-align: left;
  cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.modelo-opcao strong { color: var(--navy); font-size: 14.5px; }
.modelo-opcao span { color: var(--text-muted); font-size: 12.5px; }
.modelo-opcao.selecionada { border-color: var(--green); background: #f2faf6; }

/* Lista de perguntas (edição) */
.lista-perguntas-edit { display: flex; flex-direction: column; gap: 10px; }
.pergunta-edit-item { border: 1.5px solid var(--border); border-radius: 10px; padding: 10px; }
.pergunta-edit-topo { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pergunta-edit-topo select { flex-shrink: 0; width: auto; font-size: 13px; padding: 7px 8px; }
.pergunta-edit-remover { margin-left: auto; background: none; border: none; color: var(--danger); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px; }
.pergunta-edit-item textarea { width: 100%; border: none; resize: vertical; font-size: 14.5px; padding: 4px; font-family: inherit; }
.pergunta-edit-item textarea:focus { outline: none; }
.pergunta-edit-reorder { display: flex; gap: 3px; }
.pergunta-edit-reorder button { background: #eef1f6; border: none; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; color: var(--navy); }

/* Coleta */
.coleta-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 700; color: var(--navy); }
.progresso-barra { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.progresso-fill { height: 100%; width: 0%; background: var(--green); transition: width .25s ease; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { border: 1.5px solid var(--border); background: #fff; border-radius: 20px; padding: 9px 16px; cursor: pointer; font-size: 14px; }
.chip:hover { border-color: var(--green); }
.chip.selecionado { background: var(--green); border-color: var(--green); color: #fff; }
.ajuda { color: var(--text-muted); font-size: 12.5px; margin: -4px 0 10px; }

.pergunta-indice { font-size: 12.5px; color: var(--text-muted); font-weight: 700; }
.pergunta-tipo-badge {
  display: inline-block; background: #eef1f6; color: var(--navy); font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; margin: 4px 0 10px; text-transform: uppercase; letter-spacing: .03em;
}

.resposta-nota10 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 14px 0; }
.nota-btn {
  border: 1.5px solid var(--border); background: #fff; border-radius: 10px; padding: 12px 0; font-size: 16px; font-weight: 700;
  cursor: pointer; color: var(--navy);
}
.nota-btn.selecionado { background: var(--navy); border-color: var(--navy); color: #fff; }

.resposta-likert { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.likert-btn {
  border: 1.5px solid var(--border); background: #fff; border-radius: 10px; padding: 12px 14px; font-size: 14.5px;
  text-align: left; cursor: pointer; color: var(--text); display: flex; justify-content: space-between; align-items: center;
}
.likert-btn.selecionado { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }


.aviso-inline { background: #fdecea; color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

.coleta-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.coleta-acoes .btn-primario { flex: 1; min-width: 140px; }
.coleta-acoes .btn-secundario { padding-left: 14px; padding-right: 14px; }

/* Relatório */
.relatorio-resumo { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.resumo-numero { font-size: 30px; font-weight: 800; color: var(--navy); line-height: 1; }
.resumo-label { font-size: 12px; color: var(--text-muted); }
.campo-filtro { min-width: 200px; margin: 0; }

.relatorio-perguntas { display: flex; flex-direction: column; gap: 12px; }
.pergunta-relatorio-card .pergunta-relatorio-topo {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 10px;
}
.pergunta-relatorio-titulo { font-weight: 700; color: var(--navy); font-size: 15px; flex: 1; }
.pergunta-relatorio-media { text-align: right; flex-shrink: 0; }
.media-numero { font-size: 26px; font-weight: 800; color: var(--green-dark); line-height: 1; }
.media-sub { font-size: 11.5px; color: var(--text-muted); }

.dist-barras { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.dist-linha { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.dist-linha .dist-label { width: 120px; flex-shrink: 0; text-align: right; }
.dist-linha .dist-barra-fundo { flex: 1; background: #eef1f6; border-radius: 6px; height: 14px; overflow: hidden; }
.dist-linha .dist-barra-preench { height: 100%; background: var(--green); border-radius: 6px; }
.dist-linha .dist-count { width: 24px; flex-shrink: 0; }

.comentarios-toggle { background: none; border: none; color: var(--navy); font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 6px 0; }
.comentarios-lista { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.comentario-item { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.comentario-item .comentario-autor { font-size: 11px; color: var(--text-muted); font-weight: 700; margin-bottom: 3px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: var(--shadow); z-index: 50;
}

/* Desktop */
@media (min-width: 860px) {
  #app { max-width: 960px; padding: 28px 32px; }
  .modelo-opcoes { grid-template-columns: repeat(3, 1fr); }
  .resposta-nota10 { grid-template-columns: repeat(11, 1fr); }
  .resposta-likert { flex-direction: row; flex-wrap: wrap; }
  .likert-btn { flex: 1 1 180px; justify-content: center; }
  .card { padding: 24px 28px; }
  .lista-pesquisas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .relatorio-perguntas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: start; }
}

@media print {
  .no-print, .topbar, #btn-voltar { display: none !important; }
  body { background: #fff; }
  .card, .pergunta-relatorio-card { box-shadow: none; border: 1px solid #ddd; }
  .relatorio-perguntas { display: block !important; }
  .pergunta-relatorio-card { break-inside: avoid; margin-bottom: 14px; }
}


.correcoes { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 8px; }
.chip-correcao { background: #fff6e0; border: 1px solid #f0d9a0; color: #7a5a00; border-radius: 16px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.chip-correcao:hover { background: #ffefc2; }

#btn-autocorrecao { display: block; margin: 2px 0 12px; }

.status-rede { position: sticky; top: 0; z-index: 30; background: #b45309; color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: 8px 12px; }
.painel-overlay { position: fixed; inset: 0; background: rgba(18, 33, 63, .55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 20px 12px; overflow-y: auto; }
.painel-overlay.hidden { display: none; }
.painel-setores-card { width: 100%; max-width: 480px; }
.setor-linha { display: flex; gap: 8px; margin-bottom: 8px; }
.setor-linha input { flex: 1; padding: 10px 12px; border: 1px solid #cfd6e2; border-radius: 8px; font-size: 15px; }
.setor-linha button { flex: none; }
.editar-acoes-lista { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.coleta-status { gap: 8px; flex-wrap: wrap; }
