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

/* ── App preenche a tela inteira (sem frame de celular) ── */
html, body {
  height: 100%;
  background: #ffffff;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

/* O "frame" agora é a tela inteira */
.phone-frame {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: #f2f4f8;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ── Cabeçalho ── */
.app-header {
  padding: 14px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-bottom: 1px solid #e8ecf0;
  flex-shrink: 0;
}

.app-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

.month-selector {
  background: #f1f5f9;
  border: none;
  border-radius: 20px;
  padding: 8px 30px 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23475569" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ── Área de scroll ── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* scrollbar fina mas dentro dos limites */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.scroll-area::-webkit-scrollbar { width: 4px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ── Card financeiro principal (escuro) ── */
.finance-summary-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: 16px;
  padding: 20px;
  color: white;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
  position: relative;
  overflow: hidden;
}

/* Botão de engrenagem — separado do clique do card */
.btn-settings {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 14px;
  line-height: 1;
  z-index: 2;
  transition: background 0.15s;
  /* Garante que não expande além do tamanho definido */
  flex-shrink: 0;
  padding: 0;
}
.btn-settings:active { background: rgba(255,255,255,0.25); }

/* Linha 1: título + valor grande */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  /* espaço para o botão de engrenagem não sobrepor o valor */
  padding-right: 44px;
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: #94a3b8;
  margin-bottom: 4px;
}

.card-value {
  font-size: 26px;
  font-weight: 700;
  color: white;
  text-align: right;
}

.divider-light {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin-bottom: 14px;
}

/* Linha 2: salário restante + gastos totais — cada um ocupa metade */
.row-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 14px;
}

.mini-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Segundo bloco alinha à direita */
.mini-block:last-child {
  text-align: right;
  align-items: flex-end;
}

.mini-label {
  font-size: 12px;
  color: #94a3b8;
}

.mini-number {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

/* Linha 3: VA */
.va-section {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.va-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.va-item:last-child {
  text-align: right;
  align-items: flex-end;
}

/* ── Cards brancos (cartões, outros gastos) ── */
.cards-list-card {
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid #e8ecf0;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.1s;
}
.card-item:last-child { border-bottom: none; }
.card-item:active { background: #f8fafc; }

.card-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.card-name {
  font-weight: 600;
  color: #1e293b;
  font-size: 15px;
}

.card-balance {
  font-weight: 700;
  color: #0f172a;
  font-size: 15px;
}

.total-outros {
  text-align: right;
  font-weight: 700;
  color: #0f172a;
  margin-top: 10px;
  font-size: 17px;
}

.clickable:active { opacity: 0.92; }

/* ── Páginas secundárias ── */
.secondary-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 20;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.secondary-page.active {
  transform: translateX(0);
}

.page-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 700;
  font-size: 18px;
  color: #0f172a;
  background: white;
  flex-shrink: 0;
}

.back-btn {
  background: #f1f5f9;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #1e293b;
  padding: 0;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Formulários ── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-weight: 600;
  font-size: 14px;
  color: #334155;
}

.input-group input {
  padding: 13px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  background: #f8fafc;
  color: #0f172a;
}

.input-group input:focus {
  border-color: #6366f1;
  background: #fff;
}

.save-btn {
  background: #0f172a;
  color: white;
  border: none;
  padding: 15px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 16px;
  margin-top: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.save-btn:active { opacity: 0.85; }
.save-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Itens de compra/gasto ── */
.purchase-item {
  background: #f8fafc;
  border-radius: 10px;
  padding: 13px;
  display: flex;
  align-items: center;
  border: 1px solid #f1f5f9;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1e293b;
  color: white;
  padding: 11px 22px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-erro { background: #ef4444; }

/* ── Diálogo de confirmação ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 32px;
}
.confirm-overlay.active { display: flex; }

.confirm-box {
  background: white;
  border-radius: 16px;
  padding: 22px 20px 18px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.18);
}

.confirm-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Loading bar ── */
#loadingBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  z-index: 9999;
  opacity: 0;
  transition: opacity .2s;
}

/* Input decimal abre teclado numérico correto no iOS */
input[inputmode="decimal"],
input[inputmode="numeric"] {
  -webkit-appearance: none;
}
