@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500;600&display=swap');

:root {
  --c-bg:          #f4f6fb;
  --c-surface:     #ffffff;
  --c-surface-sub: #f0f2f8;
  --c-border:      #dde1ed;
  --c-border-faint:#edf0f7;
  --c-accent:      #4f6ef7;
  --c-accent-h:    #3d5ae6;
  --c-accent-m:    #eef0fe;
  --c-pos:         #10b981;
  --c-pos-m:       #ecfdf5;
  --c-neg:         #f43f5e;
  --c-neg-m:       #fff1f3;
  --c-warn:        #f59e0b;
  --c-warn-m:      #fffbeb;
  --c-text:        #111827;
  --c-text-2:      #374151;
  --c-text-3:      #6b7280;
  --c-text-4:      #9ca3af;
  --c-nav-bg:      #0f1117;
  --nav-h:         64px;
  --header-h:      56px;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;
  --r-full: 9999px;
  --sh-sm: 0 1px 3px rgba(17,24,39,.07),0 1px 2px rgba(17,24,39,.04);
  --sh-md: 0 4px 8px rgba(17,24,39,.07),0 2px 4px rgba(17,24,39,.04);
  --f-body: 'DM Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  --f-mono: 'DM Mono','SF Mono',Consolas,monospace;
  --t-base: .18s ease;
}

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

html { -webkit-text-size-adjust: 100%; font-size: 16px; }

body {
  font-family: var(--f-body);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
.app-header {
  position: sticky; top: 0; z-index: 120;
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-faint);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--sh-sm);
}
.app-header .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1rem; color: var(--c-text);
  text-decoration: none;
}
.app-header .logo svg { color: var(--c-accent); }
.app-header .header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  border: none; background: transparent; cursor: pointer;
  color: var(--c-text-3); display: flex; align-items: center; justify-content: center;
  transition: background var(--t-base), color var(--t-base);
}
.header-btn:hover { background: var(--c-surface-sub); color: var(--c-text); }

/* ── BOTTOM NAV ── */
.app-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--c-nav-bg);
  display: flex; align-items: center;
  border-top: 1px solid rgba(255,255,255,.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px; cursor: pointer; text-decoration: none;
  color: rgba(255,255,255,.4);
  transition: color var(--t-base);
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-item span { font-size: 10px; font-weight: 500; letter-spacing: .02em; }
.nav-item.active { color: var(--c-accent); }
.nav-item.active svg { stroke-width: 2.2; }

/* FAB (botão ação rápida) */
.nav-fab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-fab .fab-circle {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--c-accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(79,110,247,.5);
  margin-top: -18px;
  transition: background var(--t-base), transform var(--t-base);
}
.nav-fab .fab-circle svg { color: #fff; width: 22px; height: 22px; stroke-width: 2.2; }
.nav-fab:active .fab-circle { transform: scale(.92); }
.nav-fab span { font-size: 10px; font-weight: 500; color: rgba(255,255,255,.4); letter-spacing: .02em; }

/* ── PAGE ── */
.page { padding: 16px 16px 8px; }
.page-title {
  font-size: 1.125rem; font-weight: 700; color: var(--c-text);
  margin-bottom: 16px;
}
.page-subtitle {
  font-size: .75rem; font-weight: 500; color: var(--c-text-3);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 8px; margin-top: 20px;
}

/* ── CARDS ── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-faint);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
.card + .card { margin-top: 12px; }
.card-body { padding: 16px; }
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border-faint);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--c-surface-sub);
}
.card-header-title {
  font-size: .8125rem; font-weight: 600; color: var(--c-text-3);
  text-transform: uppercase; letter-spacing: .05em;
}

/* ── SALDO HERO ── */
.saldo-hero {
  background: linear-gradient(135deg, #1c2240 0%, #0f1117 100%);
  border-radius: var(--r-xl);
  padding: 24px 20px 20px;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(15,17,23,.25);
}
.saldo-hero .label {
  font-size: .75rem; font-weight: 500; color: rgba(255,255,255,.5);
  letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px;
}
.saldo-hero .valor {
  font-family: var(--f-mono); font-size: 2rem; font-weight: 700;
  letter-spacing: -.02em; color: #fff;
}
.saldo-hero .data {
  font-size: .75rem; color: rgba(255,255,255,.4); margin-top: 12px;
}

/* ── STAT GRID ── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-faint);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: 14px;
}
.stat-card .stat-label {
  font-size: .6875rem; font-weight: 600; color: var(--c-text-3);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.stat-card .stat-val {
  font-family: var(--f-mono); font-size: 1.125rem; font-weight: 700;
}
.stat-card .stat-icon {
  width: 32px; height: 32px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.stat-card .stat-icon svg { width: 16px; height: 16px; }
.stat-card.pos .stat-icon { background: var(--c-pos-m); color: var(--c-pos); }
.stat-card.neg .stat-icon { background: var(--c-neg-m); color: var(--c-neg); }
.stat-card.accent .stat-icon { background: var(--c-accent-m); color: var(--c-accent); }
.stat-card.warn .stat-icon { background: var(--c-warn-m); color: var(--c-warn); }
.stat-card.pos .stat-val { color: var(--c-pos); }
.stat-card.neg .stat-val { color: var(--c-neg); }
.stat-card.accent .stat-val { color: var(--c-accent); }
.stat-card.warn .stat-val { color: var(--c-warn); }

/* ── LISTA ITEMS ── */
.item-list { display: flex; flex-direction: column; }
.item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--c-border-faint);
  text-decoration: none; color: inherit;
  transition: background var(--t-base);
  -webkit-tap-highlight-color: transparent;
}
.item-row:last-child { border-bottom: none; }
.item-row:active { background: var(--c-surface-sub); }
.item-icon {
  width: 38px; height: 38px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.item-icon svg { width: 18px; height: 18px; }
.item-icon.pos { background: var(--c-pos-m); color: var(--c-pos); }
.item-icon.neg { background: var(--c-neg-m); color: var(--c-neg); }
.item-icon.accent { background: var(--c-accent-m); color: var(--c-accent); }
.item-icon.warn { background: var(--c-warn-m); color: var(--c-warn); }
.item-icon.neutral { background: var(--c-surface-sub); color: var(--c-text-3); }
.item-body { flex: 1; min-width: 0; }
.item-title {
  font-size: .875rem; font-weight: 500; color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-sub { font-size: .75rem; color: var(--c-text-3); margin-top: 2px; }
.item-val {
  font-family: var(--f-mono); font-size: .875rem; font-weight: 600;
  flex-shrink: 0; text-align: right;
}
.item-val.pos { color: var(--c-pos); }
.item-val.neg { color: var(--c-neg); }
.item-val.neutral { color: var(--c-text-3); }

/* ── BADGE ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-full);
  font-size: .6875rem; font-weight: 600; letter-spacing: .02em;
}
.badge-pos  { background: var(--c-pos-m);  color: #065f46; }
.badge-neg  { background: var(--c-neg-m);  color: #9f1239; }
.badge-warn { background: var(--c-warn-m); color: #78350f; }
.badge-info { background: #eff6ff; color: #1d4ed8; }
.badge-neutral { background: var(--c-surface-sub); color: var(--c-text-3); border: 1px solid var(--c-border); }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: .8125rem; font-weight: 500;
  color: var(--c-text-2); margin-bottom: 6px;
}
.form-control {
  width: 100%; height: 44px;
  padding: 0 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: var(--f-body); font-size: .9375rem; color: var(--c-text);
  outline: none; transition: border-color var(--t-base), box-shadow var(--t-base);
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}
.form-control.currency {
  font-family: var(--f-mono); font-size: 1.125rem;
  font-weight: 600; text-align: right;
}
select.form-control { padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea.form-control { height: auto; padding: 10px 12px; resize: none; }

/* Segmented tipo */
.tipo-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--c-border); margin-bottom: 16px; }
.tipo-toggle input { position: absolute; opacity: 0; width: 0; }
.tipo-toggle label {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; font-size: .875rem; font-weight: 500; cursor: pointer;
  background: var(--c-surface); color: var(--c-text-3);
  transition: background var(--t-base), color var(--t-base);
}
.tipo-toggle input:checked + label.receita { background: var(--c-pos-m); color: var(--c-pos); }
.tipo-toggle input:checked + label.despesa { background: var(--c-neg-m); color: var(--c-neg); }
.tipo-toggle label svg { width: 16px; height: 16px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: var(--r-md);
  font-family: var(--f-body); font-size: .9375rem; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none;
  transition: background var(--t-base), transform var(--t-base), box-shadow var(--t-base);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--c-accent); color: #fff; box-shadow: 0 4px 12px rgba(79,110,247,.35); }
.btn-primary:active { background: var(--c-accent-h); }
.btn-success { background: var(--c-pos); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,.35); }
.btn-danger  { background: var(--c-neg); color: #fff; }
.btn-ghost   { background: transparent; color: var(--c-text-3); }
.btn-outline { background: transparent; border: 1px solid var(--c-border); color: var(--c-text-2); }
.btn-full { width: 100%; }
.btn-sm { height: 36px; padding: 0 14px; font-size: .8125rem; }

/* ── SHEET / MODAL ── */
.sheet-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
}
.sheet-overlay.open { display: flex; align-items: flex-end; }
.sheet {
  width: 100%; background: var(--c-surface);
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  max-height: 92dvh; overflow-y: auto;
  animation: slideUp .25s ease;
}
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--c-border); margin: 12px auto 0;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--c-border-faint);
}
.sheet-title { font-size: 1rem; font-weight: 700; }
.sheet-body { padding: 16px 20px; }
.sheet-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--c-border-faint);
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}

/* ── ALERTS ── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-lg);
  font-size: .875rem; margin-bottom: 14px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--c-pos-m); color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: var(--c-neg-m); color: #9f1239; border: 1px solid #fda4af; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 24px; text-align: center;
}
.empty-state svg { width: 40px; height: 40px; color: var(--c-text-4); margin-bottom: 12px; }
.empty-state p { font-size: .875rem; color: var(--c-text-3); }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--c-border-faint); margin: 4px 0; }

/* ── PILL TABS ── */
.pill-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 16px; scrollbar-width: none; }
.pill-tabs::-webkit-scrollbar { display: none; }
.pill-tab {
  flex-shrink: 0; padding: 6px 14px; border-radius: var(--r-full);
  font-size: .8125rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-text-3); text-decoration: none;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
  -webkit-tap-highlight-color: transparent;
}
.pill-tab.active {
  background: var(--c-accent-m); border-color: var(--c-accent);
  color: var(--c-accent); font-weight: 600;
}

/* ── TOAST ── */
#toast-area { position: fixed; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom,0px)); left: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: var(--r-lg);
  font-size: .875rem; font-weight: 500; color: #fff;
  box-shadow: var(--sh-md); animation: slideUp .2s ease;
}
.toast-success { background: #065f46; }
.toast-error   { background: #9f1239; }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; background: var(--c-bg);
}
.login-card { width: 100%; max-width: 360px; }
.login-logo {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; margin-bottom: 32px; text-align: center;
}
.login-logo .logo-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, #4f6ef7 0%, #3d5ae6 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(79,110,247,.4);
}
.login-logo .logo-icon svg { width: 32px; height: 32px; color: #fff; }
.login-logo h1 { font-size: 1.25rem; font-weight: 700; }
.login-logo p { font-size: .875rem; color: var(--c-text-3); }

/* ── UTILS ── */
.mono { font-family: var(--f-mono); }
.text-pos { color: var(--c-pos); }
.text-neg { color: var(--c-neg); }
.text-warn { color: var(--c-warn); }
.text-muted { color: var(--c-text-3); }
.text-sm { font-size: .8125rem; }
.text-xs { font-size: .75rem; }
.fw-semi { font-weight: 600; }
.fw-bold { font-weight: 700; }
.mb-4 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 12px; }
.gap-top { margin-top: 20px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
