:root {
  --bg: #08101f;
  --bg-elevated: #111c31;
  --bg-card: #121e34;
  --border: rgba(148, 163, 184, 0.14);
  --text: #f3f7ff;
  --text-muted: #8fa0bd;
  --accent: #67e8f9;
  --accent-strong: #22d3ee;
  --accent-soft: rgba(103, 232, 249, 0.12);
  --violet: #9b8cff;
  --income: #34d399;
  --expense: #fb7185;
  --warning: #fbbf24;
  --glass-surface: rgba(18, 30, 52, 0.72);
  --glass-surface-strong: rgba(17, 28, 49, 0.84);
  --glass-border: rgba(203, 226, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.055);
  --glass-shadow: 0 24px 60px -38px rgba(0, 0, 0, 0.92);
  --glass-blur: blur(18px) saturate(135%);
  --radius: 22px;
  --radius-sm: 14px;
  --header-h: 76px;
  --nav-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-resolved-theme="light"] {
  --bg: #f2f5fa;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255,255,255,.9);
  --border: rgba(71, 85, 105, 0.12);
  --text: #142033;
  --text-muted: #68778f;
  --accent: #0891b2;
  --accent-strong: #0e7490;
  --accent-soft: rgba(8, 145, 178, 0.1);
  --violet: #7c6ee6;
  --income: #15803d;
  --expense: #dc2626;
  --warning: #a16207;
  --glass-surface: rgba(255, 255, 255, 0.68);
  --glass-surface-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.72);
  --glass-highlight: rgba(255, 255, 255, 0.62);
  --glass-shadow: 0 24px 60px -40px rgba(38, 57, 84, 0.42);
}
html[data-resolved-theme="light"] .app-header { background: rgba(243, 246, 251, 0.9); }
html[data-resolved-theme="light"] .btn { color: #fff; }
html[data-resolved-theme="light"] .btn.secondary { color: var(--text); }
html[data-resolved-theme="light"] .bottom-nav { box-shadow: 0 -8px 24px rgba(15, 23, 42, .06); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; }

a { color: inherit; text-decoration: none; }
button { font: inherit; }
input, select, textarea { font: inherit; }
svg { display: block; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Layout */
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 17px; margin: 0; font-weight: 600; }
.app-header .icon-btn { background: none; border: none; color: var(--text); padding: 8px; cursor: pointer; }

.app-main {
  flex: 1;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 24px);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  animation: viewIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  position: relative;
  transition: color 0.2s ease;
}
.bottom-nav a:active { transform: scale(0.94); }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a .nav-icon { line-height: 1; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bottom-nav a.active .nav-icon { transform: translateY(-1px) scale(1.08); }
.bottom-nav a.active::before {
  content: "";
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 2.5px; border-radius: 2px;
  background: var(--accent);
  animation: popIn 0.25s ease both;
}
@media (min-width: 900px) {
  .bottom-nav a.active::before { top: 6px; left: 8px; transform: none; width: 3px; height: 22px; }
}

.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 0.4s ease both;
}
body.is-guest .app-main { max-width: none; width: 100%; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .logo {
  width: 56px; height: 56px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #05202f;
  box-shadow: 0 8px 20px -6px rgba(56, 189, 248, 0.55);
}
.auth-brand h1 { font-size: 20px; margin: 14px 0 0; }
.auth-brand p { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.auth-switch a { color: var(--accent); font-weight: 600; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-error { color: var(--expense); font-size: 12px; margin-top: 4px; }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #05202f;
  width: 100%;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn.secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: linear-gradient(135deg, var(--expense), #ef4444); color: #2c0a0a; }
.btn.ghost { background: transparent; color: var(--accent); width: auto; padding: 8px 10px; }
.btn.ghost:hover { background: rgba(56, 189, 248, 0.1); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.fab {
  position: fixed;
  right: 18px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px);
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #05202f;
  border: none; line-height: 1;
  box-shadow: 0 8px 22px -4px rgba(56, 189, 248, 0.6);
  cursor: pointer; z-index: 15;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.fab:hover { transform: scale(1.06); box-shadow: 0 10px 26px -4px rgba(56, 189, 248, 0.7); }
.fab:active { transform: scale(0.93); }

/* Cards & lists */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  transition: background 0.15s ease;
  border-radius: 8px;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
}
.list-item:hover { background: rgba(255, 255, 255, 0.025); }
.list-item:last-child { border-bottom: none; }
.list-item .meta { min-width: 0; }
.list-item .meta .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta .subtitle { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.list-item .amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.amount.income { color: var(--income); }
.amount.expense { color: var(--expense); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px; border-radius: 999px; font-size: 11px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

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

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 10px;
}
.section-title h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-muted);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.tabs button:hover { color: var(--text); border-color: var(--accent); }
.tabs button:active { transform: scale(0.96); }
.tabs button.active { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #05202f; border-color: var(--accent); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters select, .filters input { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
table th { color: var(--text-muted); font-weight: 500; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
  animation: fadeIn 0.2s ease both;
}
.modal-sheet {
  width: 100%; max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 20px;
  max-height: 88vh; overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: var(--radius); animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-header button {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  display: flex; padding: 4px; border-radius: 8px; transition: color 0.15s ease, background 0.15s ease;
}
.modal-header button:hover { color: var(--text); background: var(--bg-elevated); }

/* Toast */
#toast-root { position: fixed; top: 12px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.toast.error { border-color: var(--expense); color: #fecaca; }
.toast.success { border-color: var(--income); color: #bbf7d0; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(56, 189, 248, 0.35); }
.stat-card .value { font-size: 16px; font-weight: 700; }
.stat-card .label { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

.finance-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  margin-bottom: 12px;
  border: 1px solid rgba(56, 189, 248, .25);
  border-radius: 20px;
  background:
    radial-gradient(circle at 90% -10%, rgba(56,189,248,.35), transparent 45%),
    linear-gradient(145deg, var(--bg-card), var(--bg-elevated));
  box-shadow: 0 18px 40px -28px rgba(14, 165, 233, .75);
  animation: slideUp .45s cubic-bezier(.16,1,.3,1) both;
}
.hero-balance { display: flex; flex-direction: column; gap: 4px; }
.hero-balance > span { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.hero-balance > strong { font-size: clamp(26px, 7vw, 38px); letter-spacing: -.04em; line-height: 1.15; }
.hero-balance > small { color: var(--text-muted); }
.dashboard-stats { grid-template-columns: repeat(4, 1fr); }
.dashboard-stats .stat-card:nth-child(2) { animation-delay: 50ms; }
.dashboard-stats .stat-card:nth-child(3) { animation-delay: 100ms; }
.dashboard-stats .stat-card:nth-child(4) { animation-delay: 150ms; }

.alerts-list { display: grid; gap: 8px; }
.alert-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 13px 14px; transition: transform .15s ease, border-color .15s ease;
}
.alert-card:hover { transform: translateY(-1px); border-color: var(--accent); }
.alert-card.warning { border-left-color: var(--warning); }
.alert-card.danger { border-left-color: var(--expense); }
.alert-card div { display: flex; flex-direction: column; min-width: 0; }
.alert-card strong { font-size: 13px; }
.alert-card span { color: var(--text-muted); font-size: 12px; }
.alert-card b { font-size: 13px; white-space: nowrap; }

.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 20px 0; }
.quick-actions a {
  display: flex; flex-direction: column; gap: 3px; min-height: 82px; justify-content: center;
  padding: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .18s ease, border-color .18s ease;
}
.quick-actions a:hover { transform: translateY(-2px); border-color: var(--accent); }
.quick-actions strong { font-size: 14px; }
.quick-actions span { color: var(--text-muted); font-size: 12px; }

/* Cartões e faturas */
.credit-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.credit-card {
  position: relative; overflow: hidden; min-height: 260px; padding: 20px;
  border-radius: 22px; border: 1px solid color-mix(in srgb, var(--card-color), transparent 55%);
  background:
    radial-gradient(circle at 95% 0%, color-mix(in srgb, var(--card-color), transparent 50%), transparent 45%),
    linear-gradient(145deg, var(--bg-card), var(--bg-elevated));
  box-shadow: 0 22px 45px -32px var(--card-color);
  animation: slideUp .5s cubic-bezier(.16,1,.3,1) both;
}
.credit-card::after {
  content: ""; position: absolute; width: 160px; height: 160px; border: 1px solid color-mix(in srgb, var(--card-color), transparent 72%);
  border-radius: 50%; right: -70px; bottom: -100px; pointer-events: none;
}
.credit-card-top, .limit-row, .credit-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.credit-card-top h2 { margin: 2px 0 0; font-size: 18px; }
.eyebrow { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.invoice-value { display: flex; flex-direction: column; margin: 30px 0 22px; }
.invoice-value span, .invoice-value small, .limit-row { color: var(--text-muted); font-size: 12px; }
.invoice-value strong { font-size: 28px; letter-spacing: -.03em; }
.limit-row strong { color: var(--text); }
.credit-card-actions { margin-top: 18px; position: relative; z-index: 1; }
.status-badge {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted); font-size: 10px; font-weight: 700; white-space: nowrap;
}
.status-badge.open { color: var(--accent); border-color: color-mix(in srgb, var(--accent), transparent 45%); }
.status-badge.closed, .status-badge.pending { color: var(--warning); border-color: color-mix(in srgb, var(--warning), transparent 45%); }
.status-badge.paid { color: var(--income); border-color: color-mix(in srgb, var(--income), transparent 45%); }
.status-badge.overdue { color: var(--expense); border-color: color-mix(in srgb, var(--expense), transparent 45%); }
.invoice-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text);
  text-align: left; padding: 13px 4px; cursor: pointer;
}
.invoice-row:last-child { border-bottom: 0; }
.invoice-row-end { display: flex; align-items: center; gap: 10px; }
.invoice-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.invoice-summary div { background: var(--bg-elevated); padding: 10px; border-radius: 10px; display: flex; flex-direction: column; }
.invoice-summary span { color: var(--text-muted); font-size: 10px; }
.invoice-summary strong { font-size: 13px; }
.account-card-metrics { display: flex; gap: 8px; margin-top: 5px; color: var(--text-muted); font-size: 11px; }

/* Relatórios */
.report-filter { display: grid; grid-template-columns: 1fr 1fr auto auto auto; gap: 10px; align-items: end; }
.report-filter .field { margin: 0; }
.report-stats { grid-template-columns: repeat(4, 1fr); }
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ranking { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--bg-elevated); color: var(--text-muted); font-size: 11px; }

.month-picker { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; }
.month-picker button {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.12s ease;
}
.month-picker button:hover { background: var(--bg-card); border-color: var(--accent); }
.month-picker button:active { transform: scale(0.9); }
.month-picker .label { font-weight: 600; min-width: 130px; text-align: center; text-transform: capitalize; }

canvas.chart { width: 100%; height: 220px; display: block; animation: fadeIn 0.5s ease both; }
.interactive-chart-host {
  position: relative;
  isolation: isolate;
}
canvas.interactive-chart {
  cursor: crosshair;
  outline: none;
  touch-action: pan-y;
}
canvas.pie-interactive-chart.has-chart-target { cursor: pointer; }
canvas.interactive-chart:focus-visible {
  border-radius: 12px;
  box-shadow: 0 0 0 3px rgba(103, 232, 249, .32);
}
.chart-tooltip {
  position: absolute;
  z-index: 12;
  display: grid;
  gap: 7px;
  min-width: 220px;
  max-width: min(260px, calc(100% - 20px));
  padding: 12px 14px;
  border: 1px solid rgba(103, 232, 249, .3);
  border-radius: 14px;
  color: var(--text);
  background: rgba(7, 17, 34, .9);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .09);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  backdrop-filter: blur(18px) saturate(135%);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 4px)) scale(.96);
  transform-origin: 50% 100%;
  transition: opacity .16s ease, transform .16s ease;
}
.chart-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 4px)) scale(1);
}
.chart-tooltip strong {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  letter-spacing: .01em;
}
.chart-tooltip strong i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}
.chart-tooltip span {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}
.chart-tooltip span i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}
.chart-tooltip span b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.chart-tooltip small {
  color: var(--text-muted);
  font-size: 9px;
  opacity: .82;
}

.category-chart-heading { gap: 12px; }
.chart-view-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass-surface);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.chart-view-toggle button {
  min-height: 32px;
  padding: 5px 11px;
  border: 0;
  border-radius: 9px;
  color: var(--text-muted);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.chart-view-toggle button:hover { color: var(--text); }
.chart-view-toggle button.active {
  color: #06252a;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 8px 18px -10px rgba(34,211,238,.9);
}
.category-chart-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.category-chart-legend[hidden] { display: none; }
.category-legend-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 11px;
}
.category-legend-name {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-legend-item strong { color: var(--text); }
.category-legend-item small {
  grid-column: 2 / 4;
  margin-top: -5px;
  color: var(--text-muted);
  font-size: 10px;
}

/* Planejamento e inteligência */
.planning-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 180px;
  padding: 26px;
  margin-bottom: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  background:
    radial-gradient(circle at 90% 0%, rgba(103,232,249,.24), transparent 44%),
    radial-gradient(circle at 65% 110%, rgba(155,140,255,.22), transparent 45%),
    var(--glass-surface);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.planning-hero h2 { max-width: 560px; margin: 5px 0 6px; font-size: clamp(24px, 4vw, 36px); line-height: 1.08; letter-spacing: -.035em; }
.planning-hero p { max-width: 560px; margin: 0; color: var(--text-muted); font-size: 13px; }
.planning-hero-balance { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.planning-hero-balance span { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.planning-hero-balance strong { font-size: 25px; letter-spacing: -.03em; }
.planning-flow { margin-bottom: 20px; }
.planning-tabs { position: sticky; top: calc(var(--header-h) + 7px); z-index: 10; padding: 7px; border: 1px solid var(--glass-border); border-radius: 18px; background: var(--glass-surface-strong); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
.planning-tabs button { flex: 1; padding-inline: 11px; }
.planning-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.planning-grid > .card { margin-bottom: 0; }
.calendar-strip { display: grid; gap: 9px; }
.calendar-event {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 70px;
  padding: 10px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--glass-surface);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.calendar-event time { display: grid; place-items: center; align-content: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); line-height: 1; }
.calendar-event time strong { font-size: 18px; }
.calendar-event time span { margin-top: 4px; font-size: 9px; text-transform: uppercase; }
.calendar-event .meta { display: flex; flex-direction: column; min-width: 0; }
.calendar-event .meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event .meta small { color: var(--text-muted); }
.calendar-event.invoice time { background: rgba(251,113,133,.11); color: var(--expense); }
.calendar-event.recurring time { background: rgba(155,140,255,.12); color: var(--violet); }
.reconcile-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.reconcile-card > div { display: flex; flex-direction: column; min-width: 0; }
.reconcile-card small, .debt-card small { color: var(--text-muted); }
.reconcile-card p { grid-column: 2 / 4; margin: 0; color: var(--text-muted); font-size: 11px; }
.closing-checklist { display: grid; gap: 4px; }
.closing-checklist label { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 5px 8px; border-radius: 12px; }
.closing-checklist label:hover { background: var(--accent-soft); }
.closing-checklist input { width: 18px; height: 18px; accent-color: var(--accent-strong); }
.closing-checklist .btn { margin-top: 12px; }
.debt-card { display: flex; flex-direction: column; align-items: flex-start; }
.debt-card h3, .shared-wallet-card h3 { margin: 5px 0 0; }
.debt-card > strong, .shared-wallet-card > strong { margin: 8px 0 2px; font-size: 24px; }
.debt-card p { min-height: 36px; color: var(--text-muted); font-size: 11px; }
.debt-card.paid { opacity: .68; }
.savings-simulator .field-row { align-items: end; }
.simulator-result { display: flex; flex-direction: column; align-items: center; padding: 22px; border-radius: 20px; background: var(--accent-soft); }
.simulator-result span, .simulator-result small { color: var(--text-muted); }
.simulator-result strong { font-size: clamp(26px, 5vw, 40px); }
.shared-wallet-card { display: flex; flex-direction: column; align-items: flex-start; }
.shared-wallet-card .btn { margin-top: 15px; }
.expense-heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.expense-heatmap span { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; background: rgba(251,113,133,var(--heat)); color: var(--text); font-size: 10px; }
.net-worth-history { display: flex; align-items: flex-end; gap: 7px; min-height: 230px; overflow-x: auto; }
.net-worth-history > div { flex: 1 0 62px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.net-worth-history span, .net-worth-history strong { font-size: 9px; white-space: nowrap; }
.net-worth-history i { display: block; width: 22px; height: var(--height); min-height: 8px; max-height: 130px; border-radius: 8px 8px 3px 3px; background: linear-gradient(to top, var(--accent-strong), var(--violet)); }
.finance-assistant { display: grid; gap: 13px; }
#assistant-answer { min-height: 70px; padding: 16px; border-radius: 16px; background: var(--accent-soft); }
#assistant-form { display: flex; gap: 8px; }
#assistant-form input { flex: 1; min-width: 0; padding: 11px 13px; border: 1px solid var(--glass-border); border-radius: 14px; background: var(--glass-surface); color: var(--text); }
#assistant-form .btn { width: auto; }
.assistant-suggestions { display: flex; flex-wrap: wrap; gap: 7px; }
.assistant-suggestions button { padding: 7px 10px; border: 1px solid var(--glass-border); border-radius: 999px; background: transparent; color: var(--text-muted); cursor: pointer; }
.receipt-reader { display: grid; gap: 12px; }
.receipt-reader input[type="file"], .receipt-reader textarea { width: 100%; padding: 12px; border: 1px solid var(--glass-border); border-radius: 14px; background: rgba(148,163,184,.075); color: var(--text); }
.tax-table-wrap { overflow-x: auto; }
.privacy-toggle { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.privacy-toggle input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--accent-strong); }
.privacy-toggle > span { display: flex; flex-direction: column; }
.privacy-toggle small { color: var(--text-muted); }
.widget-settings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.widget-settings label { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12px; }
.privacy-mode .money-value,
.privacy-mode .amount,
.privacy-mode .value,
.privacy-mode .hero-balance strong,
.privacy-mode .invoice-value strong { filter: blur(7px); user-select: none; transition: filter .18s ease; }
.privacy-mode .money-value:hover,
.privacy-mode .amount:hover,
.privacy-mode .value:hover { filter: blur(4px); }

.progress-bar { height: 8px; border-radius: 999px; background: var(--bg-elevated); overflow: hidden; margin-top: 6px; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.progress-bar.over > div { background: linear-gradient(90deg, var(--expense), #ef4444); }

.spinner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 40px 0; color: var(--text-muted); font-size: 13px;
}
.spinner::before {
  content: "";
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.inline-icon { display: inline-flex; vertical-align: -3px; color: var(--text-muted); }

@media (min-width: 900px) {
  .app-main { max-width: 960px; }
  .bottom-nav { max-width: 260px; height: 100vh; top: 0; bottom: auto; flex-direction: column; padding-top: 20px; border-top: none; border-right: 1px solid var(--border); }
  .bottom-nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 12px 20px; font-size: 14px; }
  #app { flex-direction: row; }
  .app-content { flex: 1; display: flex; flex-direction: column; }
  .app-main { padding-bottom: 32px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .finance-hero { align-items: flex-start; flex-direction: column; }
  .dashboard-stats, .report-stats { grid-template-columns: repeat(2, 1fr); }
  .report-filter { grid-template-columns: 1fr 1fr; }
  .report-filter .btn { width: 100%; }
  .invoice-summary { grid-template-columns: 1fr; }
  .invoice-row-end { align-items: flex-end; flex-direction: column; gap: 4px; }
}

@media (max-width: 390px) {
  .quick-actions { grid-template-columns: 1fr; }
  .bottom-nav a { font-size: 10px; }
}

/* Visual refresh · fluido, suave e menos "quadrado" */
body {
  min-height: 100%;
  background:
    radial-gradient(ellipse 78% 58% at 4% -8%, rgba(103, 232, 249, .085), transparent 72%),
    radial-gradient(ellipse 74% 62% at 102% 20%, rgba(155, 140, 255, .075), transparent 74%),
    linear-gradient(145deg, #08101f 0%, #091426 46%, #08101f 100%);
  background-attachment: fixed;
  background-color: var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.92), rgba(0,0,0,.52) 48%, transparent 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.92), rgba(0,0,0,.52) 48%, transparent 100%);
}
html[data-resolved-theme="light"] body {
  background:
    radial-gradient(ellipse 78% 58% at 4% -8%, rgba(34, 211, 238, .11), transparent 72%),
    radial-gradient(ellipse 74% 62% at 102% 20%, rgba(155, 140, 255, .085), transparent 74%),
    linear-gradient(145deg, #f2f5fa 0%, #eef4fa 48%, #f2f5fa 100%);
  background-attachment: fixed;
  background-color: var(--bg);
}
html[data-resolved-theme="light"] body::before { opacity: .14; }

.app-content { min-width: 0; width: 100%; }
.app-header {
  height: var(--header-h);
  padding: 0 22px;
  background:
    linear-gradient(115deg, var(--glass-highlight), transparent 44%),
    var(--glass-surface-strong);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 14px 38px -32px rgba(0,0,0,.85);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
html[data-resolved-theme="light"] .app-header {
  background:
    linear-gradient(115deg, var(--glass-highlight), transparent 44%),
    var(--glass-surface-strong);
}
.header-copy { display: flex; flex-direction: column; gap: 1px; }
.header-kicker {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.app-header h1 { font-size: 21px; line-height: 1.1; font-weight: 720; letter-spacing: -.025em; }
.header-user { display: flex; align-items: center; gap: 9px; padding: 6px 8px 6px 6px; border-radius: 999px; transition: background .2s ease; }
.header-user:hover { background: var(--accent-soft); }
.header-user-copy { display: flex; flex-direction: column; line-height: 1.15; }
.header-user-copy small { color: var(--text-muted); font-size: 10px; }
.header-user-copy strong { font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.user-avatar {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border: 1px solid rgba(103,232,249,.28);
  border-radius: 13px;
  color: #06252a;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  font-size: 13px; font-weight: 800;
  box-shadow: 0 8px 22px -10px rgba(34,211,238,.8);
}
.app-main {
  max-width: 1120px;
  padding: 22px 18px calc(104px + var(--safe-bottom));
  animation-duration: .5s;
}

.bottom-nav {
  left: 12px; right: 12px; bottom: 10px;
  width: auto;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 0 6px var(--safe-bottom);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  background:
    linear-gradient(145deg, var(--glass-highlight), transparent 45%),
    var(--glass-surface-strong);
  box-shadow: 0 18px 55px rgba(0,0,0,.38), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
html[data-resolved-theme="light"] .bottom-nav { box-shadow: 0 18px 42px rgba(34,50,75,.14), inset 0 1px 0 var(--glass-highlight); }
.bottom-nav .nav-brand, .bottom-nav .nav-profile { display: none; }
.nav-links { width: 100%; display: flex; }
.bottom-nav .nav-links > a {
  flex: 1;
  min-width: 0;
  border-radius: 16px;
  transition: color .2s ease, background .2s ease, transform .16s ease;
}
.bottom-nav .nav-links > a.active { color: var(--accent); background: var(--accent-soft); }
.bottom-nav .nav-links > a.active::before { display: none; }
.bottom-nav .nav-links > a:active { transform: scale(.94); }
.bottom-nav .nav-links > a .nav-icon { padding: 3px; border-radius: 9px; }

.section-title { margin: 28px 2px 12px; }
.section-title h2 {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .075em;
  opacity: .82;
}
.section-title > a { color: var(--accent); font-size: 12px; }
.card {
  padding: 19px;
  margin-bottom: 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, var(--glass-highlight), transparent 42%),
    var(--glass-surface);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
  backdrop-filter: blur(14px) saturate(125%);
}
html[data-resolved-theme="light"] .card { box-shadow: 0 18px 45px -34px rgba(30,52,82,.35); }
.card:hover { transform: translateY(-1px); border-color: rgba(103,232,249,.22); }
.card h2 { font-size: 16px; letter-spacing: -.015em; }

.stat-grid { gap: 12px; }
.stat-card {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  text-align: left;
  border-color: var(--glass-border);
  border-radius: 20px;
  background:
    linear-gradient(150deg, var(--glass-highlight), transparent 60%),
    var(--glass-surface);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: blur(12px) saturate(125%);
  backdrop-filter: blur(12px) saturate(125%);
}
.stat-card:hover { transform: translateY(-3px); border-color: rgba(103,232,249,.22); }
.stat-card .value { font-size: clamp(16px, 3vw, 20px); letter-spacing: -.025em; }
.stat-card .label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

.finance-hero {
  min-height: 180px;
  padding: 26px;
  border: 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 88% 6%, rgba(103,232,249,.32), transparent 38%),
    radial-gradient(circle at 70% 100%, rgba(155,140,255,.22), transparent 42%),
    linear-gradient(135deg, #142642, #101b31 62%, #172542);
  box-shadow: 0 32px 70px -42px rgba(34,211,238,.72);
}
.finance-hero::after {
  content: "";
  position: absolute;
  width: 230px; height: 230px;
  right: -95px; bottom: -145px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(255,255,255,.025), 0 0 0 58px rgba(255,255,255,.018);
}
.finance-hero .btn { position: relative; z-index: 1; background: rgba(255,255,255,.10); color: white; border-color: rgba(255,255,255,.16); backdrop-filter: blur(10px); }
.hero-balance > span { color: rgba(226,236,250,.66); }
.hero-balance > strong { font-size: clamp(30px, 8vw, 44px); }
.hero-balance > small { color: rgba(226,236,250,.68); }

.btn {
  min-height: 44px;
  border-radius: 14px;
  padding: 11px 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 28px -16px rgba(34,211,238,.9);
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn.secondary { background: rgba(148,163,184,.075); backdrop-filter: blur(10px); }
.btn.ghost { border-radius: 12px; box-shadow: none; }
.btn.small { min-height: 38px; border-radius: 12px; }
.fab {
  right: 22px;
  bottom: calc(92px + var(--safe-bottom));
  border: 6px solid var(--bg);
  box-shadow: 0 18px 36px -14px rgba(34,211,238,.95);
}

.field { margin-bottom: 17px; }
.field label { margin: 0 0 7px 2px; color: var(--text-muted); font-weight: 600; font-size: 12px; }
.field input, .field select, .field textarea, .filters select, .filters input {
  min-height: 46px;
  border-color: var(--glass-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--glass-surface-strong), transparent 12%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 11px 13px;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus {
  background: var(--bg-elevated);
  border-color: rgba(103,232,249,.5);
  box-shadow: 0 0 0 4px rgba(103,232,249,.08);
}
.filters { gap: 9px; padding: 4px 0; }
.advanced-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 9px;
  margin: -2px 0 16px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--glass-surface);
}
.advanced-filters[hidden] { display: none; }
.advanced-filters .field { margin: 0; }
.tabs { gap: 8px; padding-bottom: 2px; }
.tabs button { min-height: 40px; border: 0; background: rgba(148,163,184,.075); }
.tabs button.active { box-shadow: 0 10px 24px -16px rgba(34,211,238,.9); }
.chip { border-color: transparent; background: rgba(148,163,184,.08); }

.list-item {
  min-height: 62px;
  margin: 0 -7px;
  padding: 12px 8px;
  border-bottom-color: rgba(148,163,184,.10);
}
.list-item:hover { background: rgba(103,232,249,.045); }
.list-item .meta .title { font-size: 14px; letter-spacing: -.01em; }
.list-item .meta .subtitle { font-size: 11px; }
.list-item .amount { font-size: 14px; }

.alert-card {
  min-height: 68px;
  padding: 14px 16px;
  border: 0;
  border-left: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(103,232,249,.08), rgba(103,232,249,.025));
}
.alert-card.warning { background: linear-gradient(135deg, rgba(251,191,36,.10), rgba(251,191,36,.025)); }
.alert-card.danger { background: linear-gradient(135deg, rgba(251,113,133,.11), rgba(251,113,133,.025)); }
.quick-actions { gap: 12px; }
.quick-actions a {
  min-height: 100px;
  padding: 19px;
  border-color: var(--glass-border);
  border-radius: 21px;
  background:
    linear-gradient(145deg, rgba(103,232,249,.07), transparent 50%),
    var(--glass-surface);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: blur(12px) saturate(125%);
  backdrop-filter: blur(12px) saturate(125%);
}
.quick-actions a:hover { transform: translateY(-4px); border-color: rgba(103,232,249,.20); }

.credit-card {
  min-height: 290px;
  padding: 24px;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 34px 70px -42px color-mix(in srgb, var(--card-color), transparent 20%);
}
.credit-card::before {
  content: "";
  position: absolute;
  width: 44px; height: 34px;
  left: 24px; top: 84px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f5d98b, #c99f45);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.32);
}
.invoice-value { margin-top: 72px; }
.invoice-row { min-height: 70px; border-radius: 14px; padding: 12px 10px; }
.invoice-row:hover { background: var(--accent-soft); }
.progress-bar { height: 7px; background: rgba(148,163,184,.12); }

.modal-overlay { background: rgba(1,5,15,.68); backdrop-filter: blur(7px); }
.modal-sheet {
  border: 1px solid var(--glass-border);
  border-radius: 28px 28px 0 0;
  padding: 24px;
  background:
    linear-gradient(145deg, var(--glass-highlight), transparent 45%),
    var(--glass-surface-strong);
  box-shadow: 0 -25px 80px rgba(0,0,0,.4), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.auth-shell {
  background:
    radial-gradient(circle at 30% 5%, rgba(103,232,249,.14), transparent 32rem),
    radial-gradient(circle at 80% 80%, rgba(155,140,255,.12), transparent 30rem);
}
.auth-card {
  max-width: 410px;
  padding: 34px 30px;
  border-color: var(--glass-border);
  border-radius: 30px;
  background:
    linear-gradient(145deg, var(--glass-highlight), transparent 45%),
    var(--glass-surface);
  box-shadow: 0 38px 90px -46px rgba(0,0,0,.9), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.auth-brand .logo { width: 62px; height: 62px; border-radius: 21px; }
.auth-brand h1 { font-size: 24px; letter-spacing: -.03em; }

@media (min-width: 900px) {
  body.is-authenticated #app { display: block; padding-left: 278px; }
  .bottom-nav {
    top: 14px; left: 14px; right: auto; bottom: 14px;
    width: 244px; max-width: none; height: auto;
    padding: 14px;
    flex-direction: column;
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    background:
      radial-gradient(circle at 30% 0%, rgba(103,232,249,.10), transparent 19rem),
      linear-gradient(145deg, var(--glass-highlight), transparent 45%),
      var(--glass-surface-strong);
    box-shadow: 18px 0 70px -45px rgba(0,0,0,.95);
  }
  .bottom-nav .nav-brand {
    flex: none;
    display: flex; align-items: center; gap: 11px;
    flex-direction: row; justify-content: flex-start;
    padding: 9px 8px 23px;
    border-bottom: 1px solid var(--border);
  }
  .nav-brand-mark {
    width: 43px; height: 43px; display: grid; place-items: center;
    border-radius: 15px; color: #06252a;
    background: linear-gradient(145deg, var(--accent), var(--accent-strong));
    box-shadow: 0 12px 28px -14px rgba(34,211,238,.85);
  }
  .nav-brand > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
  .nav-brand strong { font-size: 16px; letter-spacing: -.02em; }
  .nav-brand small { color: var(--text-muted); font-size: 10px; }
  .nav-links { flex: 1; flex-direction: column; gap: 6px; padding: 19px 0; }
  .bottom-nav .nav-links > a {
    flex: none;
    min-height: 48px;
    padding: 0 13px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    font-size: 13px;
    font-weight: 600;
  }
  .bottom-nav .nav-links > a.active { background: linear-gradient(90deg, rgba(103,232,249,.14), rgba(103,232,249,.045)); }
  .bottom-nav .nav-links > a.active .nav-icon { color: var(--accent); transform: none; }
  .bottom-nav .nav-profile {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 8px 4px;
    border-top: 1px solid var(--border);
  }
  .nav-profile > span:last-child { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
  .nav-profile strong, .nav-profile small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-profile strong { font-size: 11px; }
  .nav-profile small { color: var(--text-muted); font-size: 9px; }
  .app-header { padding: 0 34px; }
  .app-main { padding: 30px 34px 44px; }
  .fab { bottom: 28px; right: 32px; border-color: var(--bg); }
  .modal-sheet { border-radius: 28px; }
}

@media (max-width: 640px) {
  .app-header { padding: 0 17px; }
  .header-user-copy { display: none; }
  .header-user { padding: 0; }
  .app-main { padding-top: 16px; }
  .finance-hero { min-height: 210px; padding: 23px; }
  .dashboard-stats .stat-card { min-height: 86px; }
  .credit-card-grid { grid-template-columns: 1fr; }
  .credit-card { min-height: 280px; }
  .modal-sheet { padding: 22px 19px; }
  .category-chart-legend { grid-template-columns: 1fr; }
  .planning-hero { min-height: 220px; align-items: flex-start; flex-direction: column; padding: 22px; }
  .planning-hero-balance { align-items: flex-start; }
  .planning-flow { grid-template-columns: 1fr; }
  .planning-tabs { top: calc(var(--header-h) + 3px); overflow-x: auto; }
  .planning-tabs button { flex: 0 0 auto; }
  .planning-grid { grid-template-columns: 1fr; }
  .calendar-event { grid-template-columns: 50px minmax(0, 1fr); }
  .calendar-event > b { grid-column: 2; }
  .savings-simulator .field-row { flex-direction: column; gap: 0; }
  .savings-simulator .field-row .field { width: 100%; }
  .widget-settings { grid-template-columns: 1fr; }
  .advanced-filters { grid-template-columns: 1fr 1fr; }
}

/* Motion system · ambient depth, responsive interactions and micro-feedback */
:root {
  --pointer-x: 72vw;
  --pointer-y: 24vh;
  --scene-x: 0px;
  --scene-y: 0px;
  --page-scroll: 0px;
  --motion-ease: cubic-bezier(.16, 1, .3, 1);
  --motion-spring: cubic-bezier(.2, 1.45, .45, 1);
}

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .18s ease both motionPageOut; }
::view-transition-new(root) { animation: .42s var(--motion-ease) both motionPageIn; }

@keyframes motionPageOut {
  to { opacity: 0; transform: scale(.992); filter: blur(2px); }
}
@keyframes motionPageIn {
  from { opacity: 0; transform: translateY(8px) scale(.994); filter: blur(3px); }
}
@keyframes ambientDriftA {
  0%, 100% { transform: translate3d(-3%, -2%, 0) scale(1); }
  45% { transform: translate3d(9%, 7%, 0) scale(1.12); }
  75% { transform: translate3d(-5%, 10%, 0) scale(.96); }
}
@keyframes ambientDriftB {
  0%, 100% { transform: translate3d(3%, 6%, 0) rotate(0deg); }
  40% { transform: translate3d(-10%, -5%, 0) rotate(18deg); }
  72% { transform: translate3d(5%, -9%, 0) rotate(-10deg); }
}
@keyframes ambientPulse {
  0%, 100% { opacity: .34; scale: .94; }
  50% { opacity: .7; scale: 1.08; }
}
@keyframes particleFloat {
  0% { opacity: 0; transform: translate3d(0, 18px, 0) scale(.6); }
  18%, 72% { opacity: .5; }
  100% { opacity: 0; transform: translate3d(18px, -58px, 0) scale(1.2); }
}
@keyframes streakTravel {
  0%, 22% { opacity: 0; transform: translate3d(-35vw, 18vh, 0) rotate(-18deg); }
  28% { opacity: .42; }
  56%, 100% { opacity: 0; transform: translate3d(118vw, -22vh, 0) rotate(-18deg); }
}
@keyframes rippleWave {
  from { opacity: .34; transform: scale(0); }
  to { opacity: 0; transform: scale(1); }
}
@keyframes iconBreathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.04); }
}
@keyframes shimmerFlow {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@keyframes avatarGlow {
  0%, 100% { box-shadow: 0 8px 22px -10px rgba(34,211,238,.8); }
  50% { box-shadow: 0 10px 30px -7px rgba(34,211,238,.95), 0 0 0 5px rgba(103,232,249,.055); }
}

body {
  overflow-x: hidden;
  isolation: isolate;
}
body::before { z-index: -3; }
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(520px circle at var(--pointer-x) var(--pointer-y), rgba(103,232,249,.075), transparent 64%),
    radial-gradient(360px circle at calc(var(--pointer-x) + 90px) calc(var(--pointer-y) - 70px), rgba(155,140,255,.045), transparent 70%);
  transition: opacity .4s ease;
}
html[data-resolved-theme="light"] body::after {
  background:
    radial-gradient(520px circle at var(--pointer-x) var(--pointer-y), rgba(8,145,178,.07), transparent 64%),
    radial-gradient(360px circle at calc(var(--pointer-x) + 90px) calc(var(--pointer-y) - 70px), rgba(124,110,230,.045), transparent 70%);
}
#app { position: relative; z-index: 1; }

.ambient-scene {
  position: fixed;
  z-index: -2;
  inset: -32vh -24vw;
  overflow: visible;
  pointer-events: none;
  contain: layout style;
}
.ambient-parallax {
  position: absolute;
  inset: 0;
  transform: translate3d(var(--scene-x), calc(var(--scene-y) + var(--page-scroll)), 0);
  transition: transform .28s var(--motion-ease);
  will-change: transform;
}
.ambient-orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(18px);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,.88) 25%, rgba(0,0,0,.35) 41%, transparent 50%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,.88) 25%, rgba(0,0,0,.35) 41%, transparent 50%);
  will-change: transform, opacity;
}
.ambient-orb-a {
  width: min(74vw, 1040px);
  aspect-ratio: 1;
  left: -16%;
  top: -28%;
  background: radial-gradient(circle, rgba(34,211,238,.15), rgba(34,211,238,.045) 34%, transparent 51%);
  animation: ambientDriftA 18s ease-in-out infinite;
}
.ambient-orb-b {
  width: min(68vw, 920px);
  aspect-ratio: 1;
  right: -15%;
  top: 4%;
  background: radial-gradient(circle, rgba(155,140,255,.14), rgba(155,140,255,.04) 35%, transparent 51%);
  animation: ambientDriftB 22s ease-in-out infinite;
}
.ambient-orb-c {
  width: min(58vw, 780px);
  aspect-ratio: 1;
  left: 30%;
  bottom: -35%;
  background: radial-gradient(circle, rgba(52,211,153,.085), rgba(34,211,238,.025) 34%, transparent 51%);
  animation: ambientPulse 11s ease-in-out infinite;
}
.ambient-streak {
  position: absolute;
  left: 0;
  top: 48%;
  width: 38vw;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(103,232,249,.5), transparent);
  filter: drop-shadow(0 0 7px rgba(103,232,249,.55));
  animation: streakTravel 15s ease-in-out infinite;
}
.ambient-particles { position: absolute; inset: 0; }
.ambient-particles i {
  position: absolute;
  left: var(--particle-x);
  top: var(--particle-y);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(157,238,255,.72);
  box-shadow: 0 0 12px rgba(103,232,249,.78);
  animation: particleFloat var(--particle-duration) ease-in-out var(--particle-delay) infinite;
}
.ambient-particles i:nth-child(3n) {
  width: 2px;
  height: 2px;
  background: rgba(181,170,255,.72);
  box-shadow: 0 0 11px rgba(155,140,255,.7);
}

.motion-reveal {
  opacity: 0;
  translate: 0 20px;
  scale: .985;
}
.motion-reveal.motion-visible {
  opacity: 1;
  translate: 0 0;
  scale: 1;
  transition:
    opacity .54s var(--motion-ease) var(--motion-delay, 0ms),
    translate .62s var(--motion-ease) var(--motion-delay, 0ms),
    scale .62s var(--motion-ease) var(--motion-delay, 0ms);
}
.motion-tilt {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --shine-x: 50%;
  --shine-y: 50%;
  transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform .28s var(--motion-ease), border-color .25s ease, box-shadow .3s ease, filter .3s ease;
}
.motion-tilt:hover {
  transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) translateY(-3px);
  border-color: rgba(103,232,249,.28);
  box-shadow: 0 28px 65px -38px rgba(34,211,238,.34), inset 0 1px 0 var(--glass-highlight);
  filter: brightness(1.025);
}

.btn, .tabs button, .planning-tabs button, .bottom-nav a, .quick-actions > a {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.fab {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.motion-ripple {
  position: absolute;
  z-index: 4;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255,255,255,.5);
  transform: scale(0);
  animation: rippleWave .58s ease-out forwards;
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 28%, rgba(255,255,255,.28) 46%, transparent 64%);
  background-size: 240% 100%;
  opacity: 0;
}
.btn:hover::after {
  opacity: .65;
  animation: shimmerFlow 1.05s ease both;
}
.nav-icon svg, .quick-actions svg { transition: transform .3s var(--motion-spring), filter .25s ease; }
.bottom-nav a:hover .nav-icon svg {
  transform: translateY(-2px) scale(1.1);
  filter: drop-shadow(0 4px 6px rgba(103,232,249,.25));
}
.bottom-nav a.active .nav-icon svg { animation: iconBreathe 2.8s ease-in-out infinite; }
.quick-actions > a:hover svg { transform: translateY(-3px) rotate(-4deg) scale(1.12); }
.user-avatar { animation: avatarGlow 4.6s ease-in-out infinite; }
.list-item { transition: background .2s ease, translate .22s var(--motion-ease), border-color .2s ease; }
.list-item:hover { translate: 4px 0; border-color: rgba(103,232,249,.18); }
.list-item .amount { transition: transform .25s var(--motion-spring), text-shadow .25s ease; }
.list-item:hover .amount { transform: scale(1.04); text-shadow: 0 0 18px currentColor; }
.chip, .status-badge { transition: transform .2s var(--motion-spring), background .2s ease, border-color .2s ease; }
.chip:hover, .status-badge:hover { transform: translateY(-1px) scale(1.025); }
.progress-bar { overflow: hidden; }
.progress-bar > div {
  position: relative;
  background-size: 200% 100%;
  animation: shimmerFlow 3s linear infinite;
}
.app-header { transition: box-shadow .3s ease, background .3s ease, border-color .3s ease; }
body.has-scrolled .app-header {
  box-shadow: 0 18px 44px -28px rgba(0,0,0,.92), 0 1px 0 rgba(103,232,249,.07);
  border-bottom-color: rgba(103,232,249,.18);
}
.modal-backdrop { backdrop-filter: blur(8px); }
.spinner { filter: drop-shadow(0 0 8px rgba(103,232,249,.55)); }

@media (max-width: 640px) {
  body::after {
    background: radial-gradient(360px circle at 75% 12%, rgba(103,232,249,.06), transparent 68%);
  }
  .ambient-scene { inset: -6vh -20vw; }
  .ambient-orb-a { width: 90vw; opacity: .65; }
  .ambient-orb-b { width: 82vw; opacity: .5; }
  .ambient-particles i:nth-child(even) { display: none; }
  .motion-reveal { translate: 0 13px; }
  .list-item:hover { translate: 0; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .ambient-scene, body::after { display: none; }
  .motion-reveal {
    opacity: 1 !important;
    translate: none !important;
    scale: 1 !important;
  }
  .motion-tilt, .motion-tilt:hover {
    transform: none !important;
    filter: none !important;
  }
  .user-avatar, .bottom-nav a.active .nav-icon svg, .progress-bar > div { animation: none !important; }
}
