/* Placar ao vivo da equipe (tela do cliente / TV 24x7). Base: preview aprovado. */

:root {
  --bg: #06101d;
  --panel: #0c1b2f;
  --panel-soft: rgba(255,255,255,.045);
  --text: #f7f9fc;
  --muted: #a8b7cc;
  --line: rgba(255,255,255,.09);
  --accent: #35f2a7;
  --accent-2: #35a7ff;
  --gold: #ffd166;
  --silver: #e6edf5;
  --bronze: #e59a5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(53,242,167,.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(53,167,255,.14), transparent 32%),
    var(--bg);
}

.screen {
  height: 100vh;
  padding: 28px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 22px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 3.6vw, 72px);
  line-height: .95;
  letter-spacing: -2px;
}

.subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(18px, 1.3vw, 28px);
  font-weight: 600;
}


.live {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(53,242,167,.12);
  border: 1px solid rgba(53,242,167,.35);
  font-size: clamp(18px, 1.25vw, 28px);
  font-weight: 900;
  white-space: nowrap;
}
/* estado "sem conexao": apos 2 fetches falhos seguidos (ver monitor.js).
   Fundo vermelho LEVE (translucido, como o verde original); o pulse continua
   piscando, porem em vermelho FORTE — luz de alerta. */
.live.offline {
  color: #ffb3b3;
  background: rgba(229,57,53,.14);
  border-color: rgba(229,57,53,.5);
}
.live.offline .pulse { background: #ff2d2d; animation: pulseRed 1.5s infinite; }

@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(255,45,45,.85); }
  70% { box-shadow: 0 0 0 16px rgba(255,45,45,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,45,45,0); }
}
.live-area {
  display: flex;
  align-items: center;
  gap: 20px;
}
.live-logo {
  height: clamp(44px, 3.2vw, 68px);   /* dobro do tamanho anterior; largura acompanha pela proporcao */
  width: auto;
  max-height: 68px;                   /* trava: nunca estoura mesmo antes do CSS aplicar */
  max-width: 75px;                    /* cubo ~1.06:1 (4025x3783); 68px de altura => ~72px largura */
  object-fit: contain;
  flex: 0 0 auto;                     /* nao deixa o flex container esticar/encolher o logo */
  display: block;
}

.pulse {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53,242,167,.8); }
  70% { box-shadow: 0 0 0 16px rgba(53,242,167,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,242,167,0); }
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.summary-card {
  padding: 20px 22px;
  min-height: 124px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  border: 1px solid var(--line);
  box-shadow: 0 20px 55px rgba(0,0,0,.22);
}

.label {
  color: var(--muted);
  font-size: clamp(15px, .95vw, 21px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.value {
  margin-top: 10px;
  font-size: clamp(34px, 2.9vw, 60px);
  font-weight: 950;
  letter-spacing: -1px;
}

.note {
  margin-top: 5px;
  color: var(--muted);
  font-size: clamp(14px, .9vw, 20px);
  font-weight: 600;
}

/* comparativo "hoje vs mesmo dia da semana passada" (estilo bolsa) no card Abastecimentos hoje.
   Sem negrito: em fonte pequena, peso uniforme (o do .note) le melhor — a cor ja destaca. */
.lw-pct { font-weight: inherit; white-space: nowrap; }
.lw-pct.up { color: #3ddc84; }
.lw-pct.down { color: #ff6b6b; }
.lw-pct.flat { color: var(--muted); }

.board {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;   /* top3 (auto) + ranking ocupa o resto (altura limitada p/ scroll) */
  min-height: 0;
  border-radius: 30px;
  background: rgba(12,27,47,.9);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: 0 26px 80px rgba(0,0,0,.3);
}

.top3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.025);
}

.podium-card {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border-radius: 26px;
  padding: 18px 22px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.podium-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.podium-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -80px auto;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  opacity: .18;
  background: var(--accent);
  transform: translate(-20px, -10px);
}

.podium-card.gold::after { background: var(--gold); }
.podium-card.silver::after { background: var(--silver); }
.podium-card.bronze::after { background: var(--bronze); }

.position {
  font-size: clamp(34px, 2.4vw, 54px);
  font-weight: 950;
}

.person {
  margin-top: 0;
  min-width: 0;
  text-align: right;
  font-size: clamp(24px, 1.9vw, 40px);
  font-weight: 950;
  letter-spacing: -1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.numbers {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.period-total {
  font-size: clamp(38px, 3vw, 70px);
  font-weight: 950;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.today-total {
  color: var(--accent);
  font-size: clamp(18px, 1.25vw, 28px);
  font-weight: 900;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.05;
  text-align: right;
}
.today-total .today-label {
  font-size: 0.7em;   /* "hoje" 30% menor que o numero */
}

.ranking {
  padding: 12px 22px 20px;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#rankingRows {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;   /* scroll automatico via JS (modo apresentacao) */
}

.ranking-header,
.ranking-row {
  display: grid;
  /* #, Colaborador(a), Período, Hoje, Semana passada, Comparativo visual.
     Colaborador e Comparativo reduzidos ~25% (1fr->.75fr, 1.2fr->.9fr) p/ abrir espaco
     a coluna "semana passada" (numero + seta/% compactos). */
  grid-template-columns: 90px minmax(195px, .75fr) 160px 150px 240px minmax(195px, .9fr);
  align-items: center;
  gap: 18px;
}

.ranking-header {
  padding: 12px 8px 14px;
  color: var(--muted);
  font-size: clamp(14px, .9vw, 19px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--line);
}

.ranking-row {
  min-height: 76px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: clamp(22px, 1.55vw, 34px);
  font-weight: 900;
}

.ranking-row:last-child {
  border-bottom: none;
}

.rank {
  text-align: center;
  font-size: clamp(26px, 1.9vw, 42px);
  font-weight: 950;
}

.employee {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.065);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 21px;
  font-weight: 950;
}

.employee-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.today {
  color: var(--accent);
}

/* Coluna "semana passada" (compacta): numero + seta/% numa linha so. Fonte e peso
   herdados do .ranking-row — mesmo padrao das demais colunas numericas (ex.: HOJE). */
.ranking-row .lw { white-space: nowrap; }
/* Percentual 40% menor que o numero/seta, ancorado na baseline do numero (default inline). */
.ranking-row .lw .lw-pct-num { font-size: .6em; vertical-align: baseline; }

.bar-wrap {
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,.085);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
}

.bar {
  height: 100%;
  width: var(--w);
  min-width: 7%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s ease;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: clamp(15px, .95vw, 21px);
  font-weight: 700;
  padding: 0 4px;
}

.footer strong {
  color: var(--text);
}

/* botao (OFF) discreto no rodape, a esquerda do nome da empresa — desconecta (com confirmacao) */
.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.power-off-sm {
  flex: 0 0 auto;
  width: clamp(26px, 1.9vw, 34px);
  height: clamp(26px, 1.9vw, 34px);
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(229, 57, 53, .5);
  background: rgba(229, 57, 53, .12);
  color: #ff8a87;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.power-off-sm:hover {
  color: var(--muted);
  border-color: var(--line);
  background: rgba(255, 255, 255, .05);
}
.power-off-sm svg { width: 58%; height: 58%; display: block; }

#sessionId {
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  letter-spacing: .08em;
  color: inherit;          /* mesma cor do rodape ("Ultima atualizacao") — sem destaque */
  cursor: help;            /* indica que ha um hint no hover */
}

/* ---- comemoracao: confete + banner do vendedor ---- */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 60;
}
.celeb-banner {
  position: fixed;
  left: 50%;
  top: 11%;
  transform: translate(-50%, -16px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  border-radius: 999px;
  background: rgba(12, 27, 47, .96);
  border: 1px solid rgba(53, 242, 167, .5);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  color: var(--text);
  font-weight: 950;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 70;
  transition: opacity .25s ease, transform .25s ease;
}
.celeb-banner.show { opacity: 1; transform: translate(-50%, 0); }
.celeb-banner .celeb-emoji { font-size: clamp(24px, 2vw, 36px); }
.celeb-banner .celeb-name { font-size: clamp(22px, 1.8vw, 34px); color: var(--accent); letter-spacing: -.5px; }
.celeb-banner .celeb-msg { font-size: clamp(16px, 1.2vw, 24px); color: var(--muted); font-weight: 800; }

/* ---- overlay de mensagem sobre o placar (aguardando / inativado) ---- */
.board-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 16, 29, .92);
  z-index: 50;
}
.board-overlay-box {
  max-width: 620px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 44px 40px;
  box-shadow: 0 26px 80px rgba(0,0,0,.4);
}
.board-overlay .ov-title {
  font-size: clamp(28px, 3vw, 48px);
  font-weight: 950;
  letter-spacing: -1px;
}
.board-overlay .ov-sub {
  margin-top: 12px;
  color: var(--muted);
  font-size: clamp(16px, 1.3vw, 24px);
  font-weight: 600;
}
.board-overlay .ov-disconnect {
  margin-top: 28px;
  padding: 14px 30px;
  border: none;
  border-radius: 14px;
  background: #e53935;
  color: #fff;
  font-size: clamp(16px, 1.2vw, 22px);
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease;
}
.board-overlay .ov-disconnect:hover { background: #c62828; }

/* confirmacao de desconexao na visao principal do painel (botao OFF do cabecalho) */
.confirm-overlay { z-index: 80; background: rgba(6, 16, 29, .96); }
.confirm-actions {
  margin-top: 30px;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.confirm-btn {
  padding: 14px 30px;
  border: none;
  border-radius: 14px;
  font-size: clamp(16px, 1.2vw, 22px);
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease;
}
.confirm-btn.confirm-cancel { background: rgba(255, 255, 255, .12); color: var(--text); }
.confirm-btn.confirm-cancel:hover { background: rgba(255, 255, 255, .2); }
.confirm-btn.confirm-ok { background: #e53935; color: #fff; }
.confirm-btn.confirm-ok:hover { background: #c62828; }

/* ---- tela de estado (painel inativo / link invalido) ---- */
.state-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.state-box {
  max-width: 540px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 44px 36px;
  box-shadow: 0 26px 80px rgba(0,0,0,.3);
}

.state-box .icon {
  font-size: 52px;
  margin-bottom: 14px;
}

.state-box h1 {
  font-size: clamp(26px, 3vw, 44px);
  letter-spacing: -1px;
  margin: 0 0 12px;
}

.state-box p {
  color: var(--muted);
  font-size: clamp(16px, 1.2vw, 22px);
  line-height: 1.55;
  margin: 0;
}

.state-action {
  display: inline-block;
  margin-top: 26px;
  padding: 14px 28px;
  border-radius: 14px;
  background: #2f6bff;
  color: #fff;
  font-size: clamp(16px, 1.2vw, 20px);
  font-weight: 800;
  text-decoration: none;
  transition: background .15s ease;
}
.state-action:hover { background: #2657d6; }

.state-action-danger { background: #e53935; }
.state-action-danger:hover { background: #c62828; }

@media (max-width: 1200px) {
  body { overflow: auto; height: auto; }
  .screen { height: auto; }
  .summary, .top3 { grid-template-columns: 1fr; }
  .ranking-header { display: none; }
  .ranking-row {
    grid-template-columns: 70px 1fr 110px 100px;
  }
  .ranking-row .bar-wrap { display: none; }
  .ranking-row .lw { display: none; }  /* tela estreita: mantem 4 colunas legiveis */
}

/* ---- tela de nova conexao (liberacao de TV por codigo) ---- */
.newconn {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.newconn-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 4px;
}

.newconn-logo {
  height: clamp(54px, 6vw, 88px);
  width: auto;
  object-fit: contain;
  margin-bottom: 20px;
}

.newconn-title {
  margin: 0;
  font-size: clamp(20px, 1.8vw, 28px);
  font-weight: 900;
  letter-spacing: -.5px;
}

.newconn-subtitle {
  margin: 2px 0 16px;
  font-size: clamp(18px, 1.5vw, 26px);
  font-weight: 800;
  color: var(--text);
}

.newconn-code {
  margin: 12px 0 24px;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: clamp(48px, 7vw, 104px);
  font-weight: 950;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
  min-height: 1.1em;
}
.newconn-code.loading {
  color: var(--muted);
  letter-spacing: .35em;
}

.newconn-hint {
  margin: 4px 0;
  font-size: clamp(16px, 1.2vw, 22px);
  font-weight: 700;
  color: var(--text);
}
.newconn-hint-soft {
  max-width: 640px;
  color: var(--muted);
  font-weight: 600;
}

.newconn-expiry {
  margin-top: 20px;
  min-height: 1.2em;
  color: var(--muted);
  font-size: clamp(14px, 1vw, 18px);
  font-weight: 600;
}

.newconn-regen {
  flex: 0 0 auto;
  width: 100%;
  padding: 22px 24px;
  border: none;
  border-radius: 0;
  background: #2f6bff;
  color: #fff;
  font-size: clamp(18px, 1.4vw, 24px);
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease;
}
.newconn-regen:hover { background: #2657d6; }
.newconn-regen:disabled { opacity: .6; cursor: default; }

/* ---- tela "verificando conexao" (entrada /monitor_vendas sem uid) ---- */
.checking {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.checking-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.checking-logo {
  height: clamp(48px, 5vw, 76px);
  width: auto;
  object-fit: contain;
  margin-bottom: 24px;
}
.checking-spinner {
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .15);
  border-top-color: var(--accent);
  animation: checkingSpin .9s linear infinite;
}
@keyframes checkingSpin { to { transform: rotate(360deg); } }
.checking-title {
  margin: 0;
  font-size: clamp(22px, 2vw, 32px);
  font-weight: 900;
  letter-spacing: -.5px;
}
.checking-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 1.1vw, 20px);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .checking-spinner { animation-duration: 2.4s; }
}
