/* ════════════════════════════════════════════════════════
   DASHBOARD FINANCEIRO · DESIGN SYSTEM
   Identidade: Janus Teixeira · verde-escuro + dourado envelhecido
   Fontes: Playfair Display (display) + Plus Jakarta Sans (texto)
   ════════════════════════════════════════════════════════ */

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

:root {
  /* Marca */
  --navy:        #1D2818;
  --navy-mid:    #2B3423;
  --navy-light:  #454431;
  --gold:        #928566;
  --gold-light:  #C1B6A1;
  --gold-pale:   #F1EEE7;

  /* Semânticas */
  --wine:        #8B1A1A;   /* gastos / alerta */
  --wine-deep:   #5E1212;
  --wine-bg:     #FBEFEF;
  --green:       #2E7D32;   /* positivo */
  --green-bg:    #EAF4EB;
  --orange:      #B96A00;

  /* Superfícies */
  --bg:          #F2F2F1;
  --card:        #FFFFFF;
  --border:      #E0DED8;
  --border-2:    #CCCCCC;

  /* Texto */
  --text:        #333333;
  --text-2:      #57544A;
  --text-3:      #908C80;

  /* Elevação e raios */
  --shadow-sm: 0 1px 3px rgba(40,38,32,.06);
  --shadow-md: 0 4px 14px rgba(40,38,32,.08);
  --shadow-lg: 0 16px 44px rgba(29,40,24,.16);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;

  /* z-index scale */
  --z-header: 30; --z-modal: 50; --z-toast: 60;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Nada pode alargar a página além da tela; conteúdo largo
   rola dentro do próprio contêiner (.tbl-wrap, overflow-x:auto) */
html, body { max-width: 100%; overflow-x: hidden; }
img { max-width: 100%; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* Foco visível para navegação por teclado */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--gold-pale); color: var(--navy); }

/* Apenas para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── ANIMAÇÕES ─────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* ════════════════════════ HEADER ═══════════════════════ */
header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border-bottom: 1px solid rgba(146,133,102,.35);
  box-shadow: 0 4px 20px rgba(29,40,24,.25);
}

.logo { min-width: 0; display: flex; align-items: center; gap: 14px; }

.logo-img {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  /* o fundo da imagem é o mesmo verde do header, o brasão flutua */
  box-shadow: 0 0 0 1px rgba(193,182,161,.45);
}

.logo-text { display: flex; flex-direction: column; }

.brand {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .5px;
  color: #fff;
  line-height: 1.15;
}
.brand::first-letter { color: var(--gold-light); }

.tagline {
  font-size: 10.5px;
  font-style: italic;
  color: rgba(255,255,255,.55);
  letter-spacing: .3px;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 4px;
  margin-inline: auto;
}

.nav-tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.65);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .3px;
  padding: 9px 16px;
  border-radius: 9px;
  transition: color .2s, background .2s;
  min-height: 40px;
}
.nav-tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-tab.active {
  background: var(--gold);
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-date {
  font-size: 12px;
  color: rgba(255,255,255,.6);
  letter-spacing: .3px;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  margin-left: auto;
}

.header-user-menu { display: flex; align-items: center; gap: 12px; min-width: 0; }

.header-user-name {
  font-size: 12px;
  color: rgba(255,255,255,.7);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.85);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  min-height: 38px;
  transition: background .2s, border-color .2s, color .2s;
}
.btn-logout:hover { background: rgba(255,255,255,.22); border-color: var(--gold); color: #fff; }
.btn-logout:active { transform: scale(.96); }

.sec-head-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }

/* ════════════════════════ PAGES ════════════════════════ */
.page {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 24px 60px;
}
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.page-h1 {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.15;
}

.page-sub { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* ══════════════════════ SECTIONS ═══════════════════════ */
.section { margin-bottom: 30px; }

.sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }

.sec-num {
  width: 32px; height: 32px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  color: var(--gold-light);
  font-size: 14px; font-weight: 700;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.sec-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--navy);
}

.sec-desc {
  font-size: 12.5px;
  color: var(--text-3);
  margin: 0 0 14px 44px;
}

/* ════════════════════════ CARDS ════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
}

/* ══════════════════════ BOTÕES ═════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
  min-height: 44px;
  transition: background .2s, box-shadow .2s, border-color .2s, color .2s;
}

.btn-wine {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(29,40,24,.25);
}
.btn-wine:hover { box-shadow: 0 5px 18px rgba(29,40,24,.35); background: var(--navy-light); }
.btn-wine:active { transform: scale(.98); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-2);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); background: var(--gold-pale); }

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

.btn-sm { padding: 8px 14px; font-size: 12px; min-height: 38px; border-radius: 9px; }

.sel-sm {
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  min-height: 38px;
  cursor: pointer;
  transition: border-color .2s;
}
.sel-sm:hover, .sel-sm:focus { border-color: var(--navy); }

/* ═════════════════════ MONTH BAR ═══════════════════════ */
.month-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.month-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  min-height: 40px;
  min-width: 48px;
  transition: border-color .2s, background .2s, color .2s, box-shadow .2s;
}
.month-btn:hover { border-color: var(--gold); color: var(--navy); }
.month-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--gold-light);
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.year-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
}

.year-btn {
  background: transparent;
  border: none;
  width: 34px; height: 34px;
  border-radius: 7px;
  font-size: 16px;
  color: var(--text-2);
  transition: background .2s, color .2s;
}
.year-btn:hover { background: var(--gold-pale); color: var(--navy); }

.year-label {
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  padding: 0 8px;
  min-width: 58px;
  text-align: center;
}

/* ════════════════════ RECEITA (income) ═════════════════ */
.income-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border: none;
  position: relative;
  overflow: hidden;
}
.income-card::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.income-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold-light);
}

.income-row { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }

.income-prefix {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255,255,255,.65);
}

.income-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(146,133,102,.4);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.5px;
  font-variant-numeric: lining-nums tabular-nums;
  color: #fff;
  width: 220px;
  padding: 0 2px 4px;
  transition: border-color .2s;
}
.income-input:focus { outline: none; border-bottom-color: var(--gold); }

.income-stats { display: flex; gap: 34px; flex-wrap: wrap; }

.stat-item { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.stat-val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.income-card .stat-val[style*="--wine"]  { color: #F0A0A0 !important; }
.income-card .stat-val[style*="--green"] { color: #9CD8A0 !important; }
.income-card .stat-val[style*="--text"]  { color: var(--gold-light) !important; }

.stat-lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
}

/* ═══════════════════ CATEGORIAS (grid) ═════════════════ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.cat-card {
  --c: var(--navy);
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--c);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s, background .2s;
}
.cat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c);
  background: #FFFEFA;
}

.cat-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.cat-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-ideal {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
}

.cat-val {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
  color: var(--c);
  margin-bottom: 8px;
}

.cat-bar {
  height: 5px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.cat-bar-fill {
  height: 100%;
  background: var(--c);
  border-radius: 99px;
  transition: width .5s cubic-bezier(.22,1,.36,1);
}

.cat-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
}
.cat-foot .over { color: var(--wine); font-weight: 600; }

/* ═════════════════ FILTROS (chips) ═════════════════════ */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  margin-left: 44px;
}

.chip {
  --c: var(--navy);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  min-height: 36px;
  transition: border-color .2s, background .2s, color .2s;
}
.chip:hover { border-color: var(--c); color: var(--c); }
.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
}
.chip .chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}
.chip .chip-n {
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--bg);
  border-radius: 99px;
  padding: 0 6px;
  line-height: 16px;
}
.chip.active .chip-n { background: rgba(255,255,255,.18); color: #fff; }

/* ═══════════════ TABELA DE LANÇAMENTOS ═════════════════ */
.tbl-wrap { overflow-x: auto; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }

.tbl th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 12px;
  border-bottom: 1.5px solid var(--border-2);
  white-space: nowrap;
}

.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: #FCFAF4; }

.tbl .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.tbl .td-day { color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.tag {
  --c: var(--navy);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 9%, white);
  border: 1px solid color-mix(in srgb, var(--c) 25%, white);
  border-radius: 99px;
  padding: 3px 10px;
  white-space: nowrap;
}

.status-pill {
  border: none;
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
  min-height: 30px;
  transition: filter .2s, box-shadow .2s;
}
.status-pill:hover { filter: brightness(.94); box-shadow: var(--shadow-sm); }
.status-pill.pago     { background: var(--green-bg); color: var(--green); }
.status-pill.pendente { background: var(--gold-pale); color: var(--orange); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-3);
  transition: background .2s, color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--bg); color: var(--navy); border-color: var(--border); }
.icon-btn.danger:hover { background: var(--wine-bg); color: var(--wine); border-color: transparent; }
.icon-btn svg { width: 15px; height: 15px; }

.tbl-empty {
  text-align: center;
  padding: 42px 20px;
  color: var(--text-3);
  font-size: 13px;
}
.tbl-empty strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

.tbl tfoot td {
  padding: 12px;
  font-weight: 700;
  border-top: 2px solid var(--border-2);
  border-bottom: none;
  color: var(--navy);
}

/* ═══════════════════════ MODAL ═════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(29,40,24,.55);
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; animation: fadeIn .2s ease both; }

.modal {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 26px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: popIn .25s cubic-bezier(.22,1,.36,1) both;
  position: relative;
}
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 26px; right: 26px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 23px;
  font-weight: 600;
  color: var(--navy);
}
.modal-x {
  width: 36px; height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 16px;
  color: var(--text-2);
  transition: background .2s, color .2s;
}
.modal-x:hover { background: var(--wine-bg); color: var(--wine); }

.f-field { margin-bottom: 15px; }

.f-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.f-input, .f-select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-height: 44px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.f-input:focus, .f-select:focus {
  outline: none;
  border-color: var(--navy-mid);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(29,40,24,.08);
}
.f-input::placeholder { color: var(--text-3); }

.f-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.modal-actions .btn-danger { margin-right: auto; }

/* ═══════════════ RESUMO VISUAL (donut etc) ═════════════ */
.vis-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.donut {
  width: 172px; height: 172px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px var(--border);
}

.donut-hole {
  width: 112px; height: 112px;
  background: var(--card);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.donut-total {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  line-height: 1.1;
  padding: 0 8px;
}
.donut-cap {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
}

.donut-legend { list-style: none; flex: 1; min-width: 190px; }
.dl-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--border);
}
.dl-item:last-child { border-bottom: none; }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dl-name { flex: 1; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-val { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.dl-pct { color: var(--text-3); font-size: 11px; width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

/* Saúde financeira */
.health-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 6px 4px;
}
.h-num {
  font-size: 50px;
  font-weight: 800;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--navy);
}
.h-word {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin: 4px 0 14px;
}
.h-track {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.05);
}
.h-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .6s cubic-bezier(.22,1,.36,1), background .3s;
}
.h-detail { font-size: 12px; color: var(--text-3); margin-top: 12px; line-height: 1.55; }

/* Comparativo real vs meta */
.cmp-row {
  display: grid;
  grid-template-columns: 175px 1fr 125px;
  align-items: center;
  gap: 16px;
  padding: 15px 0 9px;
  border-bottom: 1px dashed var(--border);
}
.cmp-row:last-child { border-bottom: none; }

.cmp-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  overflow: hidden;
  white-space: nowrap;
}
.cmp-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--c, var(--navy));
  flex: none;
}

.cmp-track {
  position: relative;
  height: 22px;
  background: #EFEBDE;
  border-radius: 99px;
  box-shadow: inset 0 1px 3px rgba(40,38,32,.07);
}
.cmp-fill {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  min-width: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--navy)) 70%, #fff), var(--c, var(--navy)));
  box-shadow: 0 1px 3px color-mix(in srgb, var(--c, var(--navy)) 40%, transparent);
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.cmp-fill.over { background: linear-gradient(90deg, #B44545, var(--wine)); }

.cmp-mark {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 3px;
  background: var(--gold);
  border-radius: 3px;
  box-shadow: 0 0 0 1.5px #fff;
}
.cmp-mark::after {
  content: 'meta';
  position: absolute;
  top: -13px; left: 50%;
  transform: translateX(-50%);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--gold);
}

.cmp-val {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cmp-val em { font-style: normal; color: var(--text-3); font-weight: 500; font-size: 11px; display: block; }

.chart-container { position: relative; width: 100%; }

/* Previsto (aba Custos) vs. Realizado */
.pvr-row {
  display: grid;
  grid-template-columns: 165px 1fr 175px 110px;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.pvr-row:last-child { border-bottom: none; }
.pvr-row.pvr-total { border-top: 2px solid var(--border-2); margin-top: 4px; padding-top: 12px; }

.pvr-vals {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pvr-vals em { font-style: normal; color: var(--text-3); font-weight: 500; font-size: 11px; display: block; }

.pvr-badge {
  justify-self: end;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 99px;
  white-space: nowrap;
}
.pvr-badge.ok   { background: var(--green-bg); color: var(--green); }
.pvr-badge.over { background: var(--wine-bg); color: var(--wine); }
.pvr-badge.na   { background: var(--bg); color: var(--text-3); border: 1px solid var(--border); }

/* Toast com Desfazer */
.undo-toast {
  position: fixed;
  bottom: 32px; right: 32px;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--navy);
  color: #fff;
  padding: 12px 14px 12px 20px;
  border-radius: 12px;
  border-left: 3px solid var(--gold);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(29,40,24,.35);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.undo-toast.show { opacity: 1; transform: none; pointer-events: auto; }

.undo-btn {
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .4px;
  min-height: 34px;
  transition: background .2s;
}
.undo-btn:hover { background: var(--gold-light); }

/* Ícone de gasto recorrente */
.rec-ico {
  width: 12px; height: 12px;
  color: var(--gold);
  vertical-align: -1px;
  margin-left: 7px;
}

/* Checkbox "recorrente" no modal */
.f-rec {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px 2px;
}
.f-rec input { accent-color: var(--gold); width: 16px; height: 16px; cursor: pointer; flex: none; }

/* Modal de categorias e metas */
.meta-row {
  display: grid;
  grid-template-columns: 34px 1fr 96px 30px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.meta-color {
  width: 30px; height: 30px;
  padding: 0;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.meta-color::-webkit-color-swatch-wrapper { padding: 2px; }
.meta-color::-webkit-color-swatch { border: none; border-radius: 6px; }

.meta-name { min-height: 40px; font-size: 13px; }

.meta-del {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 11px;
  transition: background .2s, color .2s;
}
.meta-del:hover { background: var(--wine-bg); color: var(--wine); }

.meta-add {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  border: 1.5px dashed var(--border-2);
  border-radius: 9px;
  padding: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  min-height: 42px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.meta-add:hover { border-color: var(--gold); color: var(--navy); background: var(--gold-pale); }
.meta-inp { position: relative; }
.meta-inp input {
  text-align: right;
  padding-right: 32px;
  min-height: 40px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.meta-inp input::-webkit-outer-spin-button,
.meta-inp input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.meta-inp span {
  position: absolute;
  right: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-weight: 700;
  font-size: 13px;
}
.meta-sum {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 11px 16px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ═══════════════════ PATRIMÔNIO ════════════════════════ */
.pl-total-card {
  text-align: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border: none;
  padding: 30px 22px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.pl-total-card::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.pl-total-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--gold-light);
}
.pl-total-value {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  line-height: 1.2;
  margin: 6px 0 2px;
}
.pl-total-sub { font-size: 12px; color: rgba(255,255,255,.55); }

.patrimonio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.pat-col-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.pat-col-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
}

.pat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.pat-item-name { flex: 1; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pat-item-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  min-width: 90px;
  text-align: right;
  cursor: text;
  transition: border-color .2s, background .2s;
}
.pat-item-val:hover { border-color: var(--border-2); background: var(--bg); }
.pat-item-val:focus { outline: none; border-color: var(--navy-mid); background: var(--card); box-shadow: 0 0 0 3px rgba(29,40,24,.07); }

.pat-del-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 12px;
  transition: background .2s, color .2s;
}
.pat-del-btn:hover { background: var(--wine-bg); color: var(--wine); }

.pat-add-btn {
  margin-top: 10px;
  background: transparent;
  border: 1.5px dashed var(--border-2);
  border-radius: 9px;
  padding: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  min-height: 40px;
  transition: border-color .2s, color .2s, background .2s;
}
.pat-add-btn:hover { border-color: var(--gold); color: var(--navy); background: var(--gold-pale); }

.pat-col-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.pat-col-total-val {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: -.2px;
}

/* ══════════════ TABELAS ANUAIS (custos/entradas) ═══════ */
/* Container em card; seções como blocos arredondados */
#custosTableWrap > div,
#entradasTableWrap > div,
#histWrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.custos-tbl {
  width: 100%;
  table-layout: fixed;       /* colunas de mês com largura idêntica */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  min-width: 1290px;   /* 12 meses × 80px: cabe valor com centavos */
}

.custos-tbl .col-name  { width: 180px; }
.custos-tbl .col-total { width: 108px; }
.custos-tbl .col-del   { width: 36px; }

.custos-tbl td { padding: 0; overflow: hidden; }

/* Cabeçalho da seção: faixa tingida com a cor, não bloco sólido */
.row-section td.sec-name-cell {
  background: color-mix(in srgb, var(--sec-c, var(--navy)) 9%, #fff);
  color: color-mix(in srgb, var(--sec-c, var(--navy)) 82%, #000);
  border-left: 4px solid var(--sec-c, var(--navy));
  border-radius: 12px 12px 0 0;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
}
.sec-name-cell span[contenteditable] {
  padding: 2px 6px;
  border-radius: 5px;
  cursor: text;
  transition: background .2s;
}
.sec-name-cell span[contenteditable]:hover { background: rgba(255,255,255,.6); }
.sec-name-cell span[contenteditable]:focus { outline: none; background: #fff; box-shadow: 0 0 0 1.5px var(--sec-c, var(--navy)); }

.custos-add-btn, .custos-del-sec-btn {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--sec-c, var(--navy)) 30%, #fff);
  color: color-mix(in srgb, var(--sec-c, var(--navy)) 85%, #000);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  margin-left: 10px;
  min-height: 30px;
  transition: background .2s, border-color .2s;
}
.custos-add-btn:hover { background: color-mix(in srgb, var(--sec-c, var(--navy)) 12%, #fff); border-color: var(--sec-c, var(--navy)); }
.custos-del-sec-btn { float: right; padding: 5px 9px; color: var(--text-3); border-color: var(--border); }
.custos-del-sec-btn:hover { background: var(--wine-bg); color: var(--wine); border-color: transparent; }

/* Cabeçalho dos meses: discreto, sem bloco de cor */
.row-col-header td {
  background: #FAF8F1;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 8px 8px 4px;
  text-align: right; /* alinhado com os valores numéricos */
  border-bottom: 2px solid color-mix(in srgb, var(--sec-c, var(--navy)) 28%, #fff);
}
.row-col-header td:first-child { text-align: left; padding-left: 16px; }

/* Linhas: sem grade vertical, apenas separadores horizontais */
.row-item td { border-bottom: 1px solid #F1EDE2; transition: background .15s; }
.row-item:hover td { background: #FCFAF4; }

.row-item .cell-name {
  padding: 8px 14px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 160px;
}
.cell-name span[contenteditable] {
  display: block;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: text;
}
.cell-name span[contenteditable]:hover { background: var(--gold-pale); }
.cell-name span[contenteditable]:focus { outline: 1.5px solid var(--gold); background: #fff; }

.cell-val { min-width: 66px; }
.cell-val-wrap { display: flex; align-items: center; padding: 3px 4px; }

/* Checkbox de "pago" só aparece no hover, foco ou quando marcado */
.paid-check {
  accent-color: var(--green);
  cursor: pointer;
  width: 14px; height: 14px;
  flex: none;
  opacity: 0;
  transition: opacity .15s;
}
.cell-val:hover .paid-check,
.cell-val:focus-within .paid-check,
.cell-val.cell-paid .paid-check { opacity: 1; }
@media (hover: none) { .paid-check { opacity: .4; } }

.cell-val input[type="number"] {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  padding: 6px 4px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.cell-val input::-webkit-outer-spin-button,
.cell-val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cell-val input:focus { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 6px; background: #fff; }
.cell-val input::placeholder { color: #DDD6C6; }

.cell-val.cell-paid { background: var(--green-bg); border-radius: 8px; }
.cell-val.cell-paid input { color: var(--green); }

.cell-row-total {
  padding: 8px 8px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  white-space: nowrap;
  border-bottom: 1px solid #F1EDE2;
}
.cell-row-total.grand {
  color: var(--navy);
  font-weight: 800;
  border-bottom: none;
}

.cell-del { width: 34px; text-align: center; border-bottom: 1px solid #F1EDE2; }
.custos-del-btn {
  background: transparent;
  border: none;
  color: transparent;
  font-size: 11px;
  width: 28px; height: 28px;
  border-radius: 6px;
  transition: background .2s, color .2s;
}
.row-item:hover .custos-del-btn, .custos-del-btn:focus-visible { color: var(--text-3); }
.custos-del-btn:hover { background: var(--wine-bg); color: var(--wine); }

/* Linha de total da seção */
.row-total td { background: #FBF8EE; }
.row-total .cell-name-total {
  padding: 9px 16px;
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  color: var(--text-2);
  border-radius: 0 0 0 12px;
}
.row-total td:last-child { border-radius: 0 0 12px 0; }
.cell-val-total {
  padding: 9px 8px 9px 4px;
  text-align: right;
  font-weight: 700;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}
.row-spacer td { border: none; height: 24px; background: transparent; }

/* Total geral: única faixa escura, arredondada */
.row-grand-total td { background: var(--navy); border: none; }
.row-grand-total td:first-child { border-radius: 12px 0 0 12px; }
.row-grand-total td:last-child { border-radius: 0 12px 12px 0; }
.row-grand-total .cell-name-total {
  padding: 11px 16px;
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  color: var(--gold-light);
}
.row-grand-total .cell-val-total { color: #fff; padding: 11px 8px 11px 4px; }
.row-grand-total .cell-row-total.grand {
  background: var(--navy);
  color: var(--gold-light);
  font-weight: 800;
  padding: 11px 8px;
}

/* ═════════════════════ HISTÓRICO ═══════════════════════ */
.hist-year-tab {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  min-height: 40px;
  transition: border-color .2s, background .2s, color .2s;
}
.hist-year-tab:hover { border-color: var(--gold); color: var(--navy); }
.hist-year-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--gold-light);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--kc, var(--gold));
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-3);
}
.kpi-value {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -.4px;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  line-height: 1.25;
  margin: 3px 0 1px;
}
.kpi-sub { font-size: 11.5px; color: var(--text-3); }

/* ══════════════════════ TUTORIAL ═══════════════════════ */
.tut-grid { display: grid; gap: 18px; }

.tut-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}

.tut-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.tut-icon {
  width: 46px; height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-pale);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, #fff);
  border-radius: 13px;
  color: var(--navy);
}
.tut-icon svg { width: 22px; height: 22px; }

.tut-title {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.2px;
  line-height: 1.3;
}
.tut-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.tut-text { font-size: 13.5px; color: var(--text-2); line-height: 1.7; margin-top: 8px; }
.tut-text strong { color: var(--text); }

.tut-steps {
  list-style: none;
  counter-reset: tut;
  margin-top: 10px;
}
.tut-steps li {
  counter-increment: tut;
  position: relative;
  padding: 10px 0 10px 42px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-2);
  border-bottom: 1px dashed var(--border);
}
.tut-steps li:last-child { border-bottom: none; }
.tut-steps li::before {
  content: counter(tut);
  position: absolute;
  left: 0; top: 10px;
  width: 27px; height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: var(--gold-light);
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 700;
}
.tut-steps li strong { color: var(--text); }

/* Caixa "exemplo" dentro de cada passo: componentes reais, sem interação */
.step-demo {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1.5px dashed var(--border-2);
  border-radius: 12px;
  padding: 22px 16px 36px;
  margin: 14px 0 4px;
  pointer-events: none;
  user-select: none;
  overflow: visible; /* não corta o selo nem as etiquetas */
}
.step-demo::before {
  content: 'exemplo';
  position: absolute;
  top: -9px; left: 14px;
  background: var(--gold);
  color: var(--navy);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: 99px;
  z-index: 1;
}

.step-note {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
  max-width: 250px;
}

/* Anel pulsante "clique aqui" / "digite aqui" */
.tap { position: relative; display: inline-block; }
.tap::before {
  content: '';
  position: absolute;
  inset: -6px;
  border: 2.5px solid var(--gold);
  border-radius: 14px;
  animation: tapPulse 1.6s ease-in-out infinite;
  pointer-events: none;
}
.tap::after {
  content: 'clique aqui';
  position: absolute;
  left: 50%; bottom: -26px;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--navy);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.tap-type::after { content: 'digite aqui'; }
@keyframes tapPulse {
  0%, 100% { opacity: .3; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .tap::before { animation: none; opacity: 1; } }

.tut-tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--gold-pale);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
  margin-top: 16px;
}
.tut-tip strong { color: var(--navy); }
.tut-tip svg { width: 17px; height: 17px; flex: none; margin-top: 2px; color: var(--gold); }

/* ═══════════════════════ FOOTER ════════════════════════ */
footer {
  text-align: center;
  padding: 30px 20px 36px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
.footer-brand {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--navy);
}
.footer-brand::first-letter { color: var(--gold); }
.footer-sub { font-size: 11px; color: var(--text-3); margin-top: 5px; letter-spacing: .4px; }

/* ═══════════════════ RESPONSIVO ════════════════════════ */
@media (max-width: 1024px) {
  .vis-grid { grid-template-columns: 1fr; }
  .nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { flex: none; }
  .tagline { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  header { padding: 10px 14px; gap: 8px 12px; }
  .logo { gap: 10px; flex: 1; min-width: 0; }
  .logo-img { width: 40px; height: 40px; }
  .brand {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-date { display: none; } /* redundante no celular */
  .header-right { margin-left: 0; flex: none; }
  .header-user-name { max-width: 110px; font-size: 11px; }
  .btn-logout { padding: 7px 12px; flex: none; }
  .nav-tab { min-height: 44px; } /* alvo de toque confortável */
  .page { padding: 20px 14px 48px; }
  .income-card { flex-direction: column; align-items: stretch; }
  .income-stats { justify-content: space-between; gap: 18px; }
  .stat-item { align-items: flex-start; }
  .income-input { width: 100%; font-size: 34px; }
  .cmp-row { grid-template-columns: 1fr; gap: 5px; padding: 10px 0; }
  .cmp-val { text-align: left; }
  .pvr-row { grid-template-columns: 1fr auto; gap: 8px; }
  .pvr-row .cmp-track { grid-column: 1 / -1; }
  .pvr-vals { text-align: left; }
  .sec-desc, .filter-row { margin-left: 0; }
  .page-h1 { font-size: 26px; }
  .pl-total-value { font-size: 36px; }
  .f-grid2 { grid-template-columns: 1fr; }
  .f-input, .f-select { font-size: 16px; } /* evita zoom no iOS */
  .modal { padding: 20px; }
  .nav-tab { padding: 9px 12px; font-size: 12.5px; }
  .hist-year-tab { min-height: 44px; }
  .juros-actions { flex-direction: column; }
  .juros-actions .btn { width: 100%; }
  .kpi-value { font-size: 20px; }
}

/* ═══════════════════ JUROS COMPOSTOS ═══════════════════ */
.juros-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
}

.juros-field { display: flex; flex-direction: column; gap: 7px; }

.juros-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-3);
}

.juros-input-group {
  display: flex;
  align-items: stretch;
}

.juros-prefix {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--gold-pale);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

.juros-input {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 0;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.juros-input:last-child { border-radius: 0 10px 10px 0; }
.juros-input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(29,40,24,.08);
  position: relative;
  z-index: 1;
}

.juros-select {
  background: var(--gold-pale);
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}
.juros-select:focus { outline: none; border-color: var(--navy); }

.juros-erro {
  margin-top: 16px;
  background: var(--wine-bg);
  border: 1px solid var(--wine);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--wine);
}

.juros-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Cartão de destaque do resultado */
.kpi-card.kpi-dark {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border: 1px solid var(--navy);
  border-top: 3px solid var(--gold);
}
.kpi-card.kpi-dark .kpi-label { color: var(--gold-light); }
.kpi-card.kpi-dark .kpi-value { color: #fff; }

.jr-gold { color: var(--gold) !important; }

/* Tabela de evolução */
.juros-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.juros-tbl th {
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold-light);
  background: var(--navy);
  padding: 11px 14px;
  white-space: nowrap;
}
.juros-tbl th:first-child { text-align: left; border-radius: 8px 0 0 8px; }
.juros-tbl th:last-child { border-radius: 0 8px 8px 0; }
.juros-tbl td {
  text-align: right;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.juros-tbl td:first-child { text-align: left; font-weight: 700; color: var(--navy); }
.juros-tbl tr:last-child td { border-bottom: none; }
.juros-tbl tbody tr:hover td { background: var(--gold-pale); }
.juros-tbl .jr-strong { font-weight: 700; color: var(--navy); }

@media (max-width: 640px) {
  .juros-form { grid-template-columns: 1fr; }
  .juros-input { font-size: 16px; } /* evita zoom no iOS */
}

/* ═══════ CORREÇÕES DE ENCOLHIMENTO (mobile) ═══════
   Itens de grid/flex não encolhem abaixo do conteúdo por
   padrão (min-width:auto); estes resets permitem quebrar/
   ajustar em telas estreitas sem alargar a página. */
.juros-field, .juros-input-group { min-width: 0; }
.juros-input { min-width: 0; }
.juros-select { flex: none; }
.tut-card, .tut-head, .tut-title, .tut-steps li { min-width: 0; }
.step-demo { max-width: 100%; }
.step-demo > * { min-width: 0; max-width: 100%; }
.meta-row .f-input { min-width: 0; width: 100%; }
.card canvas { max-width: 100%; }
@media (max-width: 400px) {
  .meta-row { grid-template-columns: 28px 1fr 70px 24px; gap: 6px; }
}

/* ═══════════════════ CARTÕES DE CRÉDITO ═══════════════════ */
.cartoes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.cartao-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--cc, var(--gold));
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.cartao-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.cartao-dot {
  width: 10px; height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--cc, var(--gold));
}
.cartao-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--navy);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cartao-ico { margin-left: auto; color: var(--gold-light); }
.cartao-ico svg { width: 20px; height: 20px; display: block; }

.cartao-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
}

.cartao-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 12px;
  flex-wrap: wrap;
}
.cartao-valor {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.4px;
  font-variant-numeric: tabular-nums;
  color: var(--wine);
}
.cartao-valor.paga { color: var(--green); }
.cartao-valor.zero { color: var(--text-3); }
.cartao-sub { font-size: 11.5px; color: var(--text-3); }

.cartao-paga-btn {
  background: var(--card);
  border: 1.5px solid var(--border-2);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  min-height: 36px;
  transition: background .2s, border-color .2s, color .2s;
}
.cartao-paga-btn:hover { border-color: var(--green); color: var(--green); }
.cartao-paga-btn.paga {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}
.cartao-paga-btn:active { transform: scale(.96); }

.cartao-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-2);
  flex-wrap: wrap;
}
.cartao-foot strong { color: var(--navy); font-variant-numeric: tabular-nums; }

/* Estado vazio */
.cartoes-empty {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--r-lg);
  padding: 30px 24px;
  text-align: center;
}
.cartoes-empty-icon {
  width: 46px; height: 46px;
  margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-pale);
  border-radius: 12px;
  color: var(--gold);
}
.cartoes-empty-icon svg { width: 24px; height: 24px; }
.cartoes-empty strong { display: block; font-size: 15px; color: var(--navy); margin-bottom: 4px; }
.cartoes-empty p {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.65;
  max-width: 420px;
  margin: 0 auto 14px;
}

/* Pill de cartão na tabela de lançamentos */
.pay-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  background: color-mix(in srgb, var(--c) 10%, #fff);
  border: 1px solid var(--border-2);
  border-color: color-mix(in srgb, var(--c) 35%, #fff);
  color: var(--c);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.pay-pill svg { width: 12px; height: 12px; }

/* Linha do modal Gerenciar Cartões */
.card-row {
  display: grid;
  grid-template-columns: 34px 1fr 30px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

/* Texto de apoio nos formulários */
.f-help {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 5px;
}

@media (max-width: 720px) {
  .cartoes-grid { grid-template-columns: 1fr; }
  .cartao-paga-btn { min-height: 44px; padding: 9px 18px; }
}

/* Parcelamento */
.parc-tag {
  display: inline-block;
  background: var(--gold-pale);
  border: 1px solid var(--gold-light);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

.f-static {
  background: var(--gold-pale);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
}

/* Modal Gerenciar Cartões: bloco por cartão */
.card-row2 {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.card-row2 .card-row { border-bottom: none; padding: 0; }
.card-days {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  padding-left: 44px;
  flex-wrap: wrap;
}
.card-day {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.card-day .f-input { width: 108px; padding: 8px 10px; font-size: 13px; }

@media (max-width: 480px) {
  .card-days { padding-left: 0; }
}

/* ═══ Tabelas anuais: páginas largas + rolagem visível ═══ */
#page-contas, #page-entradas { max-width: 1440px; }

.tbl-scroll {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-light) var(--gold-pale);
  padding-bottom: 2px;
}
.tbl-scroll::-webkit-scrollbar { height: 10px; }
.tbl-scroll::-webkit-scrollbar-track { background: var(--gold-pale); border-radius: 99px; }
.tbl-scroll::-webkit-scrollbar-thumb {
  background: var(--gold-light);
  border-radius: 99px;
  border: 2px solid var(--gold-pale);
}
.tbl-scroll::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* Coluna de nomes congelada durante a rolagem horizontal */
.custos-tbl .cell-name,
.custos-tbl .cell-name-total {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  box-shadow: 1px 0 0 var(--border);
}
.custos-tbl .row-grand-total .cell-name-total { background: var(--navy); }
.custos-tbl .row-col-header td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #FAF8F1;
}
.custos-tbl .row-item:hover .cell-name { background: #FCFAF4; }

/* Indicador de sincronização (header) */
.sync-dot {
  width: 9px; height: 9px;
  flex: none;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
}
.sync-dot.ok   { background: #8FCB8F; box-shadow: 0 0 6px rgba(143,203,143,.6); }
.sync-dot.erro { background: #E08585; box-shadow: 0 0 6px rgba(224,133,133,.6); }

/* Botão de ícone no header (backup) */
.btn-header-ico { padding: 8px 10px; }
.btn-header-ico svg { width: 15px; height: 15px; display: block; }
