* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #0f1420;
  color: #e8ecf4;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 28px 16px 8px;
  position: relative;
}
header h1 { font-size: 1.5rem; letter-spacing: 2px; }
header .sub { color: #8b95ab; font-size: .85rem; margin-top: 4px; }

#relogio {
  margin-top: 12px;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: #6fe3a5;
}
#relogio::after {
  content: " · BRASÍLIA";
  font-size: .62rem;
  letter-spacing: 1px;
  color: #5b6780;
  vertical-align: middle;
}

main { max-width: 100%; margin: 0 auto; padding: 20px 24px 60px; }

/* ABAS */
.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 14px 16px 0;
}
.tab {
  background: #171e2e;
  border: 1px solid #232c42;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  color: #8b95ab;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 10px 22px;
  cursor: pointer;
}
.tab.ativa { background: #0f1420; color: #e8ecf4; border-color: #4d7cfe; }
.hidden { display: none !important; }

/* SALVAR PAIOL */
.paiol-acoes { display: flex; gap: 12px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.status-chip { font-size: .72rem; font-weight: 700; letter-spacing: .5px; }
.status-chip.ok { color: #6fe3a5; }
.status-chip.dirty { color: #ffd166; }
.btn.salvar { background: #2e7d4f; }
.btn.salvar:disabled { background: #232c42; color: #5b6780; cursor: default; }
.btn.whatsapp { background: #1faa55; }
.btn.whatsapp:hover { background: #189a4a; }

.card {
  background: #171e2e;
  border: 1px solid #232c42;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 { font-size: .8rem; letter-spacing: 1.5px; color: #9fb0d0; margin-bottom: 14px; }

.hint { font-weight: 400; letter-spacing: 0; text-transform: none; color: #5b6780; }

input, select {
  background: #0f1420;
  border: 1px solid #2a3550;
  border-radius: 8px;
  color: #e8ecf4;
  padding: 9px 12px;
  font-size: .9rem;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: #4d7cfe; }

.btn {
  background: #4d7cfe;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #3d6bee; }
.btn.mini { padding: 5px 10px; font-size: .75rem; }
.btn.danger { background: #3a2230; color: #ff7b9c; }
.btn.danger:hover { background: #4a2a3c; }

/* FILTROS GLOBAIS */
.filtros-globais {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}
.filtros-globais::before {
  content: "🎛 FILTROS";
  font-size: .68rem;
  letter-spacing: 1.5px;
  color: #5b6780;
  font-weight: 700;
}
.filtros-globais select { width: auto; min-width: 150px; flex: 0 1 auto; }

/* TOTAIS */
.totais {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  align-items: start;
}
.total-card {
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid transparent;
}
.total-card .rotulo { font-size: .68rem; letter-spacing: 1.5px; opacity: .8; }
.total-card strong { font-size: 1.5rem; }
.total-card .valor2 { font-size: .8rem; opacity: .75; }
.total-card .valor-total { font-size: 1.35rem; font-weight: 700; display: block; }
.total-card .sep { border-top: 1px solid rgba(255,255,255,.15); margin: 8px 0; width: 100%; }
.azul     { background: #16233f; border-color: #24406e; color: #8fb8ff; }
.verde    { background: #123324; border-color: #1e5c40; color: #6fe3a5; }
.vermelho { background: #3a1b22; border-color: #6e2f40; color: #ff9db4; }
.roxo     { background: #241b3d; border-color: #43317a; color: #b7a3ff; }

.paiol-item {
  font-size: .78rem;
  padding: 3px 0;
  border-top: 1px solid rgba(255,255,255,.08);
  font-variant-numeric: tabular-nums;
}
.paiol-item:first-child { border-top: none; }

.solto-periodo {
  margin-top: 8px;
  font-size: .72rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 8px;
}
.solto-periodo div { display: flex; justify-content: space-between; gap: 8px; }
.solto-periodo b { font-weight: 700; }
.solto-periodo b.up { color: #6fe3a5; }
.solto-periodo b.down { color: #ff9db4; }
.solto-periodo .comparacao { margin-top: 4px; }
.solto-periodo .comparacao span { font-size: .7rem; font-weight: 700; }
.solto-periodo .comparacao span.up { color: #6fe3a5; }
.solto-periodo .comparacao span.down { color: #ff9db4; }
.solto-periodo .comparacao span.neutro { color: #8b95ab; }

.total-card.clicavel { cursor: pointer; }
.total-card.clicavel:hover { filter: brightness(1.15); }

.extras {
  font-size: .68rem;
  color: #8b95ab;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.1);
  line-height: 1.6;
}

/* DESEMPENHO DO CICLO */
.desempenho-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.desp-item {
  background: #0f1420;
  border: 1px solid #232c42;
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}
.desp-item .desp-rotulo { font-size: .64rem; letter-spacing: 1.2px; color: #8b95ab; }
.desp-item .desp-valor { font-size: 1.15rem; font-weight: 700; margin: 6px 0 2px; }
.desp-item .desp-cmp { font-size: .72rem; font-weight: 700; }
.desp-item .desp-cmp.up { color: #6fe3a5; }
.desp-item .desp-cmp.down { color: #ff9db4; }
.desp-item .desp-cmp.neutro { color: #8b95ab; }
.desp-item .desp-sub { font-size: .66rem; color: #5b6780; margin-top: 2px; }

.modal-box.largo { width: min(860px, 94vw); text-align: left; }
.modal-box.largo h3 { text-align: center; }
.modal-box.largo .btn { display: block; margin: 14px auto 0; }
#drill-tabela td, #drill-tabela th { white-space: nowrap; }

/* ============ PLANILHAS ============ */
.plan-grupo { margin-bottom: 18px; }
.plan-grupo-titulo {
  font-size: .85rem;
  font-weight: 700;
  color: #e8ecf4;
  margin-bottom: 8px;
}
.plan-mes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  padding: 6px 0 6px 18px;
  color: #9fb0d0;
  font-size: .82rem;
  cursor: pointer;
  border-radius: 6px;
}
.plan-mes:hover { background: #101a30; }
.plan-mes .tree { color: #5b6780; }

.plan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.plan-card {
  background: #0f1420;
  border: 1px solid #2a3550;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.plan-card:hover { border-color: #4d7cfe; }
.plan-card .pc-titulo { font-size: 1rem; font-weight: 700; }
.plan-card .pc-mes { font-size: .72rem; color: #8fb8ff; letter-spacing: 1px; margin: 4px 0; }
.plan-card .pc-info { font-size: .72rem; color: #8b95ab; }

/* planilha aberta — visual mensagem WhatsApp */
.planilha {
  max-width: 560px;
  margin: 0 auto;
}
.planilha-head {
  text-align: center;
  margin-bottom: 12px;
}
.planilha-head .ph-titulo { font-size: 1rem; font-weight: 700; letter-spacing: .5px; }
.planilha-head .ph-meta { font-size: .72rem; color: #8b95ab; margin-top: 4px; }
.planilha-msg {
  background: #0b3d2e;
  border: 1px solid #14523f;
  border-radius: 12px;
  padding: 16px 18px;
  font-family: "Segoe UI", Arial, sans-serif;
}
.pl-linha {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  font-size: .92rem;
  color: #e8f5ee;
  flex-wrap: wrap;
}
.pl-qtd { min-width: 46px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-emoji { width: 22px; }
.pl-loj { flex: 1; text-transform: uppercase; letter-spacing: .5px; min-width: 0; overflow-wrap: anywhere; }
.pl-data { color: #9fd3bb; font-variant-numeric: tabular-nums; }
.pl-valor { color: #ffd166; font-variant-numeric: tabular-nums; }
.pl-obs { color: #9fd3bb; font-style: italic; }
.pl-status { margin-left: 2px; }
.pl-sep { border-top: 1px solid #14523f; margin: 12px 0 8px; }
.pl-resumo { font-size: .82rem; line-height: 1.7; color: #cfeee0; }
.pl-resumo b { color: #fff; }
.planilha-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.plan-voltar { margin-bottom: 12px; }

/* LOGIN */
#login-screen {
  position: fixed; inset: 0; z-index: 100;
  background: #0b0f1a;
  display: flex; align-items: center; justify-content: center;
}
#login-screen.hidden { display: none; }
.login-box {
  background: #171e2e; border: 1px solid #2a3550; border-radius: 14px;
  padding: 30px 26px; width: min(340px, 90vw);
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-box h2 { font-size: .95rem; color: #9fb0d0; letter-spacing: 1px; }
.login-box input { width: 100%; box-sizing: border-box; }
.login-erro { color: #ff9db4; font-size: .8rem; min-height: 1em; }
.user-badge {
  position: absolute; top: 14px; left: 16px;
  font-size: .78rem; color: #9fb0d0; display: flex; align-items: center; gap: 8px;
}
.user-badge.hidden { display: none; }
.user-badge .btn { padding: 3px 10px; }
.user-badge { cursor: pointer; }
.user-menu {
  position: absolute; top: 42px; left: 16px; z-index: 60;
  background: #171e2e; border: 1px solid #2a3550; border-radius: 10px;
  padding: 6px; min-width: 170px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.user-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: #dce6f5; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: .82rem;
}
.user-menu button:hover { background: #223252; }
.campo-senha { position: relative; display: flex; align-items: center; }
.campo-senha input { width: 100%; padding-right: 42px; }
.campo-senha .olho {
  position: absolute; right: 6px; background: none; border: none;
  cursor: pointer; font-size: 1rem; padding: 4px 6px; opacity: .8;
}
.campo-senha .olho:hover { opacity: 1; }
.login-lb { font-size: .68rem; color: #7d8aa8; letter-spacing: 1px; text-align: left; }
.login-msg { color: #8fb8ff; font-size: .82rem; min-height: 1em; }
.cred-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

/* contador de sessão */
.sessao-timer {
  position: absolute; top: 14px; right: 16px;
  font-size: .78rem; color: #9fb0d0; font-variant-numeric: tabular-nums;
  background: #171e2e; border: 1px solid #2a3550; border-radius: 8px; padding: 4px 10px;
}
.sessao-timer.hidden { display: none; }
.sessao-timer.alerta { border-color: #ffb020; color: #ffd166; }
.sessao-timer.critico { border-color: #ff5f7e; color: #ff9db4; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* popovers 📱 e 🔴 */
.pop { position: relative; display: inline-block; }
.pop > .pop-ico {
  background: none; border: none; cursor: pointer; font-size: .85rem;
  padding: 2px 4px; border-radius: 6px;
}
.pop > .pop-ico.off { opacity: .3; cursor: default; }
.pop-box {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #1f2c3f; border: 1px solid #35507a; border-radius: 10px;
  padding: 10px 12px; font-size: .78rem; color: #dce6f5; white-space: nowrap;
  display: none; z-index: 45; box-shadow: 0 8px 22px rgba(0,0,0,.5);
  max-width: 88vw; white-space: normal; text-align: center;
}
.pop.aberto .pop-box { display: block; }
@media (hover: hover) { .pop:hover .pop-box { display: block; } }
.pop.abaixo .pop-box { bottom: auto; top: calc(100% + 8px); }
.pop.esq .pop-box { left: auto; right: -8px; transform: none; }
.pop-box .btn { margin-top: 8px; font-size: .75rem; padding: 5px 10px; }
.pop-box .pop-tel { color: #9fd3bb; }

/* select Pago? Sim/Não */
.sel-pago {
  background: #171e2e; color: #dce6f5; border: 1px solid #2a3550; border-radius: 8px;
  padding: 4px 6px; font-size: .78rem; cursor: pointer; transition: all .15s;
}
.sel-pago:hover { border-color: #4d7cfe; }
.sel-pago.sim { border-color: #2ea86f; color: #7dffc4; }
.sel-pago.nao { border-color: #a03050; color: #ff9db4; }

.neg-info {
  background: #2a1520; border: 1px solid #a03050; border-radius: 10px;
  padding: 12px; font-size: .85rem; color: #ffccd8; margin-bottom: 12px; line-height: 1.6;
}
#neg-motivo { width: 100%; box-sizing: border-box; }

/* scroll 3D sutil */
main { perspective: 900px; }
.card, .total-card { transition: transform .35s ease, opacity .35s ease; }
.fx-in { opacity: .96; transform: translateY(6px) scale(.995); }
.fx-in.mostra { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .card, .total-card { transition: none; }
  .fx-in { opacity: 1; transform: none; }
}

.wa-presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.wa-presets .btn { margin: 0 !important; display: inline-block !important; }
.wa-opcoes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: .78rem;
  color: #9fb0d0;
  margin-bottom: 12px;
}
.wa-opcoes label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wa-opcoes input { width: auto; }
.wa-preview {
  background: #0b3d2e;
  border: 1px solid #14523f;
  border-radius: 10px;
  padding: 14px;
  font-size: .82rem;
  line-height: 1.6;
  color: #e8f5ee;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "Segoe UI", Arial, sans-serif;
  max-height: 50vh;
  overflow-y: auto;
}
.wa-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

@media print {
  body * { visibility: hidden; }
  #wa-print-area, #wa-print-area * { visibility: visible; }
  #wa-print-area { position: absolute; inset: 0; background: #fff; color: #000; padding: 20px; font-size: 12pt; }
}
.solto-mercs { margin-top: 6px; }
.solto-mercs .paiol-item { font-size: .74rem; }
.solto-mercs .paiol-item .mes-ref {
  color: #5b6780;
  font-size: .66rem;
  margin-left: 4px;
}

/* FORMS */
.forms { display: grid; grid-template-columns: 1fr 1.6fr; gap: 18px; margin-bottom: 18px; }
.linha { display: flex; gap: 10px; flex-wrap: wrap; }
.linha select { flex: 1.2; min-width: 130px; }
.linha input[type="number"] { min-width: 90px; flex: 0.8; }
.linha input[type="date"] { width: auto; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chips li {
  background: #0f1420;
  border: 1px solid #2a3550;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chips li button {
  background: none; border: none; color: #ff7b9c; cursor: pointer; font-size: .9rem;
}

/* sem barras de rolagem visíveis (o conteúdo continua rolável) */
html { scrollbar-width: none; }
::-webkit-scrollbar { display: none; }

/* TABELA */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left;
  font-size: .68rem;
  letter-spacing: 1px;
  color: #8b95ab;
  padding: 8px 10px;
  border-bottom: 1px solid #232c42;
}
td { padding: 10px; border-bottom: 1px solid #1c2436; vertical-align: top; }
tr.quitado td { opacity: .55; }

.recolhe-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #123324;
  color: #6fe3a5;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: .78rem;
  margin: 2px 4px 2px 0;
}
.recolhe-item button { background: none; border: none; color: #ff9db4; cursor: pointer; }

.add-recolhe { display: flex; gap: 6px; margin-top: 6px; }
.add-recolhe input { width: 90px; padding: 5px 8px; font-size: .78rem; }

.badge {
  display: inline-block;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.badge.sim { background: #123324; color: #6fe3a5; }
.badge.nao { background: #3a1b22; color: #ff9db4; cursor: pointer; border: none; }
.badge.nao:hover { background: #4a2430; }

.vazio { text-align: center; color: #8b95ab; padding: 24px !important; }

/* FILTROS */
.filtro { max-width: 280px; margin-bottom: 12px; }
.filtros-linha { display: flex; gap: 10px; flex-wrap: wrap; }
.filtros-linha .filtro { margin-bottom: 0; }
.card .filtros-linha { margin-bottom: 12px; }

/* AGRUPAMENTO POR MÊS */
.mes-row td {
  background: #101a30;
  color: #8fb8ff;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 8px 10px;
}
.mes-row td span { color: #5b6780; font-weight: 400; letter-spacing: 0; }

/* MERCADORIAS */
#add-merc { margin-top: 14px; }
.emoji-btn {
  background: #0f1420;
  border: 1px solid #2a3550;
  border-radius: 8px;
  font-size: 1.3rem;
  padding: 4px 10px;
  cursor: pointer;
}
.emoji-btn:hover { border-color: #4d7cfe; }
.in-merc { width: 110px; padding: 6px 8px; font-size: .85rem; }

/* seletor de mês/ano na tabela */
.mes-cell { white-space: nowrap; }
.sel-mm, .sel-aa {
  width: auto;
  padding: 6px 6px;
  font-size: .82rem;
}
.sel-mm { border-radius: 8px 0 0 8px; border-right: none; }
.sel-aa { border-radius: 0 8px 8px 0; }
select.filtro { width: auto; min-width: 160px; }
.in-nome { width: 130px; padding: 6px 8px; font-size: .85rem; }
.in-venc { width: 132px; padding: 3px 6px; font-size: .7rem; margin-top: 4px; display: block; }

/* MODAL DE EMOJIS */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-box {
  background: #171e2e;
  border: 1px solid #2a3550;
  border-radius: 14px;
  padding: 22px;
  width: min(560px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
}
.modal-box h3 { font-size: .9rem; color: #9fb0d0; margin-bottom: 16px; letter-spacing: 1px; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.emoji-grid button {
  background: #0f1420;
  border: 1px solid #2a3550;
  border-radius: 10px;
  font-size: 1.5rem;
  padding: 8px 0;
  cursor: pointer;
}
.emoji-grid button:hover { border-color: #4d7cfe; background: #16233f; }

@media (max-width: 800px) {
  .totais, .forms { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .totais, .forms { grid-template-columns: 1fr; }
  .filtro, select.filtro { max-width: 100%; width: 100%; }
  header h1 { font-size: 1.15rem; letter-spacing: 1px; }
  .total-card strong { font-size: 1.25rem; }
  .btn { padding: 10px 14px; }
  .btn.mini { padding: 8px 12px; font-size: .8rem; }
  .solto-mercs .paiol-item .mes-ref { font-size: .72rem; }
}

/* TABELAS EM MODO CARTÃO — sem rolagem horizontal */
@media (max-width: 900px) {
  .tabela-wrap thead { display: none; }
  .tabela-wrap table, .tabela-wrap tbody, .tabela-wrap tr, .tabela-wrap td {
    display: block;
    width: 100%;
  }
  .tabela-wrap tbody tr {
    background: #101a30;
    border: 1px solid #232c42;
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  .tabela-wrap tbody tr.mes-row {
    background: #0d1526;
    text-align: left;
    padding: 8px 12px;
  }
  .tabela-wrap td {
    border: none;
    padding: 5px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 12px;
    text-align: right;
  }
  .tabela-wrap td::before {
    content: attr(data-th);
    color: #8b95ab;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: left;
    flex-shrink: 0;
  }
  .tabela-wrap td[data-th=""]::before { display: none; }
  .tabela-wrap .mes-row td { display: block; text-align: left; }
  .tabela-wrap .mes-row td::before { display: none; }
  .tabela-wrap .vazio { display: block; text-align: center; }
  .tabela-wrap .vazio::before { display: none; }
  .in-nome, .in-merc { width: 120px; }
  .add-recolhe { flex: 1 1 100%; justify-content: flex-end; }
}
