:root {
  --azul: #1d3557;
  --azul-2: #274472;
  --ouro: #c9a227;
  --fundo: #f5f3ee;
  --card: #ffffff;
  --texto: #1f2430;
  --muted: #6b7280;
  --borda: #e3dfd5;
  --ok: #2e7d32;
  --warn: #b26a00;
  --erro: #b3261e;
  --wa: #1fa855;
  --raio: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--azul-2); }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--azul); line-height: 1.2; }
h1 { font-size: 1.9rem; margin: .2em 0 .5em; }
h2 { font-size: 1.25rem; margin: 0 0 .7em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 480px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }

/* topo */
.top { background: var(--azul); color: #fff; border-bottom: 3px solid var(--ouro); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-family: Georgia, serif; font-size: 1.15rem; font-weight: bold; }
.cross { color: var(--ouro); }
.top nav { display: flex; gap: 4px 14px; flex-wrap: wrap; align-items: center; }
.top nav a { color: #e8ecf5; text-decoration: none; font-size: .93rem; }
.top nav a:hover { color: var(--ouro); }
.top nav a.btn { color: var(--azul); }
main.wrap { padding-top: 24px; padding-bottom: 40px; min-height: 70vh; }
.foot { color: var(--muted); font-size: .85rem; padding-bottom: 30px; text-align: center; }

/* componentes */
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.btn { display: inline-block; background: var(--azul); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--azul-2); }
.btn.ghost { background: transparent; color: var(--azul); border: 1px solid var(--azul); }
.btn.ghost:hover { background: #eef2f8; }
.btn.danger { background: var(--erro); color: #fff; border-color: var(--erro); }
.btn.ghost.danger { background: transparent; color: var(--erro); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.wa { background: var(--wa); }
.top .btn.small { background: var(--ouro); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.actions.sticky { position: sticky; bottom: 0; background: var(--fundo); padding: 12px 0; }
form.inline { display: inline; }
label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
input:not([type=checkbox]):not([type=file]), select, textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid #cfcabd; border-radius: 8px; font: inherit; background: #fff; }
input[type=file] { display: block; margin-top: 6px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ouro); border-color: var(--ouro); }
fieldset { border: 1px dashed var(--borda); border-radius: 10px; padding: 12px 14px; margin: 6px 0 14px; }
legend { font-weight: 700; color: var(--azul); padding: 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.flash { background: #fff8e1; border: 1px solid #f0d78c; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.err { background: #fdecea; border-color: #f5c2c0; }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: #eceae4; color: #444; font-weight: 600; vertical-align: middle; }
.tag.ok { background: #e3f3e4; color: var(--ok); }
.tag.warn { background: #fff1db; color: var(--warn); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
code.block { display: block; background: #f3f1ea; padding: 10px; border-radius: 8px; word-break: break-all; font-size: .85rem; }
pre { white-space: pre-wrap; background: #f3f1ea; padding: 10px; border-radius: 8px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cols > .card { margin-bottom: 0; }
.cols + .card, .cols + .cols { margin-top: 18px; }
.filters { display: flex; gap: 10px; margin-bottom: 10px; }
.filters input, .filters select { margin-top: 0; max-width: 280px; }

/* início */
.hero { text-align: center; padding: 40px 0 30px; }
.hero .kicker { color: var(--ouro); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .85rem; }
.hero h1 { font-size: 2.6rem; }
.hero h1 span { color: var(--ouro); }
.hero .lead { max-width: 640px; margin: 0 auto 10px; font-size: 1.08rem; color: #444; }
.hero .actions { justify-content: center; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* painel */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { margin: 0; text-align: center; padding: 16px 10px; }
.stat b { display: block; font-size: 1.8rem; color: var(--azul); font-family: Georgia, serif; }
.stat b.small { font-size: 1.05rem; padding: 9px 0; }
.stat span { color: var(--muted); font-size: .85rem; }
.sim { margin-top: 14px; padding: 12px; border-left: 4px solid var(--ouro); background: #fbfaf6; border-radius: 6px; }

/* mídia */
.media audio, .media video { width: 100%; max-width: 560px; margin-top: 8px; }
.media video { border-radius: 8px; background: #000; }
.media img { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.qr { display: block; width: 260px; max-width: 100%; margin: 12px auto; background: #fff; padding: 8px; border-radius: 8px; }

/* área do aluno */
.search { margin: 6px 0 18px; padding: 12px 14px !important; font-size: 1rem; }
.faq-item { padding: 0; }
.faq-item summary { cursor: pointer; padding: 16px 20px; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item[open] summary { border-bottom: 1px solid var(--borda); }
.faq-item > p, .faq-item > .media { padding: 0 20px; }
.faq-item > .media { padding-bottom: 18px; }
.num { background: var(--azul); color: #fff; border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; flex: none; }

/* conversas */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.list { padding: 10px; max-height: 78vh; overflow: auto; margin: 0; }
.list-search input { margin: 0 0 8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs a { font-size: .82rem; padding: 4px 10px; border-radius: 99px; text-decoration: none; background: #f0eee8; color: #444; }
.tabs a.on { background: var(--azul); color: #fff; }
.contact { display: block; padding: 10px; border-radius: 8px; text-decoration: none; color: inherit; border-bottom: 1px solid #f1efe9; }
.contact:hover, .contact.sel { background: #f3f1ea; }
.contact small { display: block; color: var(--muted); }
.chat { margin: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-bottom: 1px solid var(--borda); padding-bottom: 10px; }
.chat-head h2 { margin: 0; }
.msgs { height: 52vh; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 8px; background: #efeae2; border-radius: 8px; margin: 12px 0; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 10px; background: #fff; margin: 0 10px; box-shadow: 0 1px 1px rgba(0,0,0,.06); white-space: normal; word-wrap: break-word; }
.msg.out { align-self: flex-end; background: #d9fdd3; }
.msg small { display: block; text-align: right; color: var(--muted); font-size: .72rem; }
.reply textarea { margin-top: 0; }
.send-item select { width: auto; flex: 1; margin-top: 0; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols, .grid3, .chat-layout, .row2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .msgs { height: 45vh; }
}

/* chat do site */
.webchat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.wc-head { display: flex; align-items: center; gap: 12px; background: var(--azul); color: #fff; padding: 12px 16px; }
.wc-head small { display: block; color: #cdd6e6; font-size: .8rem; }
.wc-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ouro); color: var(--azul); display: inline-flex; align-items: center; justify-content: center; font-weight: bold; }
.wc-msgs { height: 55vh; min-height: 320px; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 8px; background: #efeae2; }
.wc-vazio { margin: auto; color: var(--muted); text-align: center; padding: 0 20px; }
.msg .m-tit { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.msg audio { width: 260px; max-width: 100%; display: block; }
.msg video, .msg img { width: 100%; max-width: 360px; border-radius: 8px; display: block; background: #000; }
.msg.sys { align-self: center; background: #fff3cd; font-size: .85rem; }
.msg.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: #9aa1ad; animation: pisca 1s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .2s; } .msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pisca { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.wc-chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 4px; border-top: 1px solid var(--borda); }
.wc-chips button { flex: none; border: 1px solid var(--azul); background: #fff; color: var(--azul); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.wc-chips button:hover { background: #eef2f8; }
.wc-chips button.hum { border-color: var(--ouro); color: #7a5f0c; }
.wc-form { display: flex; gap: 8px; padding: 10px 12px 12px; align-items: center; }
.wc-form input { margin: 0 !important; }
.wc-mic { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid #cfcabd; background: #fff; cursor: pointer; font-size: 1.1rem; }
.wc-mic.rec { background: var(--erro); border-color: var(--erro); animation: pisca 1s infinite; }
.faq-title { margin-top: 26px; }
.tag.site { background: #e6eefb; color: var(--azul-2); }
/* na visão do aluno, as mensagens dele ficam à direita */
.wc-msgs .msg.in { align-self: flex-end; background: #d9fdd3; }
.wc-msgs .msg.out { align-self: flex-start; background: #fff; }

.top nav a.voltar-site { color: var(--ouro); font-weight: 600; margin-right: 6px; }
.top nav a.voltar-site:hover { color: #fff; }

.btn.seta { padding: 2px 8px; line-height: 1.2; }
.btn:disabled { opacity: .3; cursor: default; }

/* respostas rápidas */
.rapidas { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.chip { border: 1px solid var(--azul); background: #fff; color: var(--azul); border-radius: 99px; padding: 4px 11px; font: inherit; font-size: .82rem; cursor: pointer; }
.chip:hover { background: #eef2f8; }

.tag.papel-admin { background: #1d3557; color: #fff; }
.tag.papel-supervisor { background: #fff1db; color: #8a5a00; }
.tag.papel-operador { background: #e6eefb; color: #274472; }

/* permissões */
table.perm th.c, table.perm td.c { text-align: center; width: 130px; }
table.perm tr.grupo td { background: #f3f1ea; font-weight: 700; color: var(--azul); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
table.perm input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
.cols > .card:only-child { grid-column: 1 / -1; }

/* avaliação */
.wc-estrelas { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 10px; border-top: 1px solid var(--borda); background: #fffbea; }
.wc-estrelas span { font-weight: 600; color: var(--azul); margin-right: 6px; font-size: .9rem; }
.wc-estrelas button { border: 0; background: none; font-size: 1.9rem; line-height: 1; color: #d6d0bf; cursor: pointer; padding: 0 2px; }
.wc-estrelas button.on { color: var(--ouro); }
.estrelas { color: var(--ouro); letter-spacing: 1px; white-space: nowrap; }
.estrelas .off { color: #ddd6c4; }
.barra { background: #eee9dc; border-radius: 99px; height: 10px; overflow: hidden; min-width: 120px; }
.barra i { display: block; height: 100%; background: var(--ouro); }
.filters a.on { font-weight: 700; text-decoration: none; color: var(--azul); }
[hidden] { display: none !important; }

/* banner instalar app */
.instalar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--borda); border-left: 4px solid var(--ouro);
  border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.instalar img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.instalar-txt { flex: 1; font-size: .88rem; line-height: 1.35; }
.instalar-txt > b { display: block; color: var(--azul); font-size: .95rem; }
.instalar-x { border: 0; background: none; font-size: 1.1rem; color: var(--muted); cursor: pointer; padding: 4px 6px; }
.ios-share { display: inline-block; border: 1.5px solid currentColor; border-radius: 4px; padding: 0 4px; font-size: .8em; }
@media (display-mode: standalone) { .top { padding-top: env(safe-area-inset-top); } }
tr.sub td { background: #fbfaf6; }
tr.raiz td { border-top: 1px solid #e6e1d4; }

.wc-chips button.volta { border-color: #9aa1ad; color: #444; }
.wc-sub { flex: none; align-self: center; font-size: .82rem; font-weight: 700; color: var(--azul); padding: 0 4px; }

/* anexos */
.anexo-prev { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #f3f1ea; border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: .9rem; }
.anexo-prev audio { height: 34px; max-width: 260px; }
.btn.rec { background: var(--erro); color: #fff; border-color: var(--erro); }
.msg .btn.small.ghost { margin-top: 4px; }

/* fila e equipe online */
.tag.fila { background: #fde8e7; color: #a12a20; }
.online-box { font-size: .82rem; color: var(--muted); padding: 4px 6px 8px; border-bottom: 1px solid #f1efe9; margin-bottom: 4px; }


/* =========================================================
   CELULAR (estética)
   ========================================================= */
.menu-toggle { display: none; }
.brand-curto { display: none; }
.top nav a.atual { color: var(--ouro); }
.voltar-lista { display: none; }
.chat-layout > * { min-width: 0; }
.tabs { flex-wrap: wrap; }

@media (max-width: 860px) {
  /* topo compacto com menu ☰ */
  .top { position: sticky; top: 0; z-index: 40; }
  .top-in { flex-wrap: nowrap; padding-top: 10px; padding-bottom: 10px; padding-top: max(10px, env(safe-area-inset-top)); }
  .brand { font-size: 1.05rem; white-space: nowrap; }
  .brand-longo { display: none; } .brand-curto { display: inline; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex: none;
    border: 1px solid rgba(255,255,255,.25); border-radius: 10px; background: transparent; color: #fff; font-size: 1.3rem; cursor: pointer; }
  #menu-topo { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--azul); border-bottom: 3px solid var(--ouro); box-shadow: 0 12px 24px rgba(0,0,0,.25); padding: 6px 12px 12px; max-height: 75vh; overflow-y: auto; }
  #menu-topo.aberto { display: flex; flex-wrap: nowrap; }
  #menu-topo a[hidden] { display: none; }
  #menu-topo a { font-size: 1rem; padding: 12px 8px; border-bottom: 1px solid rgba(255,255,255,.08); border-radius: 0; }
  #menu-topo a.atual { background: rgba(201,162,39,.12); border-radius: 8px; }
  #menu-topo a.btn.small { margin-top: 8px; text-align: center; border-radius: 8px; }
  .top-in { position: relative; }

  /* geral */
  main.wrap { padding-top: 16px; padding-bottom: 28px; }
  h1 { font-size: 1.5rem; margin-bottom: .4em; }
  .card { padding: 14px; border-radius: 14px; margin-bottom: 14px; }
  input:not([type=checkbox]):not([type=file]), select, textarea { font-size: 16px; } /* evita zoom no iPhone */
  .btn { padding: 11px 16px; }
  .btn.small { padding: 7px 11px; }
  .head-row { gap: 10px; }
  .head-row .actions { width: 100%; }
  .head-row .actions .btn, .head-row > .btn { flex: 1; text-align: center; }
  .filters { flex-wrap: wrap; }
  .filters input, .filters select { max-width: none; flex: 1 1 140px; }
  .actions.sticky { padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
  .foot { font-size: .78rem; }

  /* painel: números em 2 colunas, mais compactos */
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 8px; }
  .stat b { font-size: 1.5rem; }
  .stat span { font-size: .78rem; line-height: 1.25; display: block; }

  /* tabelas viram cartões */
  table.tabela-cartao thead { display: none; }
  table.tabela-cartao, table.tabela-cartao tbody { display: block; }
  table.tabela-cartao tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 12px 2px; border-bottom: 1px solid #ece8de; }
  table.tabela-cartao td { display: block; border: 0; padding: 0 !important; }
  table.tabela-cartao td.r { width: 100%; text-align: left; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  table.tabela-cartao td.r form { display: inline; }
  table.tabela-cartao td[data-rotulo]::before { content: attr(data-rotulo) ": "; color: var(--muted); font-size: .78rem; }
  table.tabela-cartao tr.sub { margin-left: 14px; border-left: 3px solid #e6e1d4; padding-left: 10px; }
  table.tabela-cartao td.nowrap { white-space: normal; }
  table:not(.tabela-cartao) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* conversas em modo app: lista OU conversa */
  .chat-layout { gap: 0; }
  .chat-layout.tem-conversa .list { display: none; }
  .chat-layout:not(.tem-conversa) .chat { display: none; }
  .list { max-height: none; padding: 8px; }
  .voltar-lista { display: inline-block; font-weight: 600; text-decoration: none; margin-bottom: 8px; }
  .chat { padding: 12px; }
  .chat-head { flex-wrap: wrap; }
  .chat-head form.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .msgs { height: calc(100dvh - 380px); min-height: 280px; margin: 10px -6px; border-radius: 10px; }
  .msg { max-width: 86%; }
  .rapidas { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .rapidas .chip { flex: none; }
  .reply .actions { gap: 8px; }
  .reply .actions .btn[value=responder] { flex: 1; }
  .send-item { flex-wrap: wrap; }
  .send-item select { width: 100%; flex: 1 1 100%; }

  /* área do aluno: chat em destaque */
  .aluno-topo h1 { font-size: 1.25rem; margin: 0; }
  .aluno-topo p.muted { display: none; }
  .aluno-topo .btn { padding: 8px 12px; font-size: .85rem; }
  .card.webchat { padding: 0; margin-left: -10px; margin-right: -10px; border-radius: 14px; }
  .wc-head { padding: 10px 12px; }
  .wc-msgs { height: calc(100dvh - 300px); min-height: 280px; }
  .wc-form { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .wc-mic { width: 40px; height: 40px; }
  .wc-form .btn { padding: 10px 14px; }
  .faq-item summary { padding: 14px; }
  .faq-item > p, .faq-item > .media { padding: 0 14px; }

  /* início e login */
  .hero { padding: 18px 0 10px; }
  .hero h1 { font-size: 1.8rem; }
  .hero .lead { font-size: 1rem; }
  .hero .actions .btn { width: 100%; text-align: center; }
  .narrow { margin: 16px auto; }
  .instalar { bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* Nova conversa no WhatsApp */
.nova-conversa { margin-bottom: 12px; }
.nova-conversa summary { list-style: none; display: block; text-align: center; cursor: pointer; }
.nova-conversa summary::-webkit-details-marker { display: none; }
.nova-conversa[open] summary { margin-bottom: 10px; }
.nova-conversa form { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--borda); border-radius: 10px; background: #fafaf7; }
.nova-conversa input:not([type=checkbox]), .nova-conversa textarea { margin: 0 !important; width: 100%; }
.nova-conversa .check { display: flex; align-items: center; gap: 8px; }
.nova-conversa .check input { width: auto; margin: 0; }
.nova-conversa .check { margin: 0; }

/* Conhecimento aprendido */
.msg small .ensinar { color: var(--azul); font-weight: 600; text-decoration: none; white-space: nowrap; }
.msg small .ensinar:hover { text-decoration: underline; }
.k-resp { white-space: pre-line; }
.tag.sugerido { background: #fff4d6; color: #7a5f0c; }
.tag.inativo { background: #eee; color: #777; }

/* Excluir conversa (admin) */
.excluir-conversa { position: relative; display: inline-block; }
.excluir-conversa summary { list-style: none; cursor: pointer; }
.excluir-conversa summary::-webkit-details-marker { display: none; }
.excluir-conversa form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 290px; max-width: 85vw; background: #fff; border: 1px solid var(--borda);
  border-radius: 10px; box-shadow: 0 10px 24px rgba(0,0,0,.15); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.excluir-conversa form p { margin: 0 0 4px; }
@media (max-width: 860px) { .excluir-conversa form { left: 0; right: auto; } }
