/* =============================================================
   Dashboard Financeiro · Mercury/Ramp dark theme
   ============================================================= */

:root,
[data-theme="minerva-dark"] {
  /* superfícies — neutras, sem tom vermelho */
  --bg:            #0B0D10;
  --bg-2:          #0F1216;
  --surface:       #13171C;
  --surface-2:     #171C22;
  --surface-3:     #1C2128;
  --surface-input: #14191F;
  --surface-tip:   #0F1318;

  /* cards (compat com nomes antigos) */
  --card:          #13171C;
  --card-2:        #171C22;
  --card-solid:    #13171C;
  --card-2-solid:  #1C2128;
  --surface-glass: #13171C;

  /* bordas */
  --border:        rgba(255,255,255,0.07);
  --border-soft:   rgba(255,255,255,0.045);
  --border-strong: rgba(255,255,255,0.12);

  /* texto */
  --text:          #E8EAED;
  --text-dim:      rgba(232,234,237,0.72);
  --text-muted:    rgba(232,234,237,0.46);
  --text-faint:    rgba(232,234,237,0.32);

  /* paleta semântica — fintech */
  --accent:        #10B981;     /* esmeralda — ação primária / positivo */
  --accent-hover:  #0EA372;
  --accent-on:     #FFFFFF;
  --accent-soft:   rgba(16,185,129,0.10);
  --accent-soft-2: rgba(16,185,129,0.18);

  --good:          #10B981;     /* verde positivo */
  --bad:           #F43F5E;     /* rose negativo */
  --warn:          #F59E0B;     /* âmbar */
  --info:          #3B82F6;     /* azul */
  --accent-2:      #3B82F6;
  --accent-3:      #F59E0B;

  /* tons por seção — sutis, só pra indicar identidade */
  --tone-income:   #3B82F6;   /* azul — entradas/renda */
  --tone-invest:   #14B8A6;   /* teal — poupança/cofrinho */
  --tone-card:     #F59E0B;   /* âmbar — cartões/dívida */
  --tone-fixed:    #8B5CF6;   /* violeta — fixos */
  --tone-spending: #F43F5E;   /* rose — gastos totais */
  --tone-balance:  #10B981;   /* esmeralda — saldo positivo */
  --tone-mes:      #F472B6;   /* rosa — gastos do mês */
  --tone-vale:     #FB923C;   /* laranja — vale alimentação */

  /* sombras — bem discretas, padrão financeiro */
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.02) inset, 0 1px 2px rgba(0,0,0,0.28);
  --shadow-md: 0 1px 0 rgba(255,255,255,0.02) inset, 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.55);
  --shadow-glow-accent: 0 6px 16px -8px rgba(16,185,129,0.45);

  /* raios — mais quadrados */
  --radius:    10px;
  --radius-lg: 14px;
  --radius-sm: 8px;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* glows do fundo — quase imperceptíveis */
  --gradient-glow-1: rgba(16,185,129,0.025);
  --gradient-glow-2: rgba(59,130,246,0.020);

  /* tipografia — uma só família humanista + mono pra números */
  --font-base:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; }

body {
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

button { font-family: inherit; cursor: pointer; background: none; border: 0; color: inherit; }
input, select, textarea { font-family: inherit; color: var(--text); }

button,
a,
.list-item,
.compra-item,
.import-result-item,
.kpi,
.cartao,
.cof-list-item {
  transition-duration: 0.2s;
}

.page-fade { opacity: 0; transition: opacity .35s var(--ease-out); }
.page-fade.is-ready { opacity: 1; }
.page-fade.is-leaving { opacity: 0; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
  color: var(--accent-on);
  font-weight: 600; padding: 12px 16px;
  border-radius: var(--radius-sm); font-size: 13.5px;
  transition: opacity .15s, transform .12s, box-shadow .2s;
  box-shadow: 0 4px 16px -4px rgba(16,185,129,0.50);
  border: 0; cursor: pointer; letter-spacing: -0.005em;
}
.btn-primary:hover   { opacity: .90; }
.btn-primary:active  { transform: scale(.988); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* =============================================================
   DASHBOARD
   ============================================================= */
.dashboard-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.route-view {
  width: 100%;
  min-height: 100vh;
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out), filter 0.28s var(--ease-out);
}
.route-view-leaving,
.route-view-enter {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(2px);
  pointer-events: none;
  will-change: opacity, transform;
}
.route-dashboard {
  display: flex;
  flex-direction: column;
}

.dashboard-body.dashboard-loading .main {
  display: none;
}
.dashboard-skeleton {
  display: grid;
  gap: 20px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}
.skeleton-grid {
  display: grid;
  gap: 14px;
}
.skeleton-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.skeleton-card,
.import-skeleton-line {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.skeleton-card {
  height: 220px;
}
.skeleton-card::after,
.import-skeleton-line::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
  animation: skeletonShimmer 1.2s infinite;
}
@keyframes skeletonShimmer {
  to { transform: translateX(100%); }
}

.toast-viewport {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 4000;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.app-toast {
  transform: translateY(10px);
  opacity: 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.app-toast.success {
  border-color: rgba(16,185,129,0.34);
  color: var(--good);
}
.app-toast.error {
  border-color: rgba(244,63,94,0.34);
  color: var(--bad);
}
.app-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ===== TOPBAR =====
   Dentro do .app-main, a topbar é STICKY (não fixed) — assim respeita
   a largura da coluna do main e não invade a sidebar. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  width: 100%;
  padding: 12px 28px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11,13,16,0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  margin-right: auto;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Back-link reutilizável (Projeções, Admin, etc) */
.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: color .15s, background .15s, border-color .15s;
}
.topbar-back:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.topbar-back svg { width: 14px; height: 14px; }

.topbar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-title svg { width: 16px; height: 16px; color: var(--accent); }

/* Grupos compactos de controles dentro da topbar (cenário, horizonte, etc) */
.topbar-ctrl-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-ctrl-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* Calendar picker */
.cal-picker { position: relative; }
.cal-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s;
}
.cal-trigger:hover { border-color: var(--border-strong); background: var(--surface-3); }
.cal-icon { color: var(--text-muted); display: inline-flex; }
.cal-icon svg { width: 15px; height: 15px; }
.cal-trigger-label { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; gap: 1px; }
.cal-month {
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 600;
  text-transform: capitalize;
  letter-spacing: -0.005em;
  color: var(--text);
}
.cal-year {
  font-size: 10.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.cal-caret { color: var(--text-faint); display: inline-flex; transition: transform .2s; }
.cal-caret svg { width: 12px; height: 12px; }
.cal-picker.open .cal-caret { transform: rotate(180deg); }

.cal-panel {
  position: absolute; top: calc(100% + 6px); right: 0; left: auto;
  transform: translateY(-4px);
  width: 300px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 30;
}
.cal-picker.open .cal-panel { opacity: 1; transform: translateY(0); pointer-events: auto; }
.cal-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 8px;
}
.cal-nav {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.cal-nav:hover { background: var(--surface-2); color: var(--text); }
.cal-nav svg { width: 13px; height: 13px; }
.cal-year-btn {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  transition: background .15s;
}
.cal-year-btn:hover { background: var(--surface-2); }

.cal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.cal-month-btn {
  padding: 10px 0;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px; font-weight: 500;
  color: var(--text-dim);
  text-transform: capitalize;
  transition: all .12s;
}
.cal-month-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}
.cal-month-btn.current {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
}
.cal-month-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px -2px rgba(16,185,129,0.55);
}

.cal-year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.cal-year-cell {
  padding: 10px 0;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  transition: all .12s;
}
.cal-year-cell:hover {
  color: var(--text);
  background: var(--surface-3);
}
.cal-year-cell.current { color: var(--accent); }
.cal-year-cell.active { background: var(--accent); color: white; }

.cal-foot { padding-top: 6px; display: flex; justify-content: center; }
.cal-today {
  font-size: 11.5px; color: var(--text-muted);
  padding: 5px 11px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.cal-today:hover { color: var(--text); background: var(--surface-2); }

.tb-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: color .15s, background .15s, border-color .15s, transform .12s;
}
.tb-icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}
.tb-icon-btn:active { transform: scale(.94); }
.tb-icon-btn svg { width: 16px; height: 16px; }

.tb-user { position: relative; }
.tb-user-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color .15s, background .15s;
}
.tb-user-btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.tb-user-btn svg { width: 12px; height: 12px; color: var(--text-faint); }
.tb-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), #059669);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: white;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.tb-name { font-size: 12.5px; font-weight: 500; color: var(--text-dim); }
.tb-user-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translateY(-4px);
  transition: opacity .18s, transform .18s;
  z-index: 30;
}
.tb-user.open .tb-user-menu { opacity: 1; pointer-events: auto; transform: translateY(0); }
.tb-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 11px;
  border-radius: 6px;
  font-size: 12.5px; color: var(--text-dim);
  transition: background .12s, color .12s;
}
.tb-menu-item:hover { background: var(--surface-2); color: var(--text); }
.tb-menu-item svg { width: 14px; height: 14px; }
/* Garante que o atributo `hidden` vença `display: flex` deste item */
.tb-menu-item[hidden] { display: none !important; }

/* ===== MAIN ===== */
.main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  padding: 18px 28px 40px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 -4px;
}
.section-title::before {
  content: ""; width: 3px; height: 12px;
  background: var(--accent);
  border-radius: 1px;
}

/* ===== INPUT CARDS ===== */
.inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}
.inputs-grid .span-2 { grid-column: span 2; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.input-card { display: flex; flex-direction: column; gap: 14px; height: 100%; }
.input-card.collapsed { align-self: start; height: auto; }

/* Tons sutis: só nos pontos de identidade, valor neutro */
.input-card[data-tone="income"] .ic-dot { background: var(--tone-income); }
.input-card[data-tone="invest"] .ic-dot { background: var(--tone-invest); }
.input-card[data-tone="card"]   .ic-dot { background: var(--tone-card); }
.input-card[data-tone="fixed"]  .ic-dot { background: var(--tone-fixed); }
.input-card[data-tone="mes"]    .ic-dot { background: var(--tone-mes); }
.input-card[data-tone="vale"]   .ic-dot { background: var(--tone-vale); }
.input-card[data-tone="income"] .ic-total { color: var(--tone-income); }
.input-card[data-tone="invest"] .ic-total { color: var(--tone-invest); }
.input-card[data-tone="card"]   .ic-total { color: var(--tone-card); }
.input-card[data-tone="fixed"]  .ic-total { color: var(--tone-fixed); }
.input-card[data-tone="mes"]    .ic-total { color: var(--tone-mes); }
.input-card[data-tone="vale"]   .ic-total { color: var(--tone-vale); }

.ic-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.ic-head[data-section-toggle] { cursor: pointer; }
.ic-head[data-section-toggle]:hover .ic-title h2 { color: var(--text); }
.input-card.collapsed .ic-body { display: none; }
.input-card.collapsed .segmented-control,
.input-card.collapsed .btn-section-plus { display: none; }
.input-card.collapsed .ic-head { flex-wrap: nowrap; }
.input-card.collapsed .renda-head-actions {
  width: auto;
  margin-left: auto;
  justify-content: flex-end;
}
.ic-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ic-title h2 {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-dim);
}
.ic-dot { width: 7px; height: 7px; border-radius: 50%; }
.ic-head-right { display: flex; align-items: center; gap: 10px; }
.ic-total {
  font-family: var(--font-mono);
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.ic-body { display: flex; flex-direction: column; gap: 14px; }
.ic-field { display: flex; flex-direction: column; gap: 5px; }
.ic-field > label {
  font-size: 10.5px; color: var(--text-muted);
  font-weight: 500; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.renda-head-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: color-mix(in srgb, var(--surface-2) 85%, #000);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15) inset;
}
.seg-btn {
  position: relative;
  min-height: 26px;
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
  transition: color .15s ease, background .2s ease, transform .12s ease;
}
.seg-btn:hover:not(.active) {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.seg-btn:active { transform: scale(0.97); }
.seg-btn.active {
  color: var(--text);
  background: linear-gradient(180deg,
              color-mix(in srgb, var(--surface-3) 80%, var(--accent) 10%) 0%,
              var(--surface-3) 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 1px 3px rgba(0,0,0,0.35),
    0 0 0 1px color-mix(in srgb, var(--accent, #3B82F6) 22%, transparent);
}
.seg-btn:focus-visible {
  outline: 2px solid var(--accent, #3B82F6);
  outline-offset: 1px;
}
.renda-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.renda-view[hidden] { display: none; }
.input-card[data-tone="income"] .ic-body { flex: 1; }

/* money input */
.money-input {
  display: flex; align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  padding: 0 2px;
  transition: border-color .15s, box-shadow .15s;
}
.money-input:focus-within {
  border-bottom-color: var(--accent);
  background: transparent;
  box-shadow: none;
}
.money-prefix { color: var(--text-faint); font-size: 12px; margin-right: 6px; user-select: none; font-weight: 500; }
.money-input input {
  flex: 1;
  min-width: 0;
  background: transparent !important;
  border: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  padding: 10px 0;
  font-size: 13.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  outline: none;
}

input[type="text"],
input[type="number"],
input[type="month"] {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  padding: 10px 2px;
  font-size: 13.5px;
  outline: none;
  color: var(--text);
  color-scheme: dark;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="month"]:focus {
  border-bottom-color: var(--accent);
  background: transparent;
  box-shadow: none;
}
input[type="number"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* select harmonizado com tema escuro */
select {
  color-scheme: dark;
  background-color: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  color: var(--text);
  padding: 10px 2px;
  font-size: 13px;
  transition: border-color .15s;
}
select:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
}
select option {
  background-color: var(--surface);
  color: var(--text);
}
.scope-select {
  width: max-content;
  max-width: 100%;
  align-self: flex-start;
  margin-top: 2px;
  padding: 4px 2px;
  color: var(--text-muted);
  font-size: 11px;
}
.scope-select:focus {
  color: var(--text);
}

/* Resumo clicável de rendas extras (substitui a lista inline). */
.rendas-extras-summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.rendas-extras-summary:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.rendas-extras-summary:active { transform: scale(0.99); }
.rendas-extras-summary .res-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.rendas-extras-summary .res-total {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.rendas-extras-summary .res-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.rendas-extras-summary .res-cta svg {
  width: 12px; height: 12px;
}
.rendas-extras-summary:hover .res-cta {
  color: var(--accent);
}

/* Modal de gerenciar rendas extras. */
.modal-content.modal-extras {
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-content.modal-extras .modal-sub-inline {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 6px;
}
.modal-content.modal-extras #rendaExtrasModalTotal {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--good, #10B981);
}
.modal-content.modal-extras .list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.modal-content.modal-extras .renda-extra-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 28px;
  gap: 10px;
  align-items: center;
}
.modal-content.modal-extras .renda-extra-desc {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: 5px;
  min-width: 0;
}
.modal-content.modal-extras .renda-extra-desc:hover {
  border-color: var(--border-soft);
}
.modal-content.modal-extras .renda-extra-desc:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-3);
}
.modal-content.modal-extras .renda-extra-tipo {
  font-size: 11px;
  padding: 3px 6px;
}
.modal-content.modal-extras .inline-add.inline-extra {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}


/* sub-section dentro do card */
.ic-sub { display: flex; flex-direction: column; gap: 7px; }
.ic-sub-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}
.ic-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* list items */
.list { display: flex; flex-direction: column; gap: 5px; }
.list-item {
  display: grid;
  /* Ordem padronizada: desc | valor | tend | categoria | X
     Colunas auto colapsam quando não há conteúdo, e o 1fr da desc absorve. */
  grid-template-columns: minmax(0, 1fr) auto auto auto 28px;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  min-height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.4;
  transition: border-color .12s, background .12s;
}
.list-item > * {
  align-self: center;
}
/* Fixa o X no extremo direito do item, mesmo quando badges faltam. */
.list-item .btn-x {
  grid-column: -1;
}
.list-item:hover { border-color: var(--border-strong); background: var(--surface-3); }
.list-item .li-desc { color: var(--text); }
.list-item .li-val {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

/* Valor editável inline (gasto fixo / mês / vale / contribuição).
   Visualmente igual ao .li-val, mas com hover sugerindo editabilidade. */
.li-val-editable {
  background: transparent;
  border: 1px dashed transparent;
  padding: 1px 6px;
  border-radius: 5px;
  cursor: text;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  transition: border-color .12s, background .12s, color .12s;
}
.li-val-editable:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
}
.li-val-editable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.li-val-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-3);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 1px 6px;
}
.li-val-edit-wrap .money-prefix {
  color: var(--text-faint);
  font-size: 11px;
}
.li-val-edit-wrap .li-val-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  width: 90px;
  padding: 0;
}

/* Wrapper clicável que abre modal de edição de compra (descrição vira link). */
.compra-edit-trigger {
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.compra-edit-trigger:hover { color: var(--accent); text-decoration: underline; }

/* Ícone compacto de tendência (variação vs mês anterior).
   Apenas glyph, sem box. Cor semântica por estado. */
.tendencia-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  user-select: none;
  transition: transform .12s ease;
}
.tendencia-icon:hover,
.tendencia-icon:focus-visible {
  transform: scale(1.2);
  outline: none;
}
.tendencia-icon.up    { color: var(--bad,  #F43F5E); }
.tendencia-icon.down  { color: var(--good, #10B981); }
.tendencia-icon.stable {
  color: var(--text-faint);
  font-size: 14px;
}
.rich-tooltip {
  position: fixed;
  z-index: 5000;
  max-width: min(280px, calc(100vw - 20px));
  padding: 9px 10px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), transparent 58%),
    var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 34px rgba(0,0,0,0.48), 0 1px 0 rgba(255,255,255,0.05) inset;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.35;
  pointer-events: none;
  white-space: normal;
}
.rich-tooltip[hidden] { display: none; }
.rich-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transform: translateX(-50%) rotate(45deg);
}
.rich-tooltip[data-placement="top"]::after {
  bottom: -5px;
  border-left: 0;
  border-top: 0;
}
.rich-tooltip[data-placement="bottom"]::after {
  top: -5px;
  border-right: 0;
  border-bottom: 0;
}
.rich-tooltip-title {
  font-weight: 700;
  color: var(--text);
}
.rich-tooltip-body {
  display: grid;
  gap: 2px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart-canvas-wrap .chart-rich-tooltip {
  position: absolute;
  z-index: 20;
  max-width: min(280px, calc(100% - 16px));
  padding: 9px 10px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), transparent 58%),
    var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 34px rgba(0,0,0,0.48), 0 1px 0 rgba(255,255,255,0.05) inset;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.35;
  pointer-events: none;
  white-space: normal;
}
.chart-canvas-wrap .chart-rich-tooltip[hidden] { display: none; }
.chart-canvas-wrap .chart-rich-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transform: translateX(-50%) rotate(45deg);
}
.chart-canvas-wrap .chart-rich-tooltip[data-placement="top"]::after {
  bottom: -5px;
  border-left: 0;
  border-top: 0;
}
.chart-canvas-wrap .chart-rich-tooltip[data-placement="bottom"]::after {
  top: -5px;
  border-right: 0;
  border-bottom: 0;
}
.chart-rich-tooltip-title {
  font-weight: 700;
  color: var(--text);
}
.chart-rich-tooltip-body {
  display: grid;
  gap: 3px;
}
.chart-rich-tooltip-title + .chart-rich-tooltip-body {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
}
.chart-rich-tooltip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart-rich-tooltip-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  flex: 0 0 auto;
}
.list-item.empty {
  display: block; text-align: center;
  color: var(--text-faint); font-style: normal;
  padding: 14px; font-size: 12px;
  background: transparent;
  border-style: dashed;
}

.btn-x {
  width: 22px; height: 22px; border-radius: 5px;
  display: grid; place-items: center;
  color: var(--text-faint);
  transition: color .12s, background .12s;
}
.btn-x:hover { color: var(--bad); background: rgba(244,63,94,0.10); }
.btn-x svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }

.inline-add { display: grid; gap: 8px; align-items: end; }
.inline-2 { grid-template-columns: 1.6fr 1fr auto; }
.inline-extra { grid-template-columns: 1.4fr 1fr 130px auto; }
@media (max-width: 760px) {
  .inline-extra {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .inline-extra > input[type="text"] { grid-column: 1 / -1; }
  .inline-extra > .money-input { grid-column: 1; }
  .inline-extra > .cat-select { grid-column: 1 / -1; }
  .inline-extra > .btn-add { grid-column: 2; grid-row: 2; }
}

/* Badges de tipo de renda extra */
.extra-tipo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
  min-width: 110px;
}
.extra-tipo-badge.t-freela    { background: rgba(16,185,129,0.10);  color: #34D399; border-color: rgba(16,185,129,0.22); }
.extra-tipo-badge.t-bonus     { background: rgba(245,158,11,0.10);  color: #FBBF24; border-color: rgba(245,158,11,0.22); }
.extra-tipo-badge.t-13o       { background: rgba(59,130,246,0.10);  color: #60A5FA; border-color: rgba(59,130,246,0.22); }
.extra-tipo-badge.t-ferias    { background: rgba(20,184,166,0.10);  color: #2DD4BF; border-color: rgba(20,184,166,0.22); }
.extra-tipo-badge.t-reembolso { background: rgba(125,211,252,0.10); color: #7DD3FC; border-color: rgba(125,211,252,0.22); }
.extra-tipo-badge.t-presente  { background: rgba(139,92,246,0.10);  color: #A78BFA; border-color: rgba(139,92,246,0.22); }

/* inline-add com select de categoria */
.inline-add.inline-2:has(.cat-select) {
  grid-template-columns: 1.6fr 1fr 140px auto;
}
@media (max-width: 760px) {
  .inline-add.inline-2:has(.cat-select) {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .inline-add.inline-2:has(.cat-select) > input[type="text"] { grid-column: 1 / -1; }
  .inline-add.inline-2:has(.cat-select) > .money-input { grid-column: 1; }
  .inline-add.inline-2:has(.cat-select) > .cat-select { grid-column: 1 / -1; }
  .inline-add.inline-2:has(.cat-select) > .btn-add { grid-column: 2; grid-row: 2; }
}

.btn-add {
  width: 32px; height: 32px;
  background: transparent;
  color: var(--accent);
  border: 0;
  border-radius: 0;
  font-size: 22px; font-weight: 300; line-height: 1;
  display: inline-grid;
  place-items: center;
  transition: color .15s, transform .1s, opacity .15s;
  box-shadow: none;
}
.btn-add:hover { color: var(--accent-hover); background: transparent; }
.btn-add:active { transform: scale(.92); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-dim);
  font-weight: 500;
  transition: all .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }

.btn-section-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transition: color .12s, transform .1s;
}
.btn-section-plus:hover {
  color: var(--text);
  background: transparent;
}
.btn-section-plus:active { transform: scale(.92); }

.btn-danger {
  background: transparent; border: 0;
  color: var(--text-muted); padding: 5px 8px;
  border-radius: 5px; font-size: 12px;
  transition: color .12s, background .12s;
}
.btn-danger:hover { color: var(--bad); background: rgba(244,63,94,0.10); }

/* cofrinho summary */

/* ===== CARTÕES ===== */
.cartoes-container { display: flex; flex-direction: column; gap: 8px; }

.cartao {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .12s, background .12s;
}
.cartao:hover { border-color: var(--border-strong); }
.cartao.open { border-color: var(--border-strong); background: var(--surface-3); }

.cartao-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px;
  cursor: pointer;
  gap: 12px;
}
.cartao-title { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.cartao-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.cartao-name {
  background: transparent; border: 0;
  font-size: 13.5px; font-weight: 600;
  padding: 3px 5px; border-radius: 5px;
  min-width: 0; flex: 1;
  color: var(--text);
  letter-spacing: -0.005em;
}
.cartao-name:focus { background: var(--surface-3); outline: none; }

.cartao-summary { display: flex; align-items: center; gap: 6px; }
.pill {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; color: var(--text-muted);
  display: inline-flex; gap: 5px; align-items: center;
  justify-content: space-between;
  font-weight: 500;
  min-width: 130px;
}
.pill strong {
  color: var(--text);
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.pill.fatura strong { color: var(--tone-card); }
.pill.liquido strong { color: var(--good); }
.pill.liquido.zero strong { color: var(--text-muted); }

.cartao-body { display: none; padding: 0 13px 13px; flex-direction: column; gap: 13px; min-width: 0; }
.cartao.open .cartao-body { display: flex; }
.cartao-body .subsection { min-width: 0; }
.cartao-body .inline-add { min-width: 0; }
.cartao-body .inline-add input,
.cartao-body .inline-add .money-input { min-width: 0; }

.subsection h4 {
  margin: 0 0 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-weight: 600;
}
.compras-list, .contrib-list { display: flex; flex-direction: column; gap: 5px; }

.compra-item {
  display: grid;
  /* Ordem: desc | valor | (total | nº)  OU  (tend | ↻) | categoria | X
     Todas as colunas auto-adaptam ao conteúdo; o 1fr da desc absorve sobra. */
  grid-template-columns: minmax(0, 1fr) auto auto auto auto 28px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  min-height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 12.5px;
  line-height: 1.4;
}
.compra-item > * {
  align-self: center;
}
.compra-item > .ci-desc,
.compra-item > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-self: start;
  font-weight: 500;
}
.compra-item .li-val {
  text-align: right;
  justify-self: end;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.compra-item .ci-desc,
.compra-item .compra-edit-trigger {
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}
.compra-item .badge {
  background: rgba(245,158,11,0.10);
  color: var(--warn);
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: center;
  justify-self: stretch;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(245,158,11,0.22);
}
.compra-item .cat-badge {
  justify-self: stretch;
  text-align: center;
  display: inline-flex;
  justify-content: center;
}
/* Fixa o X sempre na última coluna do grid (extremo direito do item),
   independente de quantas badges existem antes. */
.compra-item .btn-x {
  grid-column: -1;
  justify-self: center;
}
/* Ícones que substituem texto em compras parceladas:
   - .compra-total-icon: Σ (sigma) → tooltip mostra o valor total
   - .compra-parcela-icon: calendário SVG → tooltip mostra "Parcela N de M"
   Ambos seguem o mesmo padrão visual da tendência e do ↻ (22×22, sem box). */
.compra-item .compra-total-icon,
.compra-item .compra-parcela-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: help;
  user-select: none;
  transition: transform .12s ease, color .15s ease;
}
.compra-item .compra-total-icon:hover,
.compra-item .compra-total-icon:focus-visible,
.compra-item .compra-parcela-icon:hover,
.compra-item .compra-parcela-icon:focus-visible {
  transform: scale(1.2);
  color: var(--text-muted);
  outline: none;
}
.compra-item .compra-total-icon {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.compra-item .compra-parcela-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

/* Ícone ↻ que indica "assinatura". Apenas glyph, sem box.
   Tooltip mostra desde quando. */
.compra-item .assinatura-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--tone-invest, #14B8A6);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  transition: transform .12s ease;
}
.compra-item .assinatura-badge:hover {
  transform: scale(1.2);
}

/* ===== KPIs — design Mercury/Ramp ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: stretch;
}
.kpi {
  --kpi-tone: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  min-height: 124px;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: center;
  gap: 5px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out), transform .15s var(--ease-out);
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-tone);
  opacity: 0.85;
}
.kpi > * { position: relative; z-index: 1; }
.kpi:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

/* Paleta semântica simplificada */
.kpi-income   { --kpi-tone: var(--tone-income); }
.kpi-balance  { --kpi-tone: var(--tone-balance); }
.kpi-spending { --kpi-tone: var(--tone-spending); }

.kpi-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.16;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  margin-top: 2px;
}
.kpi-value.income { color: var(--good); }
.kpi-value.danger { color: var(--bad); }
.kpi-value.warn   { color: var(--warn); }
.kpi-value.info   { color: var(--info); }
.kpi-income  .kpi-value { color: var(--tone-income); }
.kpi-spending .kpi-value { color: var(--bad); }
.kpi-balance .kpi-value { color: var(--text); }

.kpi-mom {
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 16px;
  margin-top: 2px;
}
.kpi-mom .mom-good {
  color: var(--good);
  font-weight: 600;
  background: rgba(16,185,129,0.10);
  padding: 1px 6px;
  border-radius: 4px;
}
.kpi-mom .mom-bad {
  color: var(--bad);
  font-weight: 600;
  background: rgba(244,63,94,0.10);
  padding: 1px 6px;
  border-radius: 4px;
}
.kpi-mom .mom-neutral { color: var(--text-faint); }
.kpi-mom .mom-ref     { color: var(--text-faint); }
.kpi-sub {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 2px;
}

.kpi-balance.negative {
  --kpi-tone: var(--bad);
}
.kpi-balance.negative .kpi-value { color: var(--bad); }
.kpi-balance.negative .kpi-sub { color: rgba(244,63,94,0.55); }



/* ===== MODAL ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 7, 10, 0.74);
  backdrop-filter: blur(7px);
  display: grid; place-items: center;
  z-index: 1200; padding: 20px;
  animation: modalFade .18s var(--ease-out);
}
.modal[hidden] { display: none; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 24px;
  border-radius: var(--radius-lg);
  width: 100%; max-width: 540px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .22s var(--ease-out);
}
.modal-content.modal-sm { max-width: 420px; }
.modal-content.modal-copy { max-width: 560px; }
.modal-content.modal-compra {
  max-width: 500px;
  padding: 20px;
  gap: 10px;
  overflow-y: visible;
}
.modal-content h3 {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}
.color-swatch {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform .1s, border-color .15s;
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch.active { border-color: var(--text); }
.color-swatch.active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 5px;
  box-shadow: inset 0 0 0 2px var(--bg);
}
.modal-sub { color: var(--text-muted); font-size: 12px; margin-top: -6px; line-height: 1.5; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modal-grid > .ic-field,
.modal .money-input,
.modal input[type="text"],
.modal input[type="number"] {
  min-width: 0;
  width: 100%;
}
.modal-month-picker { width: 100%; }
.modal-month-trigger {
  width: 100%;
  justify-content: space-between;
  min-height: 40px;
}
.modal-copy .modal-month-trigger {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 18px;
  justify-content: initial;
  gap: 12px;
  padding-inline: 14px 12px;
}
.modal-copy .modal-month-trigger .cal-icon { justify-self: start; }
.modal-copy .modal-month-trigger .cal-trigger-label {
  min-width: 0;
  align-items: flex-start;
}
.modal-copy .modal-month-trigger .cal-caret { justify-self: end; }
.modal-month-picker .cal-panel {
  right: 0;
  left: auto;
  width: 300px;
  z-index: 120;
}
.modal-preview {
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.modal-compra .modal-sub {
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: -4px;
}
.modal-compra .modal-grid {
  gap: 10px;
}
.modal-compra .ic-field {
  gap: 4px;
}
.modal-compra .modal-month-trigger {
  min-height: 36px;
}
.modal-compra .modal-actions {
  margin-top: 2px;
}
.copy-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.copy-mode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.copy-mode-option:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.copy-mode-option input,
.copy-section-grid input {
  accent-color: var(--accent);
  margin-top: 2px;
}
.copy-mode-option strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.copy-mode-option small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.copy-section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.copy-section-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
}
.copy-section-grid.is-disabled {
  opacity: .48;
  pointer-events: none;
}
.copy-preview {
  background: rgba(59,130,246,0.08);
  border-color: rgba(59,130,246,0.22);
  color: #60A5FA;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ===== Custom dialogs ===== */
.dialog-content { gap: 14px; }
.dialog-message {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: normal;
  margin: 0;
}
.dialog-content .dialog-input { width: 100%; }

/* ===== FOOTER ===== */
.hub-credit-footer {
  width: 100%;
  padding: 18px 20px 14px;
  margin-top: auto;
  box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 7px;
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  opacity: 0.55;
  transition: opacity 0.2s;
}
.hub-credit-footer:hover { opacity: 0.85; }
.hub-credit-person { display: inline-flex; align-items: center; gap: 6px; }
.hub-credit-icons { display: inline-flex; align-items: center; gap: 4px; }
.hub-credit-social {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: inherit; text-decoration: none;
  padding: 2px;
  transition: color 0.2s, opacity 0.2s;
}
.hub-credit-social:hover, .hub-credit-social:focus-visible { color: var(--accent); outline: none; }
.hub-credit-social:hover .hub-credit-icon,
.hub-credit-social:focus-visible .hub-credit-icon { opacity: 1; }
.hub-credit-icon { width: 12px; height: 12px; opacity: 0.7; display: block; flex-shrink: 0; transition: opacity 0.2s; }

#autosaveStatus { transition: color .2s; font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.005em; }
#autosaveStatus.saving { color: var(--warn); }
#autosaveStatus.saved  { color: var(--good); }
#autosaveStatus.error  { color: var(--bad); }

/* ===== ASSINATURA TOGGLE ===== */
.assinatura-toggle {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 0 4px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-dim);
  user-select: none;
}
.assinatura-toggle input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }
.assinatura-toggle small { color: var(--text-faint); font-size: 10.5px; }
#parcelasField { transition: opacity 0.2s; }

/* Bloco de reajuste de assinatura (modal de edição). */
.reajuste-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border-soft));
  border-radius: var(--radius-sm);
  margin: 4px 0;
}
/* `display: flex` acima sobrescreve o hidden do HTML; garante esconder. */
.reajuste-block[hidden] { display: none; }
.reajuste-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.reajuste-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  user-select: none;
  min-height: 26px;
}
.reajuste-option input[type="radio"] {
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.reajuste-option span { line-height: 1; }
/* Picker custom dentro do bloco de reajuste: aproveita .cal-picker existente
   mas com proporção mais compacta pra caber numa linha de radio. */
.reajuste-cal-picker .cal-trigger {
  padding: 4px 8px;
  min-height: 28px;
}
.reajuste-cal-picker .cal-trigger-label {
  font-size: 11.5px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .inputs-grid { grid-template-columns: 1fr; }
  .inputs-grid .span-2 { grid-column: auto; }
}
@media (max-width: 760px) {
  .main { padding: 14px; }
  .skeleton-grid {
    grid-template-columns: 1fr;
  }
  .card,
  .input-card,
  .ic-head,
  .ic-head-right { min-width: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-grid { grid-template-columns: 1fr; }
  .inline-2 { grid-template-columns: minmax(0, 1fr) auto; }
  .inline-2 > input[type="text"] { grid-column: 1 / -1; }
  .inline-2 > .money-input { grid-column: 1; }
  .inline-2 > .btn-add { grid-column: 2; }
  .compra-item {
    grid-template-columns: 1fr auto auto 28px;
    grid-template-areas:
      "desc val v3   x"
      "v4   v4  cat  cat";
    row-gap: 6px;
  }
  .compra-item > .ci-desc, .compra-item > span:first-child { grid-area: desc; }
  .compra-item .li-val { grid-area: val; }
  /* v3 = tendência (assinatura) ou ícone Σ total (parcelada) */
  .compra-item .tendencia-icon { grid-area: v3; justify-self: end; }
  .compra-item .compra-total-icon { grid-area: v3; justify-self: end; }
  /* v4 = ↻ (assinatura) ou ícone calendário parcela (parcelada) */
  .compra-item .assinatura-badge { grid-area: v4; justify-self: start; }
  .compra-item .compra-parcela-icon { grid-area: v4; justify-self: start; }
  .compra-item .cat-badge { grid-area: cat; justify-self: end; }
  .compra-item .btn-x { grid-area: x; }
  .modal-month-picker .cal-panel { width: 100%; }
  .renda-head-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .segmented-control { width: 100%; }
  .seg-btn {
    flex: 1;
    min-width: 0;
    padding-inline: 6px;
  }
  .cartao-summary { flex-wrap: wrap; }
  .topbar {
    left: 14px;
    right: 14px;
    width: calc(100% - 28px);
    flex-wrap: wrap;
    gap: 10px;
  }
  .topbar-right { flex-wrap: wrap; }
  .topbar-right .cal-panel {
    position: fixed;
    top: 96px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }
  .copy-mode-grid,
  .copy-section-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi { min-height: 100px; }
}

/* ====== Cofrinhos múltiplos ====== */
.cof-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--tone-invest);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.cof-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.cof-nome {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
}
.cof-nome strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.cof-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cof-saldo {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.cof-saldo small {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 400;
  margin-left: 2px;
}
.cof-progress {
  position: relative;
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.cof-progress-bar {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  opacity: 0.9;
  transition: width .35s var(--ease-out);
}
.cof-progress.done .cof-progress-bar { opacity: 1; }
.cof-progress-label {
  position: absolute;
  right: 6px;
  top: -16px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.cof-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.cof-inputs .ic-field,
.cof-inputs .money-input { min-width: 0; }
.cof-inputs .ic-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ====== Topbar pop menus ====== */
.tb-menu-wrap { position: relative; }
.tb-popmenu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 80;
  padding: 5px;
}
.tb-popmenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  width: 100%;
  text-align: left;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.tb-popmenu-item:hover { background: var(--surface-2); color: var(--text); }
.tb-popmenu-item svg { width: 14px; height: 14px; }



/* ====== Cartões ====== */
.subsection-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  margin-top: 4px;
}
.subsection-head h4 { margin: 0; }

/* ====== Autosave status ====== */
.autosave-status {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 999px;
  transition: opacity .25s var(--ease-out), color .2s, background .2s;
  white-space: nowrap;
  opacity: 0;
  font-family: var(--font-mono);
  letter-spacing: -0.005em;
}
.autosave-status:not(:empty) { opacity: 1; }
.autosave-status.saving::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warn);
  margin-right: 6px;
  animation: pulse 1.1s ease-in-out infinite;
}
.autosave-status.saved { color: var(--good); }
.autosave-status.saved::before {
  content: "✓";
  margin-right: 4px;
  color: var(--good);
}
.autosave-status.error {
  color: var(--bad);
  background: rgba(244,63,94,0.10);
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
@media (max-width: 640px) {
  .autosave-status { display: none; }
}

/* ====== Categorias (Fase D) ====== */
.cat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: filter .15s, transform .1s;
  letter-spacing: 0.005em;
  min-width: 130px;
}
.cat-badge:hover { filter: brightness(1.15); }
.cat-badge:active { transform: scale(0.97); }
.cat-badge.empty {
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border);
  border-style: dashed;
}

/* ====== Popover de troca de categoria ====== */
.cat-popover {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  max-width: 280px;
  max-height: 360px;
  overflow-y: auto;
  padding: 5px;
  font-size: 12.5px;
}
.cat-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-dim);
  transition: background .12s, color .12s;
  width: 100%;
  text-align: left;
}
.cat-popover-item:hover { background: var(--surface-2); color: var(--text); }
.cat-popover-item.active { background: var(--accent-soft); color: var(--accent); }
.cat-popover-item .cat-dot { width: 9px; height: 9px; }
.cat-popover-item.clear {
  border-top: 1px solid var(--border-soft);
  margin-top: 4px;
  padding-top: 9px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.cat-popover-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
}
.cat-select {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 0;
  padding: 10px 2px;
  font-size: 12.5px;
  min-width: 140px;
}
.cat-select:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.modal-cats { max-width: 640px; }
.cats-add-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-bottom: 12px;
}
.cats-add-row1 {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
}
.cats-add-row1 input[type="text"],
.cats-add-row1 select {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 0;
  padding: 8px 2px;
  font-size: 13px;
  width: 100%;
}
.cats-add-row1 input[type="text"]:focus,
.cats-add-row1 select:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
}
.cats-add-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cats-add-row2 .cat-color-row {
  flex-wrap: wrap;
  flex: 1;
  max-width: none;
  gap: 5px;
}
.cats-add-row2 .color-swatch.sm {
  width: 22px;
  height: 22px;
}
@media (max-width: 560px) {
  .cats-add-row1 { grid-template-columns: 1fr; }
}
.cats-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 12px 0 16px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
}
.cat-item {
  display: grid;
  grid-template-columns: 16px minmax(120px, 1.4fr) 92px minmax(130px, 1.1fr) 26px;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}
.cat-item > * { min-width: 0; }
.cat-item input,
.cat-item select { width: 100%; min-width: 0; }
.cat-budget {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
}
.cat-budget-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 7px;
}
.cat-budget-input .money-prefix {
  font-size: 10.5px;
  color: var(--text-faint);
}
.cat-budget-input input {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  padding: 0;
  outline: none;
  width: 100%;
  min-width: 0;
}
.cat-budget-progress {
  position: relative;
  height: 10px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.cat-budget-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .35s var(--ease-out);
  opacity: 0.75;
}
.cat-budget-progress.warn .cat-budget-bar {
  background: var(--warn) !important;
  opacity: 0.9;
}
.cat-budget-progress.over .cat-budget-bar {
  background: var(--bad) !important;
  opacity: 0.9;
}
.cat-budget-pct {
  position: absolute;
  inset: 0;
  text-align: center;
  line-height: 10px;
  font-size: 9px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  z-index: 1;
}
.cat-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.cat-name {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 5px;
}
.cat-name:hover, .cat-name:focus {
  background: var(--surface-3);
  outline: none;
}
.cat-tipo-edit {
  background: var(--surface-input);
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 11.5px;
}
.cat-color-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 200px;
}
.cat-color-edit {
  max-width: none;
  gap: 0;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}
.cat-color-picker {
  position: relative;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
}
.cat-color-trigger {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--cat-current-color);
  border: 0;
  box-shadow: 0 0 0 6px transparent;
  transition: transform .12s, border-color .12s;
}
.cat-color-trigger:hover,
.cat-color-trigger[aria-expanded="true"] {
  transform: scale(1.2);
  box-shadow: 0 0 0 6px rgba(255,255,255,0.06);
}
.cat-color-menu {
  /* position: fixed pra escapar do overflow:hidden da .cats-list (que cria
     clipping context e corta o popover). JS calcula top/left ao abrir. */
  position: fixed;
  z-index: 2000;
  display: grid;
  grid-template-columns: repeat(6, 18px);
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.cat-color-menu[hidden] { display: none; }
.cat-color-option {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--cat-option-color);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
  transition: transform .1s, border-color .12s;
}
.cat-color-option:hover {
  transform: scale(1.12);
}
.cat-color-option.active {
  border-color: var(--text);
  box-shadow: inset 0 0 0 2px var(--surface);
}
.color-swatch.sm {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch.sm.active { border-color: #fff; transform: scale(1.1); }

@media (max-width: 640px) {
  .cat-item {
    grid-template-columns: 14px 1fr 28px;
    grid-template-areas:
      "dot name x"
      "budget budget budget";
    row-gap: 8px;
  }
  .cat-item .cat-dot { grid-area: dot; }
  .cat-item .cat-name { grid-area: name; }
  .cat-item .btn-x { grid-area: x; }
  .cat-item .cat-color-edit { grid-area: dot; justify-content: flex-start; }
  .cat-item .cat-budget { grid-area: budget; }
  .cat-tipo-edit { display: none; }
  .cat-color-row { max-width: 100%; }
}

/* scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

/* ===== Renda & Cofrinho: altura fixa ===== */
.input-card[data-section-card="renda"]:not(.collapsed),
.input-card[data-section-card="cofrinho"]:not(.collapsed) {
  height: 295px;
  overflow: hidden;
}
.input-card[data-section-card="renda"]:not(.collapsed) .ic-body,
.input-card[data-section-card="cofrinho"]:not(.collapsed) .ic-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.input-card[data-section-card="renda"]:not(.collapsed) .chart-view,
.input-card[data-section-card="cofrinho"]:not(.collapsed) .chart-view {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.input-card[data-section-card="renda"]:not(.collapsed) #rendaFormView {
  flex: 1;
  min-height: 0;
  gap: 10px;
}
.input-card[data-section-card="renda"]:not(.collapsed) #rendaFormView .ic-sub {
  flex: 1;
  min-height: 0;
  gap: 6px;
}
.input-card[data-section-card="renda"]:not(.collapsed) #rendaFormView .list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-gutter: stable;
}
.input-card[data-section-card="renda"]:not(.collapsed) #rendaFormView .list-item.empty {
  padding: 4px 12px;
  font-size: 11.5px;
}
.input-card[data-section-card="renda"]:not(.collapsed) #rendaFormView .renda-extra-item {
  grid-template-columns: minmax(0, 1fr) auto minmax(76px, 92px) 22px;
  min-height: 31px;
  padding: 6px 9px;
  gap: 8px;
  border-radius: 7px;
}
.renda-extra-item .li-desc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.renda-extra-item .li-val {
  justify-self: end;
}
.renda-extra-item .extra-tipo-badge {
  min-width: 0;
  width: 100%;
  padding: 2px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.renda-extra-item .btn-x {
  width: 20px;
  height: 20px;
}

/* ===== Cofrinho views ===== */
.cofrinho-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 7px;
  overflow-y: auto;
  overflow-x: hidden;
}
.cofrinho-view[hidden] { display: none; }

/* ===== Cofrinho lista clicável ===== */
.cofrinhos-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cof-list-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .12s, background .12s;
}
.cof-list-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.cof-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cof-list-nome {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cof-list-saldo {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.cof-list-saldo small {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 400;
}
.cof-list-chevron {
  width: 13px;
  height: 13px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.cof-movs-badge {
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
}
.cof-movs-badge.aporte {
  background: rgba(16,185,129,0.10);
  color: var(--good);
  border: 1px solid rgba(16,185,129,0.22);
}
.cof-movs-badge.saque {
  background: rgba(244,63,94,0.10);
  color: var(--bad);
  border: 1px solid rgba(244,63,94,0.22);
}
.cof-list-progress {
  height: 2px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.cof-list-bar {
  height: 100%;
  border-radius: 999px;
  opacity: 0.85;
  transition: width .35s var(--ease-out);
}

/* ===== Cofrinho edit modal ===== */
.cofrinho-edit-movs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.cofrinho-edit-saldo {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 8px 12px;
  background: rgba(20,184,166,0.08);
  border: 1px solid rgba(20,184,166,0.20);
  border-radius: var(--radius-sm);
}
.cofrinho-edit-saldo strong {
  color: var(--tone-invest);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.cof-modal-actions {
  justify-content: space-between;
  align-items: center;
}
.modal-actions-right {
  display: flex;
  gap: 10px;
}

/* ===== Nova compra inline ===== */
.btn-nova-compra {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  vertical-align: baseline;
  transition: color .12s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn-nova-compra:hover { color: var(--cartao-cor, var(--tone-card)); }

/* ====== Gastos Vale ====== */
.vale-budget-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: end;
}
.vale-budget-field { flex-shrink: 0; }
.vale-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}
.vale-progress {
  flex: 1;
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.vale-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--tone-vale);
  opacity: 0.85;
  transition: width .35s var(--ease-out), background .25s;
}
.vale-progress-bar.warn { background: var(--warn); opacity: 0.95; }
.vale-progress-bar.over { background: var(--bad); opacity: 1; }
.vale-progress-label {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 38px;
  text-align: right;
}
.vale-saldo-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(251,146,60,0.10);
  border: 1px solid rgba(251,146,60,0.22);
}
.vale-saldo-label {
  color: var(--text-muted);
  font-weight: 500;
}
.vale-saldo-value {
  color: var(--tone-vale);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.vale-saldo-badge.negative {
  background: rgba(244,63,94,0.10);
  border-color: rgba(244,63,94,0.22);
}
.vale-saldo-badge.negative .vale-saldo-value { color: var(--bad); }
@media (max-width: 760px) {
  .vale-budget-row {
    grid-template-columns: 1fr;
  }
}

/* ====== Import Extrato Modal ====== */
.modal-import { max-width: 560px; }
.import-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.import-dropzone:hover,
.import-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.import-dropzone-icon {
  width: 28px;
  height: 28px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.import-dropzone.dragover .import-dropzone-icon { color: var(--accent); }
.import-dropzone small { color: var(--text-faint); font-size: 11px; }
.import-browse-btn {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: inherit;
  cursor: pointer;
}
.import-browse-btn:hover { color: var(--accent-hover); }

.import-file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.import-file-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.import-skeleton {
  display: grid;
  gap: 8px;
}
.import-skeleton-line {
  height: 40px;
}
.import-skeleton-line:first-child {
  height: 52px;
}
.import-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.import-result-source {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.import-result-count {
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.import-result-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.import-result-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 12px;
  transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.import-result-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  transform: translateY(-1px);
}
.import-result-item .iri-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.import-result-item .iri-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--bad);
  font-weight: 500;
  white-space: nowrap;
}
.import-result-item .iri-check {
  accent-color: var(--accent);
}
.import-result-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-style: normal;
}
.import-result-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.import-result-item .iri-cat {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c, var(--text-muted));
  background: color-mix(in srgb, var(--c, var(--text-muted)) 16%, transparent);
}

/* Item importado já existe em meses anteriores: badge + destaque sutil */
.import-result-item.has-recorrencia {
  grid-template-columns: 1fr auto auto auto;
  border-color: color-mix(in srgb, #F59E0B 35%, var(--border-soft));
  background: color-mix(in srgb, #F59E0B 6%, var(--surface-2));
}
.import-result-item:not(.has-recorrencia) {
  grid-template-columns: 1fr auto auto auto;
}
.import-result-item .iri-recorrente-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #F59E0B;
  background: color-mix(in srgb, #F59E0B 18%, transparent);
  cursor: help;
}
.import-result-item .iri-destino {
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  padding: 2px 6px;
  font-family: inherit;
  cursor: pointer;
}
.import-result-item .iri-destino:hover {
  border-color: var(--border-strong);
}
.import-result-item.has-recorrencia .iri-destino {
  border-color: color-mix(in srgb, #F59E0B 50%, var(--border-soft));
}



/* user menu divider */
.tb-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.tb-menu-item {
  text-decoration: none;
  color: var(--text);
}

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

/* ===================================================================
   CHARTS — Toggle de visão dos cards Renda/Cofrinho + Seção Análises
   =================================================================== */

/* Toggle Lista/Gráfico no header do card (escopo: só quando expandido) */
.card-view-toggle { order: -1; }
.input-card.collapsed .card-view-toggle { display: none; }

/* View de gráfico dentro de Renda/Cofrinho */
.renda-view.chart-view,
.cofrinho-view.chart-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}
.cofrinho-view[hidden],
.renda-view[hidden] { display: none; }

.chart-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 0;
  flex-shrink: 0;
}
.chart-summary-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-card[data-tone="income"] .chart-summary-value { color: var(--tone-income); }
.input-card[data-tone="invest"] .chart-summary-value { color: var(--tone-invest); }
.chart-summary-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.chart-summary-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 240px;
  flex-shrink: 0;
}

.input-card[data-section-card="renda"] .chart-canvas-wrap,
.input-card[data-section-card="cofrinho"] .chart-canvas-wrap {
  flex: 1;
  min-height: 0;
  height: auto;
}

/* ===== ANÁLISES ===== */
.analises-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
  align-items: stretch;
}
.analise-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  min-width: 0;
  overflow: hidden;
}
.analise-card.analise-evolucao { grid-column: 1 / -1; }

.analise-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.analise-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-dim);
  margin: 0;
}
.analise-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.analise-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.analise-canvas-wrap {
  height: clamp(210px, 26vh, 240px);
  min-height: 0;
  overflow: hidden;
}
.analise-canvas-wrap > canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.analise-canvas-tall { height: clamp(230px, 30vh, 300px); }
.analise-pizza .analise-canvas-wrap { height: clamp(240px, 32vh, 320px); }

@media (max-width: 900px) {
  .analises-grid { grid-template-columns: 1fr; }
  .analise-card.analise-evolucao { grid-column: 1; }
  .chart-canvas-wrap { height: 220px; }
  .analise-canvas-wrap { height: 220px; }
  .analise-canvas-tall { height: 260px; }
}

/* =============================================================
   PROJEÇÕES (/projecoes)
   ============================================================= */

.route-projecoes {
  display: flex;
  flex-direction: column;
}

.proj-main {
  padding: 18px 28px 40px;
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ----- KPIs ----- */
.proj-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.proj-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.proj-kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.7;
}
#kpiRunwayBox::before { background: var(--tone-invest); }
#kpiLiberadoBox::before { background: var(--tone-card); }
.proj-kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.proj-kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.proj-kpi-sub { font-size: 11.5px; color: var(--text-faint); }

/* ----- Grid de cards ----- */
.proj-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.proj-card-hero { grid-column: 1 / -1; }

.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.proj-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.proj-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.proj-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.proj-card-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.proj-chart-wrap { position: relative; width: 100%; }
.proj-chart-tall { height: 320px; }
.proj-chart-med  { height: 240px; }

.proj-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border-soft);
  margin-top: -4px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.proj-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.proj-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.proj-dot-real { background: var(--text-muted); }
.proj-dot-proj { background: var(--accent); }
.proj-dot-band { background: var(--accent); opacity: 0.25; border: 1px solid var(--accent); }

/* Listas dentro dos cards */
.proj-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.proj-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.proj-list-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.proj-list-item-title { font-size: 13px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-list-item-sub   { font-size: 11px; color: var(--text-muted); }
.proj-list-item-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.proj-list-item-value.positive { color: var(--good); }
.proj-list-item-value.negative { color: var(--bad); }
.proj-list-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.proj-faturas-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-dim);
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  max-height: 140px;
  overflow-y: auto;
}

/* ----- Empty state ----- */
.proj-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
}
.proj-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.proj-empty-icon svg { width: 28px; height: 28px; }
.proj-empty h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.proj-empty p  { font-size: 13.5px; color: var(--text-dim); }
.proj-empty .btn-primary { margin-top: 6px; }

/* ----- Skeleton de loading ----- */
.proj-loading {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.proj-skel {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: projSkelShimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}
.proj-skel-row  { height: 72px; }
.proj-skel-hero { height: 360px; }
.proj-skel-grid { height: 400px; }
@keyframes projSkelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Responsivo */
@media (max-width: 980px) {
  .proj-kpi-row { grid-template-columns: 1fr; }
  .proj-grid    { grid-template-columns: 1fr; }
  .proj-main { padding: 0 0 24px; }
  .proj-chart-tall { height: 240px; }
}

/* =============================================================
   APP SHELL — sidebar fixa à esquerda (estilo HUB)
   ============================================================= */

:root {
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 76px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  transition: grid-template-columns 0.32s var(--ease-out);
}
.app-shell[data-collapsed="true"] {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

#sidebar-root {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px;
  gap: 10px;
  min-height: 64px;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.sidebar-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-mark svg { width: 17px; height: 17px; }
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.sidebar-brand-text strong {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-text small {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 1px;
}

[data-collapsed="true"] .sidebar-brand-text { display: none; }
[data-collapsed="true"] .sidebar-header { justify-content: center; padding: 14px 0; }

.sidebar-collapse {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .18s var(--ease-out), background .18s var(--ease-out), border-color .18s var(--ease-out);
}
.sidebar-collapse:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.sidebar-collapse svg {
  width: 14px;
  height: 14px;
  transition: transform .32s var(--ease-out);
}
[data-collapsed="true"] .sidebar-collapse svg { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}
[data-collapsed="true"] .sidebar-section-label {
  height: 1px;
  padding: 0;
  margin: 10px 14px;
  background: var(--border-soft);
  font-size: 0;
  overflow: hidden;
  color: transparent;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
  position: relative;
  white-space: nowrap;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.9;
}
.sidebar-link.active svg { opacity: 1; }
.sidebar-link-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-collapsed="true"] .sidebar-nav { padding: 12px 0; align-items: center; }
[data-collapsed="true"] .sidebar-link {
  justify-content: center;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
[data-collapsed="true"] .sidebar-link-label { display: none; }

.sidebar-footer {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-support-link {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.022);
  margin-bottom: 4px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 4px;
  transition: background .15s var(--ease-out), border-color .15s var(--ease-out);
}
.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
}
.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
  color: var(--accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11.5px;
  flex-shrink: 0;
}
.sidebar-user-info {
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-user-info strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-info small {
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

[data-collapsed="true"] .sidebar-footer { padding: 12px 0; align-items: center; }
[data-collapsed="true"] .sidebar-user {
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  margin-top: 0;
}
[data-collapsed="true"] .sidebar-user-info { display: none; }

.sidebar-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: color .15s var(--ease-out), border-color .15s var(--ease-out), background .15s var(--ease-out);
  margin-top: 4px;
}
.sidebar-action:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}
.sidebar-action svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-action-label { white-space: nowrap; }
[data-collapsed="true"] .sidebar-action {
  justify-content: center;
  padding: 0;
  width: 40px;
  height: 40px;
}
[data-collapsed="true"] .sidebar-action-label { display: none; }

/* ---------- App main (área de conteúdo) ---------- */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Cross-fade do conteúdo (sidebar fica imóvel) */
body.page-fade:has(.app-shell) {
  opacity: 1;
  transition: none;
}
body.page-fade:has(.app-shell) .app-main {
  opacity: 0;
  transition: opacity 0.28s var(--ease-out);
}
body.page-fade.is-ready:has(.app-shell) .app-main { opacity: 1; }
body.page-fade.is-navigating:has(.app-shell) .app-main { opacity: 0; }
body.page-fade.is-leaving:has(.app-shell) .app-main { opacity: 0; }
body.page-fade.is-leaving:has(.app-shell) #sidebar-root { opacity: 0; transition: opacity 0.22s var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  body.page-fade:has(.app-shell) .app-main { opacity: 1; transition: none; }
  .app-shell { transition: none; }
  .sidebar-collapse svg { transition: none; }
}

/* ---------- Responsivo (drawer no mobile) ---------- */
@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .app-shell #sidebar-root {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease-out);
  }
  .app-shell[data-drawer-open="true"] #sidebar-root {
    transform: translateX(0);
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  }
  .app-shell[data-drawer-open="true"]::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 150;
  }
  [data-collapsed="true"] .sidebar-brand-text,
  [data-collapsed="true"] .sidebar-link-label,
  [data-collapsed="true"] .sidebar-action-label,
  [data-collapsed="true"] .sidebar-user-info {
    display: block;
  }
}

.shell-menu-toggle { display: none; }
@media (max-width: 720px) {
  .shell-menu-toggle {
    display: inline-flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 180;
    width: 38px;
    height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    align-items: center;
    justify-content: center;
  }
  .shell-menu-toggle svg { width: 18px; height: 18px; }
}
