:root {
  --bg: #0B0B0C;
  --surface: #141416;
  --surface-2: #18181B;
  --input: #0F0F11;
  --line: #26262A;
  --line-2: #2F2F33;
  --gold: #E8B84A;
  --gold-dim: #7A5C1E;
  --gold-soft: #2A2212;
  --text: #F5F5F5;
  --text-2: #D4D4D8;
  --muted: #A1A1AA;
  --danger: #F2994A;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }

/* Topo */
.top { position: sticky; top: 0; z-index: 10; background: rgba(11, 11, 12, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid #1F1F22; padding: calc(12px + var(--safe-t)) 20px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .logo { height: 38px; width: auto; display: block; }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--gold); display: flex; align-items: center; justify-content: center; }

/* Conteúdo */
main { padding: 20px 20px calc(112px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; flex-direction: column; gap: 6px; }
.kicker { font-size: 12px; letter-spacing: 1.6px; font-weight: 600; color: var(--gold); text-transform: uppercase; }
h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
.sub { margin: 0; font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.gold { color: var(--gold); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card.hero { border-color: var(--gold); gap: 6px; padding: 20px; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.label { font-size: 12px; letter-spacing: 1.4px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.big { font-size: 34px; font-weight: 800; letter-spacing: -0.8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tile .t { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid3 .tile { padding: 12px; }
.grid3 .tile .v { font-size: 13px; white-space: normal; overflow: visible; overflow-wrap: anywhere; }

/* Gráfico de barras */
.chart { position: relative; height: 150px; display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--line-2); }
.chart .gl { position: absolute; left: 0; right: 0; border-top: 1px dashed #232327; }
.chart .col { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; position: relative; }
.chart .bar { width: 13px; background: var(--gold); border-radius: 4px 4px 0 0; transition: height 0.4s ease; }
.chart .bar.d { background: var(--gold-dim); }
.chart.cat .col { flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.chart.cat .bar { width: 28px; }
.chart .val { font-size: 10px; color: var(--text-2); font-weight: 600; }
.xlabels { display: flex; gap: 4px; margin-top: -4px; }
.xlabels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xlabels span.on { color: var(--gold); font-weight: 700; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--gold); margin-right: 6px; vertical-align: -1px; }
.legend i.d { background: var(--gold-dim); }

.progress { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; border-radius: 5px; background: var(--gold); }
.progress.sm { height: 8px; }

/* Listas */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #1F1F22; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.item:last-child { border-bottom: 0; }
.ini { width: 40px; height: 40px; flex: none; border-radius: 12px; background: #1E1E21; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--gold); }
.ini.ring { background: transparent; border: 1px solid #3A3A3F; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.grow b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-size: 14px; font-weight: 700; white-space: nowrap; }
.amt.in { color: var(--gold); }
.amt.tr { color: var(--muted); }
.dateh { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.6px; padding: 12px 14px 6px; text-transform: uppercase; background: var(--surface-2); }

.due { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.due .day { width: 46px; height: 46px; flex: none; border-radius: 12px; border: 1px solid var(--gold); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.due .day b { font-size: 16px; font-weight: 800; color: var(--gold); }
.due .day small { font-size: 9px; color: var(--muted); letter-spacing: 1px; margin-top: 3px; }
.due .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.late { color: var(--danger) !important; }

/* Botões */
.btn { height: 50px; border-radius: 12px; border: none; background: var(--gold); color: var(--bg); font-size: 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; }
.btn.outline { background: transparent; border: 1px solid var(--gold); color: var(--gold); }
.btn.ghost { background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text-2); font-weight: 600; }
.btn.danger { background: transparent; border: 1px solid #5A3A20; color: var(--danger); font-weight: 700; }
.btn.block { width: 100%; }
.btn.lg { height: 54px; font-size: 15px; letter-spacing: 0.5px; }
.pill { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--gold); background: transparent; color: var(--gold); font-size: 12px; font-weight: 700; }
.link { background: none; border: none; color: var(--gold); font-size: 13px; font-weight: 600; min-height: 44px; padding: 0; }
.trash { width: 36px; height: 36px; flex: none; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 36px; padding: 0 13px; border-radius: 18px; background: var(--surface); color: #E4E4E7; border: 1px solid var(--line-2); font-size: 13px; font-weight: 500; }
.chip.on { background: var(--gold); color: var(--bg); border-color: var(--gold); font-weight: 700; }
.chip.add { border-style: dashed; border-color: var(--gold); color: var(--gold); background: transparent; font-weight: 700; }
.seg { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { height: 40px; border-radius: 10px; border: none; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--gold); color: var(--bg); font-weight: 800; }

/* Formulários */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.input { height: 48px; width: 100%; background: var(--input); border: 1px solid var(--line-2); border-radius: 12px; color: var(--text); padding: 0 14px; font-size: 15px; }
.input:focus { border-color: var(--gold); outline: none; }
input[type=date].input { color-scheme: dark; }
.money { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--gold); padding-bottom: 6px; }
.money span { font-size: 22px; font-weight: 700; color: var(--gold); }
.money input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--text); font-size: 32px; font-weight: 800; }
.hint { font-size: 12px; color: var(--gold); font-weight: 600; }
.hint.n { color: var(--text-2); font-weight: 500; }
.formbox { background: var(--surface); border: 1px solid var(--gold); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* Cartão de crédito */
.ccard { background: #121214; border: 1px solid #3A3A3F; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }

/* Navegação inferior */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; z-index: 15; background: rgba(14, 14, 16, 0.97); border-top: 1px solid #1F1F22; display: flex; align-items: center; justify-content: space-around; padding: 6px 8px calc(10px + var(--safe-b)); }
.nav button { background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; min-height: 52px; justify-content: center; font-size: 11px; font-weight: 600; }
.nav button.on { color: var(--gold); }
.nav .fab { width: 58px; height: 58px; min-width: 58px; border-radius: 18px; background: var(--gold); color: var(--bg); margin-top: -26px; box-shadow: 0 6px 18px rgba(232, 184, 74, 0.25); }

/* Folha (bottom sheet) */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.72); display: flex; flex-direction: column; justify-content: flex-end; animation: fade 0.18s ease; }
.sheet { width: 100%; max-width: 520px; margin: 0 auto; background: #111113; border-top: 1px solid var(--gold); border-radius: 24px 24px 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 10px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; animation: up 0.22s ease; }
.sheet > * { flex-shrink: 0; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: #3A3A3F; align-self: center; flex: none; }
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-b)); width: calc(100% - 40px); max-width: 480px; z-index: 40; background: var(--surface-2); border: 1px solid var(--gold); border-radius: 12px; padding: 12px 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 10px; animation: up 0.2s ease; }

/* Boas-vindas e apoio */
.boas-topo { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 4px; }
.feat { display: flex; align-items: center; gap: 12px; }
.ini.gold { color: var(--gold); }
.apoio-card { border-color: #5C4818; background: #17140D; }
.qr-box { align-self: center; width: 232px; height: 232px; padding: 10px; background: #fff; border-radius: 18px; border: 3px solid var(--gold); display: flex; align-items: center; justify-content: center; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.chave { display: flex; align-items: center; gap: 10px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-align: left; font-size: 13px; }
.chave b { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.passos { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.passos b { color: var(--text); font-size: 14px; margin-bottom: 2px; }

.empty { padding: 26px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.welcome { border: 1px dashed var(--gold); background: transparent; }

/* Relatório para impressão / PDF */
.print-only { display: none; }
@media print {
  @page { margin: 16mm; }
  body { background: #fff; color: #111; }
  .app, .toast, .overlay { display: none !important; }
  .print-only { display: block; font-family: Inter, Arial, sans-serif; color: #111; }
  .print-only header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #8C6418; padding-bottom: 10px; margin-bottom: 16px; }
  .print-only header img { height: 44px; }
  .print-only h2 { font-size: 15px; margin: 18px 0 8px; color: #111; }
  .print-only table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
  .print-only th { text-align: left; background: #F3EEDF; color: #5A410F; padding: 6px 8px; border-bottom: 1px solid #D9CBA3; }
  .print-only td { padding: 6px 8px; border-bottom: 1px solid #EEE; }
  .print-only td.n, .print-only th.n { text-align: right; white-space: nowrap; }
  .print-only .tot { display: flex; gap: 12px; }
  .print-only .tot div { flex: 1; border: 1px solid #E2D6B5; border-radius: 8px; padding: 10px; }
  .print-only .tot small { display: block; color: #666; font-size: 11px; }
  .print-only .tot b { font-size: 16px; }
  .print-only .bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; border-bottom: 1px solid #ccc; padding-top: 6px; }
  .print-only .bars div { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; }
  .print-only .bars i { width: 10px; display: block; background: #C9962E; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only .bars i.d { background: #5A410F; }
  .print-only .bl { display: flex; gap: 6px; font-size: 10px; color: #666; }
  .print-only .bl span { flex: 1; text-align: center; }
  .print-only footer { margin-top: 20px; font-size: 10px; color: #888; }
}
