@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/roboto-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/roboto-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/roboto-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/roboto-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --ink: #0f172a;
  --body: #475569;
  --muted: #64748b;
  --line: #dce4f0;
  --primary: #2563eb;
  --primary-active: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #149b68;
  --warning: #b7791f;
  --danger: #c53b4e;
  --shadow: 0 12px 36px rgb(31 56 100 / 0.08);
  --shadow-lg: 0 20px 48px rgb(15 23 42 / 0.14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html.dark {
  color-scheme: dark;
  --bg: #0b1329;
  --surface: #151f38;
  --surface-2: #1c2948;
  --ink: #f1f5f9;
  --body: #a8b5ca;
  --muted: #8190a8;
  --line: #2d3b5e;
  --primary: #4b8df8;
  --primary-active: #76a9ff;
  --primary-soft: #1d376b;
  --success: #50c998;
  --warning: #ecc16d;
  --danger: #ff8b9b;
  --shadow: 0 16px 44px rgb(0 0 0 / 0.28);
  --shadow-lg: 0 24px 56px rgb(0 0 0 / 0.40);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
html { background: var(--bg); }
body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

body.modal-open {
  overflow: hidden !important;
  touch-action: none;
}

button, input, select {
  font: inherit;
  font-size: 16px;
  touch-action: manipulation;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.screen {
  min-height: 100svh;
  min-height: 100dvh;
}

.hidden { display: none !important; }

/* Ícones Lucide SVG */
.lucide-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
html.dark .theme-icon-sun { display: block; }
html.dark .theme-icon-moon { display: none; }

/* Autenticação */
.auth-screen {
  display: grid;
  place-items: center;
  padding: max(28px, calc(20px + var(--safe-top))) 20px max(28px, calc(28px + var(--safe-bottom)));
}

.auth-wrap, .narrow-screen {
  width: min(100%, 460px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-lockup.compact { font-size: 15px; }

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 10px rgb(37 99 235 / 0.22));
  transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1), filter .2s ease;
}

.brand-lockup.compact .brand-logo {
  width: 34px;
  height: 34px;
}

.brand-lockup:hover .brand-logo {
  filter: drop-shadow(0 8px 14px rgb(37 99 235 / 0.3));
  transform: translateY(-1px) rotate(-2deg);
}

.auth-intro { margin: 48px 0 24px; }
.auth-intro h1, .step-heading h1, .view-heading h1 {
  margin: 6px 0 10px;
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.auth-intro p:not(.eyebrow), .step-heading p {
  margin: 0;
  color: var(--body);
  max-width: 38ch;
}

.eyebrow, .step-count, .metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow.light { color: rgb(255 255 255 / 0.78); }

.auth-card, .loading-card, .metric-card, .chat-card, .ai-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-card { padding: 14px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--surface-2);
  border-radius: 13px;
}

.segment {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}

.segment.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.08);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.field input, .field select, .chat-form input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  padding: 13px 15px;
  font-size: 16px;
  transition: border-color .18s, box-shadow .18s;
}

.field input:focus, .field select:focus, .chat-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgb(37 99 235 / 0.14);
}

.field-hint, .privacy-note, .disclaimer, .muted, .metric-caption, .section-caption {
  color: var(--muted);
}

.field-hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.field {
  gap: 8px;
  margin-bottom: 18px;
}

.field label {
  font-size: 13px;
  letter-spacing: 0.01em;
}

.field input, .field select, .chat-form input {
  border-width: 1.5px;
  background: color-mix(in srgb, var(--surface) 96%, var(--surface-2));
}

.field input::placeholder, .chat-form input::placeholder {
  color: var(--muted);
  opacity: 0.82;
}

.field.full-span {
  grid-column: 1 / -1;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field-value-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 800;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

.button:active { transform: scale(0.98); }
.button:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.button.primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgb(37 99 235 / 0.22);
}

.button.primary:hover:not(:disabled) {
  background: var(--primary-active);
}

.button.secondary {
  background: var(--primary-soft);
  color: var(--primary-active);
}

.button.full { width: 100%; }

.form-error {
  min-height: 22px;
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.privacy-note {
  margin: 18px auto 0;
  max-width: 36ch;
  text-align: center;
  font-size: 12px;
}

.narrow-screen {
  margin: 0 auto;
  padding: max(24px, calc(16px + var(--safe-top))) 16px calc(40px + var(--safe-bottom));
}

.step-heading { margin: 48px 0 28px; }
.step-count { color: var(--primary); }
.form-stack { display: grid; gap: 2px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-prefix {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding-left: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.input-prefix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgb(37 99 235 / 0.14);
}

.input-prefix input {
  min-height: 50px;
  border: 0;
  padding-left: 0;
  font-size: 16px;
  box-shadow: none !important;
}

/* Topbar & Navegação */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: max(12px, calc(8px + var(--safe-top))) max(16px, calc((100vw - 720px) / 2)) 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button, .text-button, .link-button, .round-add, .send-button {
  border: 0;
  background: transparent;
  color: var(--body);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  transition: background .15s ease, color .15s ease;
}

.icon-button:hover, .icon-button:active {
  background: var(--surface-2);
  color: var(--ink);
}

.text-button {
  min-width: 48px;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 750;
  border-radius: var(--radius-sm);
  transition: background .15s ease, color .15s ease;
}

.text-button:hover, .text-button:active {
  background: var(--surface-2);
  color: var(--ink);
}

.content {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 24px 16px calc(108px + var(--safe-bottom));
}

.view-heading, .section-heading, .card-topline, .ai-card-header, .modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.view-heading {
  align-items: center;
  margin-bottom: 22px;
}

.view-heading h1 { margin-bottom: 0; }
.loading-card { padding: 24px; color: var(--body); }

.error-state {
  display: grid;
  gap: 8px;
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}

.error-state strong {
  color: var(--ink);
  font-size: 16px;
}

.error-state p {
  margin: 0;
  color: var(--body);
  font-size: 14px;
}

.error-state .button {
  width: max-content;
  margin-top: 4px;
}

/* Card de Teto Seguro */
.safe-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: #183d85;
  color: #ffffff;
  box-shadow: 0 16px 36px rgb(37 99 235 / 0.22);
}

.safe-card::after {
  position: absolute;
  right: -34px;
  bottom: -52px;
  width: 150px;
  height: 150px;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 50%;
  box-shadow: 0 0 0 20px rgb(255 255 255 / 0.05), 0 0 0 40px rgb(255 255 255 / 0.04);
  content: "";
  pointer-events: none;
}

.safe-card p {
  position: relative;
  z-index: 1;
  max-width: 34ch;
  margin: 10px 0 0;
  color: rgb(255 255 255 / 0.82);
  font-size: 14px;
}

.safe-card p strong { color: #ffffff; }

.money-display {
  display: block;
  position: relative;
  z-index: 1;
  margin-top: 10px;
  font: 800 clamp(30px, 9.5vw, 48px)/1.05 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.06em;
  word-break: break-word;
}

.status-pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.light-pill {
  color: #ffffff;
  background: rgb(255 255 255 / 0.16);
}

/* Grade de Métricas */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-card {
  min-height: 122px;
  padding: 16px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 3px;
  color: var(--ink);
  font: 800 clamp(18px, 4.8vw, 22px)/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.04em;
  word-break: break-word;
}

.metric-caption {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

/* Seções e Envelopes */
.section-block { margin: 28px 0; }
.section-heading {
  align-items: flex-end;
  margin-bottom: 14px;
}

.section-heading h2, .chat-card h2, .modal-header h2 {
  margin: 4px 0 0;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.link-button {
  min-height: 48px;
  padding: 10px 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.envelope-list {
  display: grid;
  gap: 10px;
}

.envelope-row {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.envelope-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.envelope-name { font-weight: 800; font-size: 15px; }
.envelope-value { color: var(--body); font-size: 13px; font-variant-numeric: tabular-nums; }

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .48s cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Lançamentos */
@keyframes transaction-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.spending-overview {
  position: relative;
  overflow: hidden;
  margin: 0 0 18px;
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 58%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 18px 38px rgb(37 99 235 / 0.24);
}

.spending-overview::after {
  position: absolute;
  right: -52px;
  bottom: -76px;
  width: 190px;
  height: 190px;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 50%;
  box-shadow: 0 0 0 20px rgb(255 255 255 / 0.06), 0 0 0 42px rgb(255 255 255 / 0.045);
  content: "";
  pointer-events: none;
}

.spending-overview > * {
  position: relative;
  z-index: 1;
}

.spending-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.spending-overview-head > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.overview-status {
  max-width: 45%;
  color: rgb(255 255 255 / 0.78);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
}

.spending-total {
  display: block;
  margin-top: 16px;
  font: 800 clamp(30px, 9vw, 42px)/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.spending-overview-caption {
  max-width: 34ch;
  margin: 9px 0 16px;
  color: rgb(255 255 255 / 0.78);
  font-size: 13px;
}

.spending-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(8 47 130 / 0.42);
}

.spending-progress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #ffffff;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .5s cubic-bezier(0.16, 1, 0.3, 1);
}

.spending-overview-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 11px;
  color: rgb(255 255 255 / 0.76);
  font-size: 12px;
}

.spending-overview-foot strong {
  color: #ffffff;
  font: 750 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.transactions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.transactions-toolbar .filter-row {
  min-width: 0;
  margin: 0;
  padding-bottom: 2px;
}

.transactions-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.transaction-list {
  display: grid;
  gap: 10px;
}

.transaction-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgb(31 56 100 / 0.055);
  animation: transaction-enter .3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.transaction-card:nth-child(2) { animation-delay: .035s; }
.transaction-card:nth-child(3) { animation-delay: .07s; }
.transaction-card:nth-child(4) { animation-delay: .105s; }

.transaction-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 15px 14px 13px;
}

.transaction-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
}

.transaction-icon.income {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}

.transaction-detail {
  min-width: 0;
}

.transaction-title-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.transaction-title {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-type-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.transaction-meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.transaction-category {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-date {
  color: var(--body);
  font-variant-numeric: tabular-nums;
}

.transaction-status {
  border-radius: 999px;
  padding: 3px 7px;
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  color: var(--warning);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.transaction-status.is-paid,
.transaction-status.is-income {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}

.transaction-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.transaction-amount {
  color: var(--ink);
  font: 800 14px ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.transaction-amount.income { color: var(--success); }
.transaction-amount.paid { color: var(--muted); text-decoration: line-through; }

.transaction-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0 14px 13px;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.transaction-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--body);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 750;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.transaction-actions button:hover {
  background: var(--primary-soft);
  color: var(--primary-active);
}

.transaction-actions button:active { transform: scale(.96); }
.transaction-actions button:last-child { color: var(--danger); }
.transaction-actions button:last-child:hover { background: color-mix(in srgb, var(--danger) 12%, var(--surface-2)); }

.empty-state {
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

/* Barra Inferior (Bottom Navigation) */
.bottom-nav {
  position: fixed;
  right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  left: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(696px, calc(100% - 24px));
  margin: 0 auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  isolation: isolate;
}

.bottom-nav::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc((100% - 12px) / 3);
  border-radius: 16px;
  background: var(--primary-soft);
  box-shadow: 0 5px 14px rgb(37 99 235 / 0.16);
  content: "";
  pointer-events: none;
  transform: translateX(var(--nav-offset, 0%));
  transition: transform .36s cubic-bezier(0.22, 1, 0.36, 1), opacity .2s ease;
  will-change: transform;
  z-index: 0;
}

.nav-item {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 60px;
  padding: 4px 3px 5px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.1;
  transition: color .24s ease, transform .24s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  color: currentColor;
  transition: background .24s ease, color .24s ease, box-shadow .24s ease, transform .24s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-icon .lucide-icon {
  width: 20px;
  height: 20px;
  transition: transform .24s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-item > span:not(.nav-icon) {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform .24s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-item.active {
  color: var(--ink);
}

.nav-item.active .nav-icon {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 5px 12px rgb(37 99 235 / 0.25);
  transform: translateY(-1px);
}

.nav-item.active .nav-icon .lucide-icon {
  transform: scale(1.04);
}

.nav-item.active > span:not(.nav-icon) {
  transform: translateY(-1px);
}

.nav-item:not(.active):hover .nav-icon,
.nav-item:not(.active):focus-visible .nav-icon {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item:active {
  transform: scale(.96);
}

.nav-item:focus-visible {
  z-index: 2;
}

/* Filtros */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: -4px 0 20px;
  padding-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter {
  min-height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--body);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 750;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.filter.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.round-add {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 18px rgb(37 99 235 / 0.22);
  transition: transform .15s ease;
}

.round-add:active { transform: scale(0.95); }
.large-list { min-height: 150px; }

/* Tela de IA */
@keyframes screen-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-breathe {
  0%, 100% { opacity: .72; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

.view-panel:not(.hidden) { animation: screen-enter .28s cubic-bezier(0.16, 1, 0.3, 1) both; }

.ai-spark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  animation: ai-breathe 3.4s ease-in-out infinite;
}

.ai-badge {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.morning-card {
  position: relative;
  overflow: hidden;
  margin: 16px 0 24px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface));
  box-shadow: var(--shadow);
  animation: screen-enter .38s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.morning-card::after {
  position: absolute;
  right: -38px;
  bottom: -58px;
  width: 150px;
  height: 150px;
  border: 18px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 50%;
  content: "";
  opacity: .65;
}
.morning-card > * { position: relative; z-index: 1; }
.morning-card-head, .morning-brand, .ai-hero-head, .ai-card-header {
  display: flex;
  align-items: center;
}
.morning-card-head, .ai-hero-head { justify-content: space-between; gap: 14px; }
.morning-brand { min-width: 0; gap: 10px; }
.morning-card h2, .ai-hero-card h2 {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: -0.025em;
}
.ai-status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  color: var(--body);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
}
.light-status { border-color: rgb(255 255 255 / .25); background: rgb(255 255 255 / .12); color: #ffffff; }
.morning-message {
  max-width: 54ch;
  margin: 16px 0 10px;
  color: var(--body);
  font-size: 14px;
  line-height: 1.52;
}
.morning-link { min-height: 40px; padding: 6px 0 0; }

.ai-hero-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-active));
  color: #ffffff;
  box-shadow: 0 16px 34px rgb(37 99 235 / .22);
  animation: screen-enter .38s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.ai-hero-card::after {
  position: absolute;
  right: -46px;
  bottom: -70px;
  width: 190px;
  height: 190px;
  border: 20px solid rgb(255 255 255 / .12);
  border-radius: 50%;
  content: "";
}
.ai-hero-card > * { position: relative; z-index: 1; }
.ai-hero-card h2 { color: #ffffff; }
.ai-briefing-text {
  max-width: 54ch;
  margin: 16px 0;
  color: rgb(255 255 255 / .9);
  font-size: 15px;
  line-height: 1.55;
}
.ai-cycle-label {
  display: inline-flex;
  border: 1px solid rgb(255 255 255 / .22);
  border-radius: 999px;
  background: rgb(255 255 255 / .12);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
}
.ai-alert-section { margin: 0 0 20px; }
.ai-alert-list { display: grid; gap: 8px; }
.ai-alert {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  transition: transform .18s ease;
}
.ai-alert:active { transform: scale(.99); }
.ai-alert-marker {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
}
.ai-alert.warning .ai-alert-marker { background: var(--warning); }
.ai-alert.critical .ai-alert-marker { background: var(--danger); }
.ai-alert.positive .ai-alert-marker { background: var(--success); }
.ai-alert strong { display: block; color: var(--ink); font-size: 13px; }
.ai-alert p { margin: 2px 0 0; color: var(--body); font-size: 13px; line-height: 1.4; }

.ai-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
}
.ai-metric {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.ai-metric strong {
  display: block;
  overflow: hidden;
  margin: 8px 0 3px;
  color: var(--ink);
  font: 800 16px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
}
.ai-metric > span:last-child { color: var(--muted); font-size: 11px; }

.ai-card, .chat-card { padding: 20px; animation: screen-enter .42s cubic-bezier(0.16, 1, 0.3, 1) both; }
.ai-card { margin-bottom: 16px; }
.ai-card-header { justify-content: flex-start; gap: 10px; color: var(--body); font-weight: 750; }
.ai-card-header > div { display: grid; gap: 2px; }
.ai-source { color: var(--muted); font-size: 11px; font-weight: 500; }
.ai-card p { min-height: 48px; margin: 16px 0; color: var(--body); font-size: 14px; }
.quick-prompts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 16px 0 2px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.quick-prompts::-webkit-scrollbar { display: none; }
.quick-prompt {
  min-height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--body);
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 750;
  transition: transform .16s ease;
}
.quick-prompt:active { transform: scale(.97); }

.chat-messages {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin: 18px 0 14px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble {
  max-width: 88%;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  animation: screen-enter .22s ease both;
}
.chat-bubble.assistant { border-bottom-left-radius: 4px; background: var(--surface-2); color: var(--ink); }
.chat-bubble.user { justify-self: end; border-bottom-right-radius: 4px; background: var(--primary); color: #ffffff; }
.chat-form { display: grid; grid-template-columns: 1fr 48px; gap: 8px; }
.send-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  transition: transform .15s ease;
}
.send-button:active { transform: scale(0.95); }
.disclaimer { margin: 12px 0 0; font-size: 11px; }

.date-trigger {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 68px;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 96%, var(--surface-2));
  color: var(--ink);
  padding: 10px 14px;
  text-align: left;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.date-trigger:hover, .date-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--surface);
}

.date-trigger:active {
  transform: translateY(1px);
}

.date-trigger-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary);
}

.date-trigger-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.date-trigger-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-trigger-copy strong {
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-trigger-chevron {
  color: var(--muted);
  transition: transform .18s ease;
}

.date-trigger[aria-expanded="true"] .date-trigger-chevron {
  transform: rotate(180deg);
}

.date-picker-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.date-picker-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--ink);
  text-align: center;
}

.date-picker-toolbar strong {
  font-size: 15px;
  text-transform: capitalize;
}

.calendar-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--body);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.calendar-nav:hover, .calendar-nav:active {
  background: var(--primary-soft);
  color: var(--primary);
}

.calendar-nav:active {
  transform: scale(0.95);
}

.date-picker-weekdays, .date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.date-picker-weekdays {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.date-picker-grid {
  margin-top: 5px;
}

.calendar-day {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}

.calendar-day:hover, .calendar-day:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-active);
}

.calendar-day:active {
  transform: scale(0.94);
}

.calendar-day.is-outside {
  color: var(--muted);
  opacity: 0.56;
}

.calendar-day.is-today {
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  color: var(--primary);
}

.calendar-day.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 5px 12px rgb(37 99 235 / 0.22);
}

.calendar-day.is-selected.is-today {
  color: #ffffff;
}

.date-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.date-picker-selected {
  min-width: 0;
  overflow: hidden;
  color: var(--body);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-today {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-active);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: background .15s ease, transform .15s ease;
}

.picker-today:hover {
  background: color-mix(in srgb, var(--primary-soft) 75%, var(--primary));
}

.picker-today:active {
  transform: scale(0.96);
}

/* Modal Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  background: rgb(7 15 33 / 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  width: 100%;
  max-height: min(90svh, 760px);
  max-height: min(90dvh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 20px calc(28px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  align-items: center;
  margin-bottom: 20px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin-top: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-2));
  color: var(--body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}

.checkbox-row:focus-within {
  border-color: var(--primary);
  background: var(--surface);
}

.checkbox-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  top: max(18px, calc(12px + var(--safe-top)));
  right: 18px;
  left: 18px;
  z-index: 100;
  transform: translateY(-160%);
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  padding: 13px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 750;
  text-align: center;
  transition: transform .24s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show { transform: translateY(0); }
.toast.error { background: var(--danger); color: #ffffff; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Acessibilidade de Foco */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 65%, transparent);
  outline-offset: 3px;
}

@media (max-width: 540px) {
  .transactions-toolbar {
    display: block;
  }

  .transactions-count {
    display: block;
    margin-top: 3px;
  }
}

@media (max-width: 360px) {
  .spending-overview {
    padding: 16px;
  }

  .spending-overview-foot {
    gap: 8px;
    font-size: 11px;
  }

  .transaction-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
  }

  .transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .transaction-amount {
    grid-column: 2;
    margin-top: -3px;
    text-align: left;
  }

  .transaction-type-chip {
    display: none;
  }
}

/* Responsividade Mobile Estreita (320px até 430px) */
@media (max-width: 360px) {
  .topbar, .content { padding-left: 12px; padding-right: 12px; }
  .safe-card, .ai-card, .chat-card, .auth-card { padding-left: 14px; padding-right: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 8px; }
  .metric-card { padding: 12px; }
  .metric-card strong { font-size: 17px; }
}

@media (max-width: 430px) {
  .auth-screen { place-items: start center; }
  .auth-intro { margin-top: 36px; }
}

@media (min-width: 720px) {
  .auth-screen { padding: 48px 24px; }
  .auth-intro { margin-top: 64px; }
  .content { padding-top: 36px; }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal-card { width: min(100%, 560px); border-radius: 24px; padding: 28px; }
}

@media (max-width: 430px) {
  .ai-metric-grid { grid-template-columns: 1fr 1fr; }
  .ai-metric:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
