:root {
  --bg: #0f1420;
  --surface: #182033;
  --surface-2: #212b42;
  --line: #2c3854;
  --text: #e8edf7;
  --muted: #94a0ba;
  --accent: #19b38a;
  --accent-2: #12916f;
  --danger: #e5484d;
  --radius: 14px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* ---------- Lobby ---------- */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; margin-bottom: 6px; }
.brand-logo { height: 84px; width: auto; display: block; margin: -6px 0 4px -8px; }
.brand-icon { width: 36px; height: 36px; display: block; }
.brand-icon-sm { width: 30px; height: 30px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #3b82f6); color: #fff; font-size: 18px; }
.sub { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.field { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); outline: none; }
.field:focus { border-color: var(--accent); }
.btn { border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 600; color: #fff; background: var(--surface-2); }
.btn-primary { background: var(--accent); width: 100%; margin-top: 18px; }
.btn-primary:hover { background: var(--accent-2); }
.row { display: flex; gap: 8px; }
.row .field { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 22px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.erro { color: #ff8a8e; font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- Pré-entrada ---------- */
.prejoin { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; padding: 16px; z-index: 50; }
.prejoin .card { max-width: 520px; }
.preview { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; margin-bottom: 8px; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-ctrls { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; }

/* ---------- Sala ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.room-code { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.main { display: flex; min-height: 0; }
.stage { flex: 1; padding: 12px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.spotlight { flex: 1; min-height: 0; display: none; }
.spotlight .tile { height: 100%; }
.grid { flex: 1; min-height: 0; display: grid; gap: 12px; grid-template-columns: repeat(var(--cols, 1), 1fr);
  grid-auto-rows: 1fr; }
.stage.com-destaque .spotlight { display: block; }
.stage.com-destaque .grid { flex: 0 0 140px; grid-auto-flow: column; grid-template-columns: none;
  grid-auto-columns: 200px; overflow-x: auto; }

.tile { position: relative; background: var(--surface-2); border-radius: var(--radius); overflow: hidden;
  min-height: 0; border: 2px solid transparent; transition: border-color .15s; }
.tile.falando { border-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.tile.local video.espelho { transform: scaleX(-1); }
.tile.tela video { object-fit: contain; }
.tile .avatar { position: absolute; inset: 0; display: none; place-items: center; background: var(--surface-2); }
.tile.sem-cam:not(.tela) .avatar { display: grid; }
.avatar span { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 28px;
  font-weight: 700; background: linear-gradient(135deg, #3b82f6, var(--accent)); }
.tile .nome { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); padding: 4px 10px;
  border-radius: 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 16px); }
.tile .nome .mudo { display: none; color: #ff8a8e; }
.tile.mic-off .nome .mudo { display: inline; }
.tile .reacao { position: absolute; top: 10px; right: 12px; font-size: 36px; animation: sobe 2.4s ease-out forwards; }
@keyframes sobe { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 15% { opacity: 1; transform: none; }
  80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }

.controls { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface); border-top: 1px solid var(--line); flex-wrap: wrap; position: relative; }
.ctrl { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text);
  display: grid; place-items: center; position: relative; }
.ctrl:hover { background: #2b3755; }
.ctrl.off { background: var(--danger); }
.ctrl.ativo { background: var(--accent); }
.ctrl svg { width: 22px; height: 22px; }
.ctrl.sair { width: auto; border-radius: 24px; padding: 0 20px; background: var(--danger); font-weight: 600; }
.badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 9px; display: none; place-items: center; padding: 0 4px; }
.badge.on { display: grid; }
.reacoes { position: absolute; bottom: 72px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; display: none; gap: 4px; }
.reacoes.on { display: flex; }
.reacoes button { background: none; border: 0; font-size: 24px; padding: 6px; border-radius: 8px; }
.reacoes button:hover { background: var(--surface); }

/* ---------- Painel lateral ---------- */
.painel { width: 320px; border-left: 1px solid var(--line); background: var(--surface); display: none; flex-direction: column; }
.painel.on { display: flex; }
.painel header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--line); font-weight: 600; }
.painel header button { background: none; border: 0; color: var(--muted); font-size: 20px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 10px; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.mensagens { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg .autor { font-size: 12px; color: var(--muted); }
.msg .texto { background: var(--surface-2); padding: 8px 12px; border-radius: 10px; margin-top: 3px;
  word-wrap: break-word; white-space: pre-wrap; }
.msg.minha .texto { background: #17463c; }
.enviar { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.lista { list-style: none; margin: 0; padding: 8px 16px; overflow-y: auto; flex: 1; }
.lista li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lista .icones { color: var(--muted); }

.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: var(--surface-2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0;
  transition: opacity .2s; pointer-events: none; z-index: 60; }
.toast.on { opacity: 1; }

@media (max-width: 760px) {
  .painel.on { position: fixed; inset: 0; width: auto; z-index: 40; }
  .ctrl { width: 44px; height: 44px; }
  .stage.com-destaque .grid { flex-basis: 110px; grid-auto-columns: 150px; }
}

/* ---------- Login ---------- */
.dica { color: var(--muted); font-size: 13px; margin: 18px 0 0; text-align: center; }
select.field, textarea.field { appearance: none; font: inherit; }
textarea.field { resize: vertical; min-height: 70px; }
select.field { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

/* ---------- Painel ---------- */
.pg-painel { height: auto; min-height: 100%; }
.topo { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.topo-logo img { height: 46px; display: block; }
.abas { display: flex; gap: 4px; flex: 1; }
.abas button, .filtros button { background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.abas button:hover, .filtros button:hover { color: var(--text); background: var(--surface-2); }
.abas button.on, .filtros button.on { color: var(--text); background: var(--surface-2); }
.topo-user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.btn-sm { padding: 8px 12px; font-size: 13px; text-decoration: none; display: inline-block; }
.btn-acc { background: var(--accent); }
.btn-acc:hover { background: var(--accent-2); }
.btn-ghost { background: none; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.perigo { color: #ff8a8e; }
.conteudo { max-width: 1040px; margin: 0 auto; padding: 28px 24px 60px; }
.cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cabecalho h1 { font-size: 24px; margin: 0; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.filtros { display: flex; gap: 4px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filtros label { margin: 0 0 0 auto; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.lista-cards { display: flex; flex-direction: column; gap: 10px; }
.vazio { color: var(--muted); padding: 40px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.r-card { display: grid; grid-template-columns: 110px 1fr auto; gap: 18px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.r-quando { text-align: center; border-right: 1px solid var(--line); padding-right: 16px; }
.r-data { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.r-hora { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.r-dur { font-size: 12px; color: var(--muted); }
.r-corpo { min-width: 0; }
.r-corpo h3 { margin: 4px 0; font-size: 17px; overflow-wrap: anywhere; }
.r-linha { display: flex; gap: 8px; align-items: center; }
.r-dono { color: var(--muted); font-size: 12px; }
.r-desc { margin: 0 0 4px; color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-codigo { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.r-acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 300px; }
.selo { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .03em; }
.selo.agora { background: rgba(25,179,138,.18); color: #4fd6ae; }
.selo.futura { background: rgba(59,130,246,.18); color: #8db8ff; }
.selo.passada { background: var(--surface-2); color: var(--muted); }
.selo.gestor { background: rgba(245,166,35,.18); color: #f8c15c; }
.selo.usuario { background: var(--surface-2); color: var(--muted); }
.tabela-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tabela td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tr.inativo td { color: var(--muted); }
.t-acoes { text-align: right; white-space: nowrap; }
.voce { color: var(--muted); font-size: 12px; }
.card-form { max-width: 440px; }
.modal { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 24px;
  width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal::backdrop { background: rgba(5,8,15,.7); }
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.grade-2 { display: grid; grid-template-columns: 1fr 160px; gap: 12px; }
input[type="datetime-local"].field { color-scheme: dark; }

@media (max-width: 760px) {
  .topo { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .topo-logo img { height: 38px; }
  .abas { order: 3; flex-basis: 100%; overflow-x: auto; }
  .topo-user { margin-left: auto; }
  .topo-user span { display: none; }
  .conteudo { padding: 20px 16px 48px; }
  .r-card { grid-template-columns: 72px 1fr; }
  .r-acoes { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
  .grade-2 { grid-template-columns: 1fr; }
  .tabela thead { display: none; }
  .tabela tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .tabela td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 16px; }
  .tabela td[data-l]::before { content: attr(data-l); color: var(--muted); }
  .t-acoes { justify-content: flex-end !important; }
}
