/* ============================================
   Finanças de Casa — design tokens
   ============================================ */
:root{
  --bg: #0E0D11;
  --bg-elevated: #17161B;
  --surface: #1D1C22;
  --surface-hover: #26242C;
  --border: #2C2A33;
  --text: #F3EFE9;
  --text-muted: #948F8A;
  --text-faint: #5E5A56;

  --coral: #E8623F;
  --coral-dim: #E8623F26;
  --gold: #D9A55C;
  --gold-dim: #D9A55C26;
  --green: #7BA88A;
  --green-dim: #7BA88A26;
  --red: #D9634F;
  --red-dim: #D9634F26;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; }

::selection{ background: var(--coral-dim); color: var(--text); }

/* ============================================
   Login
   ============================================ */
.login-body{
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% -10%, #E8623F22, transparent 45%),
    radial-gradient(circle at 100% 100%, #D9A55C1a, transparent 50%),
    var(--bg);
}

.login-card{
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 40px 32px;
}

.login-eyebrow{
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--coral);
  font-weight: 600;
  margin-bottom: 14px;
}

.login-title{
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  margin: 0 0 8px;
}

.login-sub{
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
  line-height: 1.5;
}

.login-form label{
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.login-form input{
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 13px 14px;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 16px;
}
.login-form input:focus{
  outline: none;
  border-color: var(--coral);
}

.login-form button{
  width: 100%;
  background: var(--coral);
  color: #17110D;
  border: none;
  border-radius: var(--radius-s);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}
.login-form button:hover{ filter: brightness(1.08); }

.login-erro{
  color: var(--red);
  font-size: 13px;
  margin: -6px 0 16px;
}

/* ============================================
   App shell
   ============================================ */
.app{
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 100px;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  padding: 20px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand{
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.topbar-brand span{ color: var(--coral); }

.topbar-actions{ display:flex; gap:10px; align-items:center; }
.icon-btn{
  width: 38px; height: 38px;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor:pointer;
}
.icon-btn:hover{ color: var(--text); border-color: var(--coral); }

/* bottom nav (mobile-first, also fine on desktop) */
.tabbar{
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
}
.tabbar a{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: var(--radius-s);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
}
.tabbar a.active{ color: var(--coral); background: var(--coral-dim); }
.tabbar svg{ width: 20px; height: 20px; }

/* ============================================
   Sections & cards
   ============================================ */
.section-label{
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 28px 0 12px;
  text-transform: uppercase;
}

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 20px;
}

.grid{ display: grid; gap: 14px; }
.grid-2{ grid-template-columns: repeat(2, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px){
  .grid-3{ grid-template-columns: 1fr; }
}

/* ============================================
   Hero saldo gauge (signature element)
   ============================================ */
.hero{
  background: radial-gradient(circle at 15% 0%, #E8623F1f, transparent 55%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 28px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.hero-gauge{ position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.hero-gauge svg{ width: 100%; height: 100%; transform: rotate(-90deg); }
.hero-gauge-track{ fill: none; stroke: var(--border); stroke-width: 10; }
.hero-gauge-fill{ fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.hero-gauge-label{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.hero-gauge-label .pct{ font-family: var(--font-display); font-size: 22px; }
.hero-gauge-label .txt{ font-size: 9px; color: var(--text-muted); letter-spacing: 0.08em; }

.hero-info .eyebrow{ font-size: 11px; letter-spacing: 0.1em; color: var(--gold); font-weight: 600; margin-bottom: 6px; }
.hero-info .saldo{ font-family: var(--font-display); font-size: 40px; font-weight: 500; line-height: 1; margin-bottom: 8px; }
.hero-info .saldo.positivo{ color: var(--green); }
.hero-info .saldo.negativo{ color: var(--red); }
.hero-info .detalhe{ font-size: 13px; color: var(--text-muted); }
.hero-info .detalhe b{ color: var(--text); font-weight: 600; }

@media (max-width: 480px){
  .hero{ flex-direction: column; text-align: center; }
}

/* ============================================
   Stat tiles
   ============================================ */
.stat-tile{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px 18px;
}
.stat-tile .label{ font-size: 11px; color: var(--text-muted); letter-spacing: .04em; margin-bottom: 8px; }
.stat-tile .value{ font-family: var(--font-display); font-size: 24px; }
.stat-tile .value.despesa{ color: var(--red); }
.stat-tile .value.receita{ color: var(--green); }

/* ============================================
   Cartões (credit cards)
   ============================================ */
.cartao-card{
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s;
}
.cartao-card:hover{ border-color: var(--gold); }
.cartao-card .nome{ font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.cartao-card .saldo{ font-family: var(--font-display); font-size: 26px; color: var(--gold); }

/* ============================================
   Lists / rows
   ============================================ */
.lancamento-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}
.lancamento-row:last-child{ border-bottom: none; }
.lancamento-row .esquerda{ display: flex; align-items: center; gap: 12px; }
.lancamento-row .dot{ width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lancamento-row .dot.despesa{ background: var(--red); }
.lancamento-row .dot.receita{ background: var(--green); }
.lancamento-row .categoria{ font-size: 14px; font-weight: 500; }
.lancamento-row .data{ font-size: 12px; color: var(--text-faint); }
.lancamento-row .valor{ font-family: var(--font-display); font-size: 16px; }
.lancamento-row .valor.despesa{ color: var(--red); }
.lancamento-row .valor.receita{ color: var(--green); }
.lancamento-row .del{ color: var(--text-faint); cursor: pointer; padding: 4px 8px; font-size: 16px; }
.lancamento-row .del:hover{ color: var(--red); }

/* ============================================
   Forms
   ============================================ */
.form-field{ margin-bottom: 16px; }
.form-field label{ display:block; font-size: 12px; color: var(--text-muted); margin-bottom: 7px; }
.form-field input, .form-field select, .form-field textarea{
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 13px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus{
  outline: none; border-color: var(--coral);
}
.row-2{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toggle-tipo{ display: flex; gap: 8px; margin-bottom: 18px; }
.toggle-tipo button{
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.toggle-tipo button.active[data-tipo="despesa"]{ background: var(--red-dim); border-color: var(--red); color: var(--red); }
.toggle-tipo button.active[data-tipo="receita"]{ background: var(--green-dim); border-color: var(--green); color: var(--green); }

.btn-primary{
  width: 100%;
  background: var(--coral);
  color: #17110D;
  border: none;
  border-radius: var(--radius-s);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover{ filter: brightness(1.08); }

.btn-secondary{
  width: 100%;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 13px;
  font-size: 14px;
  cursor: pointer;
}
.btn-secondary:hover{ color: var(--text); border-color: var(--text-muted); }

.fab{
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--coral);
  color: #17110D;
  border: none;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px #E8623F4d;
  cursor: pointer;
  z-index: 15;
}

/* ============================================
   Modal / sheet
   ============================================ */
.overlay{
  position: fixed; inset: 0;
  background: #08070ac0;
  z-index: 30;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.overlay.open{ display: flex; }
.sheet{
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 640px){
  .overlay{ align-items: center; }
  .sheet{ border-radius: var(--radius-l); }
}
.sheet-title{ font-family: var(--font-display); font-size: 22px; margin: 0 0 20px; }
.sheet-close{ float: right; color: var(--text-muted); cursor: pointer; font-size: 20px; }

.chip-add{
  display: inline-block;
  font-size: 12px;
  color: var(--gold);
  cursor: pointer;
  margin-top: 6px;
}

/* ============================================
   Charts container
   ============================================ */
.chart-wrap{ position: relative; height: 240px; }

.empty-state{
  text-align: center;
  color: var(--text-faint);
  padding: 32px 16px;
  font-size: 13px;
}

h1, h2, h3{ font-family: var(--font-display); font-weight: 500; }
