:root {
  --fundo: #edf0ee;
  --superficie: #ffffff;
  --tinta: #1b2b25;
  --tinta-suave: #55665f;
  --linha: #ccd5d0;
  --verde: #0e7c5a;
  --verde-escuro: #0a5c43;
  --verde-claro: #dcefe6;
  --alerta: #b4541a;
  --alerta-claro: #f8e6da;
  --papel-conversa: #e7ece4;
  --raio: 10px;
  --titulo: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --texto: "Figtree", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fundo);
  color: var(--tinta);
  font-family: var(--texto);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--titulo); margin: 0; line-height: 1.15; }
h1 { font-size: 1.25rem; font-weight: 700; }
h2 { font-size: 2rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.35rem; font-weight: 500; }
p { margin: 0; }

button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.apoio { color: var(--tinta-suave); max-width: 62ch; }

input, textarea {
  width: 100%;
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 10px 12px;
}

.botao {
  border: 1px solid var(--linha);
  background: var(--superficie);
  border-radius: var(--raio);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.botao:hover { border-color: var(--tinta-suave); }
.botao.principal { background: var(--verde); border-color: var(--verde); color: #fff; }
.botao.principal:hover { background: var(--verde-escuro); border-color: var(--verde-escuro); }
.botao.perigo { color: var(--alerta); border-color: var(--alerta); }
.botao:disabled { opacity: 0.45; cursor: default; }

.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--tinta-suave); text-decoration: underline; text-underline-offset: 3px;
}
.link.claro { color: #d7ebe2; }
.perigo-texto { color: var(--alerta); }

.erro {
  background: var(--alerta-claro); color: #7a3409;
  border-radius: var(--raio); padding: 10px 12px; margin-top: 12px;
}

/* ---- login ---- */
.tela-login { min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; justify-items: center; padding: 16px; }
.login {
  width: min(400px, 100%);
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: 16px;
  padding: 32px;
}
.login h1 { font-size: 1.75rem; margin-bottom: 8px; }
.login .apoio { margin-bottom: 24px; }
.login .botao { width: 100%; margin-top: 16px; }

/* ---- estrutura ---- */
.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }

.lateral {
  background: var(--tinta);
  color: #e9f0ec;
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.lateral h1 { padding: 0 8px; }
.rodape-lateral { margin: auto 8px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.lateral .link { color: #a9bab2; }

.lojas { display: flex; flex-direction: column; gap: 2px; }
.lojas button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: none; border: 0; border-radius: 8px;
  padding: 10px 8px; color: inherit; cursor: pointer;
}
.lojas button:hover { background: rgba(255, 255, 255, 0.08); }
.lojas button[aria-current="true"] { background: var(--verde); color: #fff; font-weight: 600; }
.ponto { width: 9px; height: 9px; border-radius: 50%; background: #71837b; flex: none; }
.ponto.ligado { background: #5fe0a8; }
.lojas .sem-lojas { color: #a9bab2; padding: 0 8px; }

.nova-loja label { color: #a9bab2; font-weight: 500; padding: 0 8px; }
.nova-loja .linha { display: flex; gap: 8px; }
.nova-loja input { background: #26382f; border-color: #3a4f45; color: #fff; }
.nova-loja input::placeholder { color: #8fa39a; }
.nova-loja .botao { background: #26382f; border-color: #3a4f45; color: #fff; }

.conteudo { padding: 40px 48px; max-width: 1180px; width: 100%; }

.vazio { max-width: 52ch; margin-top: 12vh; }
.vazio h2 { margin-bottom: 12px; }
.vazio p { color: var(--tinta-suave); }

.cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.situacao { color: var(--tinta-suave); margin-top: 6px; }
.situacao.ligado { color: var(--verde-escuro); font-weight: 600; }

/* chave liga/desliga da IA */
.chave { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 6px 0 0; font-weight: 600; }
.chave input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.trilho {
  width: 46px; height: 26px; border-radius: 13px; background: #a9b5af;
  position: relative; transition: background 0.15s; flex: none;
}
.trilho::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.chave input:checked + .trilho { background: var(--verde); }
.chave input:checked + .trilho::after { transform: translateX(20px); }
.chave input:focus-visible + .trilho { outline: 3px solid var(--verde); outline-offset: 2px; }

/* abas */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--linha); margin: 28px 0 24px; overflow-x: auto; overflow-y: hidden; }
.abas button {
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 14px; cursor: pointer;
  color: var(--tinta-suave); font-weight: 600; white-space: nowrap;
}
.abas button[aria-selected="true"] { color: var(--tinta); border-bottom-color: var(--verde); }

/* ---- WhatsApp ---- */
.conexao { display: grid; grid-template-columns: 300px 1fr; gap: 40px; align-items: start; }
.qr-area {
  aspect-ratio: 1; background: var(--superficie);
  border: 1px solid var(--linha); border-radius: 16px;
  display: grid; place-items: center; padding: 16px;
}
.qr-area img { width: 100%; height: 100%; object-fit: contain; }
.qr-area.conectado { background: var(--verde-claro); border-color: var(--verde); }
.qr-vazio { color: var(--tinta-suave); text-align: center; }
.conexao-texto h3 { margin-bottom: 8px; }
.conexao-texto > p { color: var(--tinta-suave); }
.passos { padding-left: 20px; margin: 16px 0 0; max-width: 52ch; }
.passos li { margin-bottom: 6px; }
.acoes { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.rodape-aba { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--linha); }

/* ---- prompt e teste ---- */
.treino { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.editor .apoio { margin-bottom: 12px; }
.editor textarea { min-height: 520px; resize: vertical; line-height: 1.55; }
.estado-salvo { color: var(--tinta-suave); }

.telefone {
  position: sticky; top: 24px;
  background: var(--papel-conversa);
  border: 1px solid var(--linha); border-radius: 22px;
  overflow: hidden; display: flex; flex-direction: column; height: 620px;
}
.telefone-topo {
  background: var(--verde-escuro); color: #fff;
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
}
.bolhas { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.dica { color: var(--tinta-suave); text-align: center; margin: auto 12px; font-size: 0.95rem; }
.bolha {
  max-width: 84%; padding: 8px 12px; border-radius: 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.95rem;
}
.bolha.cliente { align-self: flex-end; background: #cfeedd; border-bottom-right-radius: 3px; }
.bolha.ia { align-self: flex-start; background: #fff; border-bottom-left-radius: 3px; }
.bolha.aviso { align-self: center; background: var(--alerta-claro); color: #7a3409; max-width: 100%; }
.bolha.pensando { color: var(--tinta-suave); font-style: italic; }
.telefone-entrada { display: flex; gap: 8px; padding: 10px; background: var(--superficie); border-top: 1px solid var(--linha); }
.telefone-entrada input { border-radius: 20px; }
.telefone-entrada .botao { border-radius: 20px; }

/* ---- conversas ---- */
.lista-conversas { list-style: none; margin: 20px 0 0; padding: 0; max-width: 760px; }
.lista-conversas li {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--linha);
}
.lista-conversas .numero { font-weight: 600; }
.lista-conversas .trecho {
  grid-column: 1; color: var(--tinta-suave);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lista-conversas .lado { grid-row: 1 / span 2; grid-column: 2; text-align: right; }
.selo { background: var(--alerta-claro); color: #7a3409; border-radius: 6px; padding: 2px 8px; font-size: 0.875rem; font-weight: 600; }
.vazio-lista { color: var(--tinta-suave); margin-top: 20px; }

[hidden] { display: none !important; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .lateral { padding: 16px; gap: 16px; position: static; height: auto; }
  .rodape-lateral { margin-top: 0; flex-direction: row; gap: 20px; }
  .conteudo { padding: 24px 16px; }
  h2 { font-size: 1.6rem; }
  .conexao { grid-template-columns: 1fr; gap: 24px; }
  .qr-area { max-width: 300px; }
  .treino { grid-template-columns: 1fr; }
  .editor textarea { min-height: 320px; }
  .telefone { position: static; height: 520px; }
}

@media (prefers-reduced-motion: reduce) {
  .trilho, .trilho::after { transition: none; }
}

/* ---- gastos ---- */
.mes { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mes strong { min-width: 9.5em; text-align: center; font-family: var(--titulo); font-size: 1.15rem; }
.total { margin: 28px 0 36px; }
.total-valor { font-family: var(--titulo); font-size: 3.25rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.total .apoio { margin-top: 8px; }
#gastos h3 { margin: 0 0 12px; }
.tabela { width: 100%; max-width: 900px; border-collapse: collapse; margin-bottom: 36px; background: var(--superficie); border: 1px solid var(--linha); }
.tabela.estreita { max-width: 520px; }
.tabela th, .tabela td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--linha); }
.tabela th { font-weight: 600; color: var(--tinta-suave); font-size: 0.9rem; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabela .soma td { font-weight: 600; background: var(--fundo); }
.nota { margin-top: 4px; }

@media (max-width: 960px) {
  .total-valor { font-size: 2.4rem; }
  .tabela { display: block; overflow-x: auto; }
}
