/* Cores vindas do tema do Telegram (o script do Telegram define as variáveis --tg-theme-*).
   O segundo valor é usado só se a variável não existir. */
:root {
  --fundo: var(--tg-theme-bg-color, #ffffff);
  --fundo-secundario: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --texto: var(--tg-theme-text-color, #111111);
  --dica: var(--tg-theme-hint-color, #8a8a8e);
  --botao: var(--tg-theme-button-color, #2481cc);
  --botao-texto: var(--tg-theme-button-text-color, #ffffff);
  --perigo: var(--tg-theme-destructive-text-color, #e53935);
  --secao: var(--tg-theme-section-bg-color, var(--fundo));
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 16px 16px 32px;
  background: var(--fundo-secundario);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

main { max-width: 560px; margin: 0 auto; }

h1 { font-size: 20px; margin: 0 0 12px; }

.dica { color: var(--dica); font-size: 14px; }

.cartao {
  background: var(--secao);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

/* Navegação entre meses */
.navegacao-mes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.navegacao-mes h1 { margin: 0; text-transform: capitalize; text-align: center; }
.seta {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--secao);
  color: var(--botao);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

/* Total e gráfico */
.total { display: flex; flex-direction: column; gap: 4px; }
.total strong { font-size: 28px; }
.grafico-area { position: relative; height: 240px; margin-top: 12px; }

/* Botões */
.botao, .botao-perigo {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}
.botao { background: var(--botao); color: var(--botao-texto); }
.botao-perigo { background: var(--secao); color: var(--perigo); }

/* Lista de gastos */
.lista {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--secao);
  border-radius: 12px;
  overflow: hidden;
}
.lista:empty { display: none; }
.lista li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--fundo-secundario);
  cursor: pointer;
}
.lista li:last-child { border-bottom: none; }
.lista li:active { opacity: 0.6; }
.item-info { display: flex; flex-direction: column; min-width: 0; }
.item-descricao { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-valor { font-weight: 600; white-space: nowrap; }
.bolinha {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.vazio { text-align: center; padding: 24px 0; }

/* Formulário */
form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--dica);
  margin-bottom: 14px;
}
form label:last-child { margin-bottom: 0; }
form input, form select {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* 16px evita o zoom automático no iPhone */
  color: var(--texto);
  background: var(--fundo-secundario);
  border: 1px solid transparent;
  border-radius: 8px;
  appearance: none;
  -webkit-appearance: none;
}
form input:focus, form select:focus { outline: none; border-color: var(--botao); }

/* Aviso fora do Telegram */
.aviso { max-width: 420px; margin: 20vh auto 0; text-align: center; }
