/* ================================================================
   Débita+ — Design System v3 (Mobile-First, Clean)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ================================================================
   1. DESIGN TOKENS
   ================================================================ */
:root {
  /* Brand */
  --primary:          #FF7A00;
  --primary-dark:     #E06500;
  --primary-light:    #FF9B3D;
  --primary-glow:     rgba(255,122,0,0.15);
  --accent:           #10B981;
  --accent-dark:      #059669;
  --danger:           #EF4444;
  --danger-light:     rgba(239,68,68,0.10);
  --warning:          #F59E0B;
  --info:             #3B82F6;

  /* Surfaces */
  --bg:               #F0F2F7;
  --surface:          #FFFFFF;
  --surface-2:        #F8F9FC;
  --border:           rgba(15,23,42,0.07);
  --border-strong:    rgba(15,23,42,0.13);

  /* Text */
  --text:             #0F1724;
  --text-2:           #374151;
  --muted:            #6B7280;
  --muted-light:      #9CA3AF;

  /* Shadows */
  --shadow-sm:        0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow:           0 4px 16px rgba(15,23,42,0.08), 0 1px 4px rgba(15,23,42,0.04);
  --shadow-lg:        0 10px 36px rgba(15,23,42,0.12), 0 2px 8px rgba(15,23,42,0.06);
  --shadow-primary:   0 6px 20px rgba(255,122,0,0.30);

  /* Geometry */
  --radius-xs:        6px;
  --radius-sm:        10px;
  --radius:           14px;
  --radius-lg:        18px;
  --radius-xl:        24px;

  /* Motion */
  --ease:             cubic-bezier(0.16, 1, 0.3, 1);
  --dur:              220ms;

  /* Layout */
  --header-h:         56px;
  --nav-h:            64px;
  --safe-t:           env(safe-area-inset-top,    0px);
  --safe-b:           env(safe-area-inset-bottom, 0px);
  --safe-l:           env(safe-area-inset-left,   0px);
  --safe-r:           env(safe-area-inset-right,  0px);
  --page-px:          16px;

  /* Inputs */
  --input-bg:         #FFFFFF;
  --input-border:     rgba(15,23,42,0.10);
}

/* ================================================================
   2. DARK MODE
   ================================================================ */
.dark {
  --primary:          #FF9B3D;
  --primary-dark:     #E07A20;
  --primary-light:    #FFB870;
  --primary-glow:     rgba(255,155,61,0.15);
  --accent:           #34D399;
  --accent-dark:      #10B981;
  --danger:           #F87171;
  --danger-light:     rgba(248,113,113,0.12);
  --warning:          #FCD34D;

  --bg:               #080E1A;
  --surface:          #0F1826;
  --surface-2:        #141F30;
  --border:           rgba(255,255,255,0.07);
  --border-strong:    rgba(255,255,255,0.12);

  --text:             #EEF2FF;
  --text-2:           #CBD5E1;
  --muted:            #8898AA;
  --muted-light:      #64748B;

  --shadow-sm:        0 1px 3px rgba(0,0,0,0.25);
  --shadow:           0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg:        0 10px 36px rgba(0,0,0,0.45);

  --input-bg:         #0F1826;
  --input-border:     rgba(255,255,255,0.10);
}

/* ================================================================
   3. RESET
   ================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  height: 100%;
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
}
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* CRITICAL: prevent content from overflowing viewport horizontally */
  overflow-x: hidden;
  max-width: 100vw;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
button  { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
img     { max-width: 100%; display: block; }
p       { margin: 0; }
h1,h2,h3,h4 { margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

/* ================================================================
   4. GLOBAL LAYOUT
   ================================================================ */

/* Page wrapper: fills the screen, column layout */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
}

/* Inner padding respects safe areas and stays inside viewport */
.container-fluid {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding-left:  max(var(--page-px), var(--safe-l));
  padding-right: max(var(--page-px), var(--safe-r));
}

/* Scrollable content area between header and nav */
.app-content {
  flex: 1;
  /* top: some breathing room; bottom: clear fixed nav + safe area */
  padding-top: 16px;
  padding-bottom: calc(var(--nav-h) + max(16px, var(--safe-b)) + 8px);
  overflow-x: hidden;
}

/* Desktop overrides */
@media (min-width: 640px) {
  :root {
    --header-h: 60px;
    --nav-h:    0px;
    --page-px:  24px;
  }
  h1 { font-size: 26px; }
  h2 { font-size: 22px; }
  h3 { font-size: 17px; }
  h4 { font-size: 15px; }
  .app-content {
    padding-top: 28px;
    padding-bottom: 40px;
  }
}
@media (min-width: 1024px) {
  :root { --page-px: 32px; }
}

/* Utilities */
.hidden    { display: none !important; }
.full      { width: 100%; }
.all       { width: 100%; }
.small     { font-size: 12px; }
.center-text { text-align: center; }
.muted     { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }
.row              { display: flex; align-items: center; }
.row-between-center { display: flex; align-items: center; justify-content: space-between; }
.row-center       { display: flex; align-items: center; justify-content: center; }
.gap   { gap: 10px; }
.gap-s { gap: 6px; }
.mt    { margin-top: 14px; }
.mt-s  { margin-top: 8px; }
.mb    { margin-bottom: 14px; }
.ml    { margin-left: 14px; }
.ml-s  { margin-left: 6px; }
.mr-s  { margin-right: 6px; }
.p     { padding: 16px; }
.p-s   { padding: 10px 14px; }
.pageAccount { width: 100%; }
.label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.code-text { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; color: var(--muted); }
.icon-large { font-size: 2.4em; display: block; margin-bottom: 12px; }

/* ================================================================
   5. HEADER
   ================================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: rgba(255,255,255,0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  /* account for notch */
  padding-top: var(--safe-t);
}
.dark .app-header { background: rgba(15,24,38,0.90); }

.app-header .container-fluid {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-row { display: flex; align-items: center; gap: 8px; }
.logo { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.logo-row h1 {
  font-size: 19px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.4px;
}

/* Header right controls */
.app-header .row.gap { gap: 4px; }

/* ================================================================
   6. BOTTOM NAVIGATION
   ================================================================ */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: calc(var(--nav-h) + max(0px, var(--safe-b)));
  padding-bottom: max(0px, var(--safe-b));
  padding-left:  var(--safe-l);
  padding-right: var(--safe-r);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.06);

  /* 5-column grid: icon icon FAB icon icon */
  display: grid;
  grid-template-columns: 1fr 1fr 68px 1fr 1fr;
  align-items: center;
}
.dark .mobile-nav {
  background: rgba(15,24,38,0.95);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.30);
}

/* Hide on desktop */
@media (min-width: 640px) {
  .mobile-nav { display: none !important; }
  #settings-button { display: flex !important; }
}
#settings-button { display: none; }

/* Nav item */
.nav-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  color: var(--muted-light);
  border-radius: 10px;
  position: relative;
  transition: color var(--dur) var(--ease);
  /* prevent touch highlight */
  -webkit-tap-highlight-color: transparent;
}
.nav-bottom i    { font-size: 1.2em; transition: transform var(--dur) var(--ease); }
.nav-bottom span { font-size: 9.5px; font-weight: 600; letter-spacing: 0.03em; line-height: 1; }
.nav-bottom:active { background: var(--surface-2); }

.nav-bottom.active { color: var(--primary); }
.nav-bottom.active i { transform: translateY(-2px) scale(1.1); }
.nav-bottom.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* Central FAB */
.nav-fab-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.nav-fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  font-size: 1.5em;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 5px 18px var(--primary-light),
    0 0 0 3px var(--surface);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  margin-top: -18px;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.dark .nav-fab {
  box-shadow: 0 5px 18px var(--dur), 0 0 0 3px var(--surface);
}
.nav-fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 8px 24px var(--primary-dark), 0 0 0 3px var(--surface);
}
.nav-fab:active {
  transform: scale(0.94);
}
/* Pulse ring */
.nav-fab::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--primary-dark);
  animation: fabPulse 2.6s ease-in-out infinite;
}
@keyframes fabPulse {
  0%,100% { opacity: 0; transform: scale(0.88); }
  50%      { opacity: 1; transform: scale(1.10); }
}
.nav-fab.open {
  background: linear-gradient(145deg, #6B7280, #374151);
  box-shadow: 0 5px 18px rgba(0,0,0,0.28), 0 0 0 3px var(--surface);
}
.nav-fab i,
.nav-fab.open i { transition: transform 280ms var(--ease); }
.nav-fab.open i  { transform: rotate(45deg); }

/* ================================================================
   7. PAGES
   ================================================================ */
.page { animation: pageIn 0.28s var(--ease); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header { margin-bottom: 16px; }
.page-header h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.page-header p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ================================================================
   8. CARDS
   ================================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ================================================================
   9. METRIC CARDS
   ================================================================ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 640px) {
  .metric-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
  }
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: opacity var(--dur);
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.metric-card:hover::before { opacity: 1; }
.metric-card i      { font-size: 1.3em; margin-bottom: 1px; }
.metric-card .label { font-size: 10px; letter-spacing: 0.05em; }
.metric-card h3     { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }

@media (min-width: 640px) {
  .metric-card { padding: 18px; }
  .metric-card h3 { font-size: 21px; }
}

/* ================================================================
   10. SCORE WIDGET
   ================================================================ */
.score-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
}
.score-container::after {
  content: '';
  position: absolute;
  top: 5px; right: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary-glow);
  pointer-events: none;
}
.score-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.score-number {
  font-size: 2.1em;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
  line-height: 1;
}
.score-title { font-size: 1em; font-weight: 700; color: var(--text-2); text-align: right; }
#score-bar-wrapper {
  height: 8px;
  background: var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  transition: width 0.9s var(--ease), background-color 0.6s ease;
  background: var(--primary);
}
.subtitleScore {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}
/* Score states */
.critico   .progress-bar-fill { background: var(--danger);  }
.ruim      .progress-bar-fill { background: var(--warning); }
.regular   .progress-bar-fill { background: var(--info);    }
.bom       .progress-bar-fill { background: var(--accent);  }
.excelente .progress-bar-fill { background: var(--accent);  }
.critico   .score-number { color: var(--danger);  }
.ruim      .score-number { color: var(--warning); }
.regular   .score-number { color: var(--info);    }
.bom       .score-number { color: var(--accent);  }
.excelente .score-number { color: var(--accent);  }

@media (min-width: 640px) {
  .score-container { padding: 20px; margin-bottom: 20px; }
  .score-number    { font-size: 2.6em; }
  #score-bar-wrapper { height: 10px; }
}

/* ================================================================
   11. RISK CARD
   ================================================================ */
.risk-card {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
  border-left: 4px solid;
}
.risk-card.baixo  { background: rgba(16,185,129,0.08);  border-color: var(--accent);  color: var(--accent-dark); }
.risk-card.medio  { background: rgba(245,158,11,0.10);  border-color: var(--warning); color: #92400E; }
.risk-card.alto   { background: rgba(239,68,68,0.09);   border-color: var(--danger);  color: #991B1B; }
.dark .risk-card.baixo { color: var(--accent); }
.dark .risk-card.medio { color: var(--warning); }
.dark .risk-card.alto  { color: var(--danger); }

/* ================================================================
   12. BUTTONS
   ================================================================ */
.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  transition:
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    opacity var(--dur);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(255,122,0,0.22);
}
.btn.primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-primary); }

.btn.primary-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn.primary-outline:hover { background: var(--primary-glow); }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-2); }

.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover { background: #DC2626; }

.btn.danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn.danger-outline:hover { background: var(--danger-light); }

.btn.disabled,
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Icon button */
.icon-btn {
  background: transparent;
  border: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur), transform var(--dur);
  color: var(--muted);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover  { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn i      { font-size: 1em; }
.primary-icon    { color: var(--primary) !important; }
.danger-icon     { color: var(--danger)  !important; }

/* Header add-debt button — icon only on mobile */
#add-debt-button-header {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
#add-debt-button-header span { display: none; }
@media (min-width: 640px) {
  #add-debt-button-header { width: auto; height: auto; padding: 9px 14px; }
  #add-debt-button-header span { display: inline; }
}

/* ================================================================
   13. INPUTS
   ================================================================ */
.input,
.select-filter {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color var(--dur), box-shadow var(--dur);
  appearance: none;
  -webkit-appearance: none;
}
.input:focus,
.select-filter:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

.settings-select{
  background: var(--input-bg);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 10px 13px;
  border: 1.5px solid var(--input-border);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.label-field {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: block;
}
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }

/* Input group (auth screens) */
.input-group {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.90);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255,255,255,0.40);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.input-group:focus-within {
  border-color: rgba(255,255,255,0.80);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
}
.input-group i        { margin-right: 10px; color: var(--primary); flex-shrink: 0; }
.input-group input    { border: none; background: transparent; width: 100%; font-size: 15px; outline: none; color: #1a1a1a; }
.input-group input::placeholder { color: #999; }

/* Radio group */
.radio-group { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 3px; }
.radio-label {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--input-bg);
  transition: all var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 700;
}
.radio-label input { margin-right: 5px; accent-color: var(--primary); }

/* ================================================================
   14. DEBT CARDS
   ================================================================ */
.debt-list { display: flex; flex-direction: column; gap: 9px; }
.styled-list { padding: 0; }

.debt-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
  /* Prevent overflow */
  max-width: 100%;
  min-width: 0;
}
.debt-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
}
.debt-card.open::before    { background: var(--primary); }
.debt-card.overdue::before { background: var(--danger); }
.debt-card.paid::before    { background: var(--accent); }
.debt-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.debt-card.overdue {
  background: rgba(239,68,68,0.04);
  border-color: rgba(239,68,68,0.18);
}
.debt-card.paid { opacity: 0.65; }
.dark .debt-card.overdue { background: rgba(239,68,68,0.07); }

.debt-info { flex: 1; min-width: 0; overflow: hidden; }
.debt-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
  flex-wrap: nowrap;
}
.debt-header h4 {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.debt-status {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.debt-status.open    { background: var(--primary-glow);              color: var(--primary);    }
.debt-status.overdue { background: var(--danger-light);              color: var(--danger);     }
.debt-status.paid    { background: rgba(16,185,129,0.12);            color: var(--accent-dark);}

.debt-category { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.debt-value    { font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }

.debt-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}
.debt-date {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.debt-actions .row { gap: 2px; }

/* Progress bar on debt cards */
.progress-bar {
  height: 3px;
  background: var(--border-strong);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 5px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s var(--ease);
}
.paid    .progress-fill { background: var(--accent); }
.overdue .progress-fill { background: var(--danger); }

/* Upcoming section: even more compact */
.upcoming-card .debt-card { padding: 9px 11px; }
.upcoming-card .debt-card h4 { font-size: 13px; }

/* ================================================================
   15. HOME LAYOUT
   ================================================================ */
.home-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.debt-chart-card {
  min-height: 230px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chart-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}
.upcoming-card {
  max-height: 270px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.upcoming-card::-webkit-scrollbar        { width: 3px; }
.upcoming-card::-webkit-scrollbar-track  { background: transparent; }
.upcoming-card::-webkit-scrollbar-thumb  { background: var(--border-strong); border-radius: 3px; }

@media (min-width: 640px) {
  .home-layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
  }
  .debt-chart-card { min-height: 340px; }
  .upcoming-card   { max-height: 340px; }
}

/* ================================================================
   16. DEBTS PAGE
   ================================================================ */
.debts-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
}
.debts-controls .select-filter { font-size: 13px; padding: 8px 10px; flex: 1; }

#add-debt-button-list { display: none; }
@media (min-width: 640px) {
  #add-debt-button-list { display: flex; }
}

#all-debts-list { overflow-y: auto; padding-bottom: 4px; }

/* ================================================================
   17. MODALS
   ================================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: modalBgIn 0.22s ease;
}
@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  width: 100%;
  max-width: 520px;
  /* leave space at top on mobile */
  max-height: min(92vh, calc(100vh - 20px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--surface);
  animation: sheetUp 0.30s var(--ease);
  padding-bottom: max(4px, var(--safe-b));
}
@keyframes sheetUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Drag handle */
.modal-panel::before {
  content: '';
  display: block;
  margin: 10px auto 0;
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
}

/* Desktop: centered dialog */
@media (min-width: 640px) {
  .modal { align-items: center; padding: 20px; }
  .modal-panel {
    border-radius: var(--radius-xl);
    max-height: 88vh;
    animation: modalIn 0.26s var(--ease);
  }
  .modal-panel::before { display: none; }
}
@keyframes modalIn {
  from { transform: scale(0.94) translateY(8px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);   opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }

.debt-modal-panel form { padding: 14px 18px 20px; }

/* ================================================================
   18. SETTINGS / ACCOUNT
   ================================================================ */
.info-list { display: flex; flex-direction: column; }

.detalsUser {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.detalsUser:last-child { border-bottom: none; }
.detalsUser .label { margin: 0; flex-shrink: 0; }
.detalsUser p:last-child {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.theme-toggle .label { margin: 0; flex: 1; }
.toggle-switch {
  position: relative;
  width: 42px; height: 23px;
  background: var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--dur);
  flex-shrink: 0;
}
.toggle-switch.active { background: var(--primary); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.20);
  transition: transform var(--dur) var(--ease);
}
.toggle-switch.active::after { transform: translateX(19px); }

/* ================================================================
   19. AUTH SCREEN
   ================================================================ */
.auth-wrapper {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #FF7A00 0%, #FF9B3D 50%, #FFB870 100%);
  padding:
    max(20px, var(--safe-t))
    max(20px, var(--safe-r))
    max(20px, var(--safe-b))
    max(20px, var(--safe-l));
  position: relative;
  overflow: hidden;
}
/* Decorative circles */
.auth-wrapper::before {
  content: '';
  position: absolute; top: -100px; right: -70px;
  width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  pointer-events: none;
}
.auth-wrapper::after {
  content: '';
  position: absolute; bottom: -80px; left: -50px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.auth-card-new {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 28px 22px;
  border: 1px solid rgba(255,255,255,0.28);
  box-shadow: 0 20px 60px rgba(0,0,0,0.16);
  position: relative;
  z-index: 1;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  margin: 0 auto 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.auth-header h1 { color: white; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.subtitle       { color: rgba(255,255,255,0.82); font-size: 14px; margin-top: 3px; }

.auth-section        { display: none; }
.auth-section.active { display: block; }
.auth-form { display: flex; flex-direction: column; gap: 11px; margin-top: 10px; }

.line { color: rgba(255,255,255,0.60); text-align: center; font-size: 12px; margin: 13px 0; letter-spacing: 0.1em; }

.btn.auth-submit {
  background: white;
  color: var(--primary);
  border-color: white;
  font-weight: 700;
  font-size: 15px;
  padding: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  width: 100%;
}
.btn.auth-submit:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.20); transform: translateY(-1px); }

.google-btn,
.anon-btn {
  width: 100%; padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur);
  -webkit-tap-highlight-color: transparent;
}
.google-btn {
  background: white; color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.google-btn:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.18); transform: translateY(-1px); }
.google-btn img { width: 18px; height: 18px; }

.anon-btn {
  background: rgba(255,255,255,0.18);
  color: white;
  border: 1px solid rgba(255,255,255,0.36);
  margin-top: 7px;
}
.anon-btn:hover { background: rgba(255,255,255,0.26); }
.anon-btn img   { width: 18px; height: 18px; border-radius: 50%; }

.switch-text { text-align: center; font-size: 13px; color: rgba(255,255,255,0.80); margin-top: 14px; }
.switch-btn  { background: none; border: none; color: white; font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: underline; }

.forgot-link { text-align: right; font-size: 12px; }
.forgot-link button { background: none; border: none; color: rgba(255,255,255,0.72); font-size: 12px; cursor: pointer; text-decoration: underline; }
.forgot-link button:hover { color: white; }

/* Extra small phones */
@media (max-width: 360px) {
  .auth-card-new { padding: 22px 16px; }
  .auth-header h1 { font-size: 22px; }
  .auth-logo { width: 52px; height: 52px; }
}

/* ================================================================
   20. TOAST
   ================================================================ */
.toast-container {
  position: fixed;
  top: max(14px, var(--safe-t));
  left: 50%; transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 88%;
  max-width: 360px;
}
.toast {
  background: rgba(15,23,42,0.94);
  color: white;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.20);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  pointer-events: auto;
  animation: toastIn 0.36s var(--ease);
}
.toast-success { background: rgba(16,185,129,0.95); }
.toast-danger  { background: rgba(239,68,68,0.95); }
.toast-warning { background: rgba(245,158,11,0.95); }
.toast-info    { background: rgba(59,130,246,0.95); }
.toast.hide    { animation: toastOut 0.28s ease forwards; }
@keyframes toastIn  { from { transform: translateY(-16px) scale(0.95); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to   { transform: translateY(-12px) scale(0.95); opacity: 0; } }

/* ================================================================
   21. SPLASH & LOADING
   ================================================================ */
.splash {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: linear-gradient(150deg, #FF7A00, #FF9B3D);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  animation: fadeOut 0.6s ease 2.2s forwards;
}
.splash h1        { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; margin-top: 10px; }
.splash-icon      { width: 80px; height: 80px; border-radius: 20px; box-shadow: 0 12px 30px rgba(0,0,0,0.18); }
.splash-tagline   { font-size: 13px; opacity: 0.75; margin-top: 5px; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  transition: opacity 0.4s;
}
.loader {
  width: 42px; height: 42px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
.loading-screen p { font-size: 14px; }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@keyframes fadeIn  { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ================================================================
   22. BIOMETRIC MODAL
   ================================================================ */
.bio-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.bio-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.30s var(--ease);
}
.bio-icon svg { width: 60px; height: 60px; margin-bottom: 14px; }
.bio-content h2 { margin-bottom: 8px; }
.bio-text  { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 22px; }
.bio-btn   { width: 100%; padding: 12px; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px; cursor: pointer; border: none; margin-bottom: 9px; }
.bio-btn.primary   { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(255,122,0,0.28); }
.bio-btn.secondary { background: var(--surface-2); color: var(--muted); }

/* ================================================================
   23. ONBOARDING
   ================================================================ */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2,6,23,0.70);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.onboarding-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px 22px;
  text-align: center;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.34s var(--ease);
}
.onboarding-step-icon { font-size: 3em; margin-bottom: 14px; }
.onboarding-card h2   { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.onboarding-card p    { color: var(--muted); font-size: 14px; line-height: 1.65; }
.onboarding-dots { display: flex; justify-content: center; gap: 7px; margin: 20px 0; }
.onboarding-dot  {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong);
  transition: all var(--dur) var(--ease);
}
.onboarding-dot.active { background: var(--primary); width: 22px; border-radius: 4px; }
.onboarding-actions    { display: flex; flex-direction: column; gap: 9px; }

/* ================================================================
   24. FORECAST PAGE
   ================================================================ */
.forecast-list { display: flex; flex-direction: column; gap: 5px; }
.forecast-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background var(--dur);
}
.forecast-row.current-month {
  background: var(--primary-glow);
  border-color: rgba(255,122,0,0.28);
  font-weight: 600;
}
.forecast-row.past-month { opacity: 0.45; }
.forecast-month  { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.forecast-amount { font-weight: 700; font-size: 14px; color: var(--primary); }
.badge-current   {
  font-size: 9px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
#payoff-tip-card { border-left: 4px solid var(--primary); }
#payoff-tip-card h3 { font-size: 14px; }
#payoff-tip-text { font-size: 13px; line-height: 1.6; color: var(--text-2); margin-top: 7px; }

/* ================================================================
   25. MICRO INTERACTIONS & SPECIAL STATES
   ================================================================ */
.pressed { transform: scale(0.97) !important; opacity: 0.88 !important; }

.micro-success .debt-card.paid {
  animation: pulseSuccess 0.5s ease;
}
@keyframes pulseSuccess {
  0%,100% { box-shadow: none; }
  50%      { box-shadow: 0 0 0 4px rgba(16,185,129,0.30); }
}

.emergency-mode .app-header { border-bottom-color: var(--danger); }
.emergency-mode .mobile-nav  { border-top-color: var(--danger); }

/* ================================================================
   26. CONFETTI
   ================================================================ */
.confetti-piece {
  position: fixed;
  width: 10px; height: 10px;
  pointer-events: none;
  z-index: 10000;
  border-radius: 2px;
  animation: confettiFall var(--fall-dur, 1.2s) ease-in forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(var(--fall-y, 400px)) rotate(var(--rot, 360deg)) scale(0.5); opacity: 0; }
}

/* ================================================================
   27. SCROLLBAR
   ================================================================ */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

/* ================================================================
   28. PWA UPDATE BAR
   ================================================================ */
.pwa-update-bar {
  position: fixed;
  bottom: calc(var(--nav-h) + max(8px, var(--safe-b)) + 8px);
  left: 50%; transform: translateX(-50%);
  z-index: 9998;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  width: calc(100% - 32px); max-width: 420px;
  animation: slideUpBar 0.36s var(--ease);
}
@media (min-width: 640px) {
  .pwa-update-bar { bottom: 20px; width: auto; }
}
@keyframes slideUpBar {
  from { transform: translateX(-50%) translateY(120%); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}
.pwa-update-bar .pwa-icon { font-size: 1.5em; flex-shrink: 0; }
.pwa-update-bar .pwa-text { flex: 1; min-width: 0; }
.pwa-update-bar .pwa-text strong { font-size: 13px; font-weight: 700; display: block; }
.pwa-update-bar .pwa-text span   { font-size: 11px; color: var(--muted); }
.pwa-update-bar .pwa-actions     { display: flex; gap: 6px; flex-shrink: 0; }
.pwa-update-bar .btn             { padding: 6px 12px; font-size: 12px; }

/* ================================================================
   29. TYPOGRAPHY HELPERS
   ================================================================ */
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }

/* ================================================================
   30. EMPTY STATE
   ================================================================ */
#all-debts-list .card.p {
  padding: 28px 20px;
  text-align: center;
}

/* ================================================================
   31. DARK MODE INPUT FIXES
   ================================================================ */
.dark .input-group {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}
.dark .input-group input       { color: var(--text); }
.dark .input-group input::placeholder { color: var(--muted); }
.dark .input-group i           { color: var(--primary-light); }

/* ================================================================
   32. IA FINANCEIRA — Assistente & Chat
   ================================================================ */

/* Grid de dicas rápidas */
.ai-tips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 0;
}
@media (max-width: 360px) { .ai-tips-grid { grid-template-columns: 1fr; } }

.ai-tip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .2s, box-shadow .2s;
}
.ai-tip-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.ai-tip-card .tip-icon { font-size: 22px; line-height: 1; }
.ai-tip-card .tip-title { font-size: 12px; font-weight: 700; color: var(--text); line-height: 1.3; }
.ai-tip-card .tip-text  { font-size: 11px; color: var(--muted); line-height: 1.5; }
.ai-tip-card.critical { border-left: 3px solid var(--danger); }
.ai-tip-card.warning  { border-left: 3px solid var(--warning); }
.ai-tip-card.info     { border-left: 3px solid var(--primary); }
.ai-tip-card.success  { border-left: 3px solid #22c55e; }

/* Cabeçalho do card de análise */
.ai-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 10px;
}
.btn.sm { padding: 6px 14px; font-size: 12px; white-space: nowrap; }

/* Resultado da análise */
.ai-result { margin-top: 12px; }
.ai-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--bg-app);
  border-radius: calc(var(--radius) - 2px);
  padding: 14px;
  border: 1px solid var(--border);
}

/* Loading animado */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 4px;
  font-size: 13px;
  color: var(--muted);
}
.ai-pulse {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--primary);
  animation: ai-pulse-anim 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ai-pulse-anim {
  0%, 100% { transform: scale(1); opacity: .8; }
  50%       { transform: scale(1.4); opacity: 1; }
}

/* Chat IA */
.ai-chat-messages {
  min-height: 120px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 12px;
  scroll-behavior: smooth;
}
.ai-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  gap: 3px;
}
.ai-chat-msg.user  { align-self: flex-end; align-items: flex-end; }
.ai-chat-msg.assistant { align-self: flex-start; align-items: flex-start; }
.ai-chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.ai-chat-msg.user .ai-chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg.assistant .ai-chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-chat-msg .ai-chat-time {
  font-size: 10px;
  color: var(--muted);
  padding: 0 4px;
}
.ai-chat-typing .ai-chat-bubble {
  display: flex; align-items: center; gap: 5px; padding: 12px 16px;
}
.ai-typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce .9s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: .15s; }
.ai-typing-dot:nth-child(3) { animation-delay: .30s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Chips de sugestão */
.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}
.ai-suggestion-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  font-family: inherit;
}
.ai-suggestion-chip:hover {
  background: rgba(var(--primary-rgb, 255,122,0), .08);
  border-color: var(--primary);
}

/* Input do chat */
.ai-chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.ai-chat-input-wrap .input { flex: 1; font-size: 14px; }
.ai-chat-input-wrap .icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Score breakdown */
.ai-score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.score-factor {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.score-factor-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text);
}
.score-factor-label span:last-child { color: var(--muted); font-size: 12px; }
.score-factor-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.score-factor-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .6s ease;
}
.score-factor-fill.good     { background: #22c55e; }
.score-factor-fill.warning  { background: var(--warning, #f59e0b); }
.score-factor-fill.danger   { background: var(--danger); }

/* mr-s helper */
.mr-s { margin-right: 6px; }

/* ================================================================
   34. USER AVATAR BUTTON (header)
   ================================================================ */
.header-actions { align-items: center; gap: 6px; }

.user-avatar-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--primary-light);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.user-avatar-btn:hover { transform: scale(1.08); box-shadow: 0 0 0 3px var(--primary-glow); }
.user-avatar-btn img  { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-avatar-badge {
  position: absolute; top: -2px; right: -2px;
  width: 10px; height: 10px;
  border-radius: 50%; background: var(--danger);
  border: 2px solid var(--surface);
}

/* ================================================================
   35. PROFILE DRAWER
   ================================================================ */
.profile-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
.profile-overlay.hidden { display: none; }

.profile-drawer {
  position: fixed; top: 0; right: 0;
  width: min(360px, 92vw);
  height: 100dvh;
  background: var(--surface);
  z-index: 301;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.18);
  transform: translateX(0);
  transition: transform .3s var(--ease);
  overflow: hidden;
}
.profile-drawer.hidden { display: none; }
.profile-drawer.slide-in  { animation: drawerSlideIn .3s var(--ease) both; }
.profile-drawer.slide-out { animation: drawerSlideOut .25s ease both; }
@keyframes drawerSlideIn  { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes drawerSlideOut { from { transform: translateX(0); } to { transform: translateX(100%); } }

/* Drawer header */
.profile-drawer-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary-glow), transparent);
  flex-shrink: 0;
}
.profile-drawer-user { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }

/* Big avatar */
.profile-big-avatar {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  border: 3px solid var(--primary-light);
  overflow: visible;
}
.profile-big-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
  position: absolute; inset: 0;
}
.avatar-upload-label {
  position: absolute; bottom: -2px; right: -2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; font-size: 9px;
  z-index: 2;
  transition: background .15s;
}
.avatar-upload-label:hover { background: var(--primary-dark); }

.profile-drawer-info { min-width: 0; flex: 1; }
.profile-drawer-name  { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-drawer-email { font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-drawer-score {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 12px; font-weight: 700;
}

/* Quick action buttons */
.profile-quick-actions {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.profile-quick-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  cursor: pointer; font-family: inherit;
  font-size: 10px; color: var(--text);
  transition: background .15s, border-color .15s, transform .1s;
}
.profile-quick-btn:hover  { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.profile-quick-btn:active { transform: scale(.96); }
.pqa-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

/* Drawer body */
.profile-drawer-body { flex: 1; overflow-y: auto; }
.drawer-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--primary); margin-bottom: 10px;
}
.drawer-row {
  display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
  padding: 8px 0;
}
.drawer-row-info { display: flex; flex-direction: column; gap: 2px; }
.drawer-row-label { font-size: 14px; color: var(--text); }
.drawer-action-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; background: none; border: none;
  padding: 11px 0; cursor: pointer; font-family: inherit;
  font-size: 14px; color: var(--text);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.drawer-action-btn:last-child { border-bottom: none; }
.drawer-action-btn i:first-child { width: 18px; text-align: center; color: var(--primary); }
.drawer-action-btn span { flex: 1; }
.drawer-action-btn:hover { color: var(--primary); }
.drawer-action-btn.disabled { opacity: .45; pointer-events: none; }
.mt-s { margin-top: 6px !important; }

/* ================================================================
   36. THEME PALETTE SELECTOR
   ================================================================ */
.theme-palette-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 4px;
}
.palette-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  cursor: pointer; font-family: inherit;
  font-size: 12px; color: var(--muted);
  transition: all .15s;
}
.palette-btn:hover { border-color: var(--primary); color: var(--text); }
.palette-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); font-weight: 600; }
.palette-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }

/* ================================================================
   37. CURRENCY GRID
   ================================================================ */
.currency-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.currency-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.currency-btn:hover  { border-color: var(--primary); }
.currency-btn.active { border-color: var(--primary); background: var(--primary-glow); }
.currency-symbol { font-size: 18px; font-weight: 700; color: var(--text); }
.currency-name   { font-size: 11px; color: var(--muted); }
.currency-rate   { font-size: 10px; color: var(--primary); font-weight: 600; margin-top: 2px; }

/* ================================================================
   38. HISTORY PAGE
   ================================================================ */
.history-filters {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.history-filter-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px; color: var(--muted);
  cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.history-filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.history-filter-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

.history-summary-cards {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 8px; margin-bottom: 14px;
}
.history-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px; text-align: center;
}
.history-summary-card .hsc-value { font-size: 16px; font-weight: 700; color: var(--primary); }
.history-summary-card .hsc-label { font-size: 10px; color: var(--muted); margin-top: 2px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: transform .15s;
}
.history-item:hover { transform: translateX(2px); }
.history-item-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(16,185,129,.12);
  color: #10B981;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.history-item-info { flex: 1; min-width: 0; }
.history-item-name  { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-date  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.history-item-amount { font-size: 15px; font-weight: 700; color: #10B981; white-space: nowrap; }

/* ================================================================
   39. REMINDERS PAGE
   ================================================================ */
.reminders-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.reminders-list { display: flex; flex-direction: column; gap: 10px; }
.reminder-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.reminder-item:last-child { border-bottom: none; }
.reminder-item-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-glow); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.reminder-item-info { flex: 1; min-width: 0; }
.reminder-item-title { font-size: 14px; font-weight: 600; color: var(--text); }
.reminder-item-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.reminder-item-actions { display: flex; gap: 6px; }
.reminder-toggle { cursor: pointer; }
.reminder-delete-btn {
  background: none; border: none; cursor: pointer;
  color: var(--danger); font-size: 13px; padding: 4px;
}

/* ================================================================
   40. COLOR THEMES (palettes applied to :root)
   ================================================================ */
/* Blue theme */
html[data-theme="blue"] { --primary: #3B82F6; --primary-dark: #2563EB; --primary-light: #60A5FA; --primary-glow: rgba(59,130,246,.15); --shadow-primary: 0 6px 20px rgba(59,130,246,.3); }
html[data-theme="blue"].dark { --primary: #60A5FA; --primary-dark: #3B82F6; --primary-light: #93C5FD; --primary-glow: rgba(96,165,250,.15); }
/* Purple theme */
html[data-theme="purple"] { --primary: #8B5CF6; --primary-dark: #7C3AED; --primary-light: #A78BFA; --primary-glow: rgba(139,92,246,.15); --shadow-primary: 0 6px 20px rgba(139,92,246,.3); }
html[data-theme="purple"].dark { --primary: #A78BFA; --primary-dark: #8B5CF6; --primary-light: #C4B5FD; --primary-glow: rgba(167,139,250,.15); }
/* Green theme */
html[data-theme="green"] { --primary: #10B981; --primary-dark: #059669; --primary-light: #34D399; --primary-glow: rgba(16,185,129,.15); --shadow-primary: 0 6px 20px rgba(16,185,129,.3); }
html[data-theme="green"].dark { --primary: #34D399; --primary-dark: #10B981; --primary-light: #6EE7B7; --primary-glow: rgba(52,211,153,.15); }
/* Rose theme */
html[data-theme="rose"] { --primary: #F43F5E; --primary-dark: #E11D48; --primary-light: #FB7185; --primary-glow: rgba(244,63,94,.15); --shadow-primary: 0 6px 20px rgba(244,63,94,.3); }
html[data-theme="rose"].dark { --primary: #FB7185; --primary-dark: #F43F5E; --primary-light: #FDA4AF; --primary-glow: rgba(251,113,133,.15); }
/* Orange (default) — no override needed */


/* ================================================================
   41. ✅ NOVO: PAINEL DE ORÇAMENTO (RENDA x DÍVIDAS) — Previsão
   ================================================================ */
.income-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.income-input-row .input-with-prefix {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  overflow: hidden;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.income-input-row .input-with-prefix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input-with-prefix .input-prefix {
  padding: 0 10px;
  font-weight: 700;
  color: var(--muted);
  font-size: 14px;
  flex-shrink: 0;
}
.input-with-prefix input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 13px 10px 0;
  font-size: 15px;
  color: var(--text);
  outline: none;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.income-input-row .btn { flex-shrink: 0; white-space: nowrap; }
.income-input-row .btn.ghost { padding: 10px 14px; }

#budget-result .progress-bar { height: 8px; margin-top: 8px; }
#budget-result .progress-fill { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }

.budget-result-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.budget-result-header .budget-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.budget-result-header h4 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}
.budget-figures {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.budget-figures strong { color: var(--text); }

/* Faixas de risco do orçamento — cor de destaque por nível */
#budget-panel.budget-saudavel       .progress-fill { background: var(--accent); }
#budget-panel.budget-atencao        .progress-fill { background: var(--info); }
#budget-panel.budget-critico        .progress-fill { background: var(--warning); }
#budget-panel.budget-risco_falencia .progress-fill { background: var(--danger); }

#budget-panel.budget-saudavel       .budget-result-header h4 { color: var(--accent); }
#budget-panel.budget-atencao        .budget-result-header h4 { color: var(--info); }
#budget-panel.budget-critico        .budget-result-header h4 { color: var(--warning); }
#budget-panel.budget-risco_falencia .budget-result-header h4 { color: var(--danger); }

#budget-panel.budget-risco_falencia {
  border: 1.5px solid var(--danger);
  background: var(--danger-light);
}
#budget-panel.budget-critico {
  border: 1.5px solid var(--warning);
}

/* ================================================================
   42. ✅ NOVO: BADGE DE NOTIFICAÇÃO NO MENU (mensagem do agente IA)
   ================================================================ */
.nav-badge-dot {
  position: absolute;
  top: 6px;
  right: 22%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
  animation: badge-pulse 1.8s infinite;
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.7; }
}

/* ── Mensagem proativa do agente IA no chat ── */
.ai-chat-msg.proactive .ai-chat-bubble {
  border: 1px solid var(--primary);
  background: var(--primary-glow);
}
.ai-chat-proactive-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
