:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f766e;
  --primary-2: #14b8a6;
  --receita: #059669;
  --despesa: #e11d48;
  --investimento: #7c3aed;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --sidebar: 260px;
  --font: "Manrope", system-ui, sans-serif;
}

html[data-theme="escuro"] {
  color-scheme: dark;
  --bg: #020b16;
  --surface: #071d33;
  --surface-2: #0c3355;
  --text: #f4faff;
  --muted: #c5d9ea;
  --border: rgba(74, 168, 224, 0.28);
  --primary: #7ec8f0;
  --primary-2: #98d466;
  --receita: #34d399;
  --despesa: #fb7185;
  --investimento: #c4b5fd;
  --shadow: 0 16px 40px rgba(2, 11, 22, 0.45);
}

html[data-theme="escuro"] body {
  background-color: #020b16;
  background-image:
    radial-gradient(ellipse 58% 42% at 100% -8%, rgba(31, 143, 212, 0.32), transparent 55%),
    radial-gradient(ellipse 42% 38% at -8% 108%, rgba(122, 193, 67, 0.16), transparent 52%),
    radial-gradient(ellipse 36% 30% at 78% 100%, rgba(255, 143, 31, 0.14), transparent 50%),
    linear-gradient(165deg, #020b16 0%, #071d33 55%, #0c3355 140%);
  background-attachment: fixed;
}

html[data-theme="escuro"] .sidebar,
html[data-theme="escuro"] .card,
html[data-theme="escuro"] .kpi,
html[data-theme="escuro"] .account-card,
html[data-theme="escuro"] .table-wrap,
html[data-theme="escuro"] .modal {
  background: rgba(7, 29, 51, 0.88);
  backdrop-filter: blur(10px);
}

html[data-theme="escuro"] .btn-primary { color: #020b16; }
html[data-theme="escuro"] .avatar { color: #020b16; }
html[data-theme="escuro"] .topbar {
  background: color-mix(in srgb, #020b16 78%, transparent);
}
html[data-theme="escuro"] .card-head h2,
html[data-theme="escuro"] .page-head h1,
html[data-theme="escuro"] .side-nav a,
html[data-theme="escuro"] .mov-list a,
html[data-theme="escuro"] .data-table td {
  color: var(--text);
}
html[data-theme="escuro"] .mov-list small,
html[data-theme="escuro"] .kpi span,
html[data-theme="escuro"] .kpi small,
html[data-theme="escuro"] .kicker,
html[data-theme="escuro"] .muted,
html[data-theme="escuro"] .empty,
html[data-theme="escuro"] .tag,
html[data-theme="escuro"] .data-table th,
html[data-theme="escuro"] .data-table td::before,
html[data-theme="escuro"] .opcional,
html[data-theme="escuro"] .hint,
html[data-theme="escuro"] .brand small,
html[data-theme="escuro"] .user-meta small,
html[data-theme="escuro"] .notify-title,
html[data-theme="escuro"] .back,
html[data-theme="escuro"] .nav-label,
html[data-theme="escuro"] .nav-soon,
html[data-theme="escuro"] .tema-opcao small {
  color: #d6e7f5;
}
html[data-theme="escuro"] ::placeholder {
  color: #9ec0d8;
  opacity: 1;
}
html[data-theme="escuro"] .icon-btn {
  background: #0c3355;
  color: #f4faff;
}
html[data-theme="escuro"] .fab {
  color: #020b16;
}
html[data-theme="escuro"] input:-webkit-autofill,
html[data-theme="escuro"] textarea:-webkit-autofill,
html[data-theme="escuro"] select:-webkit-autofill {
  -webkit-text-fill-color: #f4faff;
  caret-color: #f4faff;
  box-shadow: 0 0 0 1000px #0c3355 inset;
}
html[data-theme="escuro"] .badge.vence_hoje,
html[data-theme="escuro"] .badge.pendente,
html[data-theme="escuro"] tr.vence-hoje td {
  color: #fbbf24;
}
html[data-theme="escuro"] .chip-tipo.ativo.receita {
  background: #064e3b;
  color: #a7f3d0;
}
html[data-theme="escuro"] .chip-tipo.ativo.despesa {
  background: #4c0519;
  color: #fecdd3;
}
html[data-theme="escuro"] .chip-tipo.ativo.transferencia {
  background: #0c4a6e;
  color: #bae6fd;
}
html[data-theme="escuro"] .pill.ativo,
html[data-theme="escuro"] .tab.ativo {
  color: #020b16;
}
html[data-theme="escuro"] code {
  background: #0c3355;
  color: #eef6fc;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  --sidebar-pad-x: 1rem;
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem var(--sidebar-pad-x) 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  z-index: 30;
  flex-shrink: 0;
  transition: width 0.2s ease, padding 0.2s ease, transform 0.2s ease;
}
.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
  flex-shrink: 0;
}
.sidebar-top .brand {
  margin-bottom: 0;
  min-width: 0;
  flex: 1;
}
.sidebar-collapse-btn {
  flex-shrink: 0;
  margin-top: 0.15rem;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.15rem;
  padding-bottom: 0.5rem;
  scrollbar-gutter: stable;
}
.side-nav .nav-label { min-width: 0; }
.side-nav .nav-badge { margin-left: auto; }

html.sidebar-recolhida {
  --sidebar: 76px;
}
html.sidebar-recolhida .sidebar {
  --sidebar-pad-x: 0.55rem;
  padding-left: var(--sidebar-pad-x);
  padding-right: var(--sidebar-pad-x);
}
html.sidebar-recolhida .brand > div,
html.sidebar-recolhida .side-nav .nav-label {
  display: none;
}
html.sidebar-recolhida .brand {
  justify-content: center;
}
html.sidebar-recolhida .sidebar-top {
  flex-direction: column;
  align-items: center;
}
html.sidebar-recolhida .side-nav a {
  justify-content: center;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}
html.sidebar-recolhida .side-nav .nav-badge {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  margin-left: 0;
}
html.sidebar-recolhida .side-nav a {
  position: relative;
}
html.sidebar-recolhida .menu-btn {
  display: grid;
  place-items: center;
}
.brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.5rem; }
.brand-lg {
  margin-bottom: 1rem;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
  background: #000000;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}
.brand-logo-capa {
  width: 96px;
  height: 96px;
  border-radius: 24px;
}
.brand-lockup {
  width: 100%;
  align-items: center;
  margin-bottom: 0.35rem;
}
.brand-logo-full {
  width: min(100%, 280px);
  height: auto;
  border-radius: 20px;
  object-fit: contain;
  background: #000000;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}
.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); }

.side-nav a, .nav-soon {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.65rem 0.8rem; border-radius: 12px;
  color: var(--text);
}
.nav-badge {
  margin-left: auto;
  background: var(--despesa); color: #fff;
  font-size: 0.7rem; font-weight: 800;
  min-width: 1.3rem; height: 1.3rem; border-radius: 999px;
  display: grid; place-items: center; padding: 0 0.3rem;
}
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1.1rem; }
.tab {
  padding: 0.55rem 1rem; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.tab.ativo { background: var(--primary); color: #fff; border-color: transparent; }
.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.dot.pendente { background: #eab308; }
.badge.atrasado, .badge.despesa { color: var(--despesa); }
.badge.vence_hoje, .badge.pendente { color: #b45309; }
.badge.parcial { color: #c2410c; }
.badge.pago, .badge.recebido { color: var(--receita); }
.texto-atrasado,
tr.atrasada,
tr.atrasada td,
tr.atrasada a,
tr.atrasada strong,
tr.atrasada em,
tr.atrasada small,
tr.atrasada td::before {
  color: var(--despesa) !important;
}
tr.atrasada { font-weight: 700; }
tr.vence-hoje td { color: #b45309; }
tr.quitada { opacity: 0.72; }
.notify { position: relative; }
.notify-dot {
  position: absolute; top: -2px; right: -2px;
  background: var(--despesa); color: #fff;
  font-size: 0.65rem; font-weight: 800;
  min-width: 1.1rem; height: 1.1rem; border-radius: 999px;
  display: grid; place-items: center; padding: 0 0.25rem;
}
.notify-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: min(320px, 80vw); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); z-index: 40; overflow: hidden;
}
.notify-title { margin: 0; padding: 0.7rem 0.9rem 0.3rem; font-size: 0.8rem; color: var(--muted); }
.notify-panel a {
  display: block; padding: 0.65rem 0.9rem; border-top: 1px solid var(--border); color: var(--text);
}
.notify-panel a small { display: block; color: inherit; opacity: 0.8; }
.chip-tipo input { display: none; }
.chip-tipo { text-align: center; }
.side-nav a:hover, .side-nav a.ativo { background: var(--surface-2); }
.side-nav a.ativo { color: var(--primary); font-weight: 700; }
.nav-label {
  margin: 1rem 0.8rem 0.3rem; font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.nav-soon { color: var(--muted); opacity: 0.7; cursor: default; }
.ico { width: 1.4rem; display: inline-block; }

.barra {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.45rem;
}
.barra span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
}
.barra.alerta span { background: #eab308; }
.hint-fatura {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}
.data-table input {
  width: 100%;
  min-width: 7rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
}

.main-wrap { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.85rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--border);
}
.search-box {
  flex: 1; display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.45rem 0.9rem; position: relative;
}
.search-box input {
  border: 0; outline: 0; width: 100%; background: transparent; color: var(--text);
}
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.search-results a {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1rem; color: var(--text); border-bottom: 1px solid var(--border);
}
.top-actions { display: flex; align-items: center; gap: 0.45rem; }
.user-chip { display: flex; align-items: center; gap: 0.55rem; color: var(--text); }
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.user-meta small { color: var(--muted); font-size: 0.75rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--primary); color: #022; font-weight: 800;
}

.content { padding: 1.25rem 1.5rem 6rem; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0.15rem 0; font-size: 1.8rem; }
.page-nav-back {
  margin: -0.15rem 0 0.75rem;
}
.btn-voltar {
  padding-left: 0.35rem;
  font-weight: 600;
}
.kicker { margin: 0; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.muted { color: var(--muted); }
.back { color: var(--muted); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
a.kpi-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
a.kpi-link:hover,
a.kpi-link:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent, #0f766e) 45%, var(--border));
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
  outline: none;
}
a.kpi-link .kpi-acao {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.78rem;
  opacity: 0.85;
}
.kpi span { color: var(--muted); font-size: 0.85rem; }
.kpi strong { display: block; font-size: 1.45rem; margin-top: 0.35rem; }
.kpi.receita strong { color: var(--receita); }
.kpi.despesa strong { color: var(--despesa); }
.kpi.investimento strong { color: var(--investimento); }
.kpi.saldo.positivo strong { color: var(--receita); }
.kpi.saldo.negativo strong { color: var(--despesa); }
.kpi small { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.card-head h2 { margin: 0; font-size: 1rem; }
.grid-charts, .grid-2-dash, .grid-2, .account-grid {
  display: grid; gap: 1rem;
}
.grid-charts, .grid-2-dash, .grid-2 { grid-template-columns: 1.3fr 1fr; }
.grid-charts > .card,
.grid-2-dash > .card,
.grid-2 > .card {
  min-width: 0;
  overflow: hidden;
}
.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
}
.chart-wrap--rd { height: 220px; }
.chart-wrap--cat {
  height: auto;
  min-height: 0;
  padding: 0.25rem 0 0.5rem;
}
.chart-cat-box {
  position: relative;
  width: min(240px, 100%);
  height: 280px;
  margin: 0 auto;
}
.chart-wrap--evo { height: 200px; }
.chart-wrap--rd canvas,
.chart-wrap--evo canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 100% !important;
}
.chart-cat-box canvas {
  display: block;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.account-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.account-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; color: var(--text);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.25rem;
}
.account-card h2 { margin: 0.2rem 0; font-size: 1.1rem; }
.account-card strong { font-size: 1.35rem; }
.tag {
  font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}

.mov-list { list-style: none; margin: 0; padding: 0; }
.mov-list li a {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--border); color: var(--text);
}
.mov-list div { flex: 1; }
.mov-list small { display: block; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.receita { background: var(--receita); }
.dot.despesa { background: var(--despesa); }
.dot.investimento { background: var(--investimento); }
.dot.transferencia { background: #0ea5e9; }
.valor.receita { color: var(--receita); }
.valor.despesa, .valor.investimento { color: var(--despesa); }
.hero-valor { font-size: 1.8rem; }
.hero-valor.receita { color: var(--receita); }
.hero-valor.despesa, .hero-valor.investimento { color: var(--despesa); }

.btn {
  border: 0; border-radius: 12px; padding: 0.7rem 1rem;
  cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--primary); color: #042f2e; }
html[data-theme="claro"] .btn-primary { color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--despesa); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--despesa); }
.btn-sm { padding: 0.5rem 0.8rem; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.icon-btn {
  border: 0; background: var(--surface-2); width: 40px; height: 40px;
  border-radius: 12px; cursor: pointer; color: var(--text);
}
.menu-btn { display: none; }
.check-line {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-weight: 600;
}
.check-line input {
  width: auto;
  margin-top: 0.2rem;
}

.filters, .form-inline, .period-pills {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.relatorio-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: end;
  margin: 0 0 1.1rem;
}
.relatorio-filtros .filters {
  margin-bottom: 0;
  align-items: end;
}
.filtro-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.filtro-label input {
  min-width: 150px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
}
.filters input, .filters select, .form-inline input, .form-inline select,
label input, label select, label textarea {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 0.65rem 0.8rem;
  width: 100%;
}
.form-inline input, .form-inline select { width: auto; min-width: 160px; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.9rem; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem 1rem;
  align-items: end;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
@media (max-width: 800px) {
  .form-grid { grid-template-columns: 1fr; }
}
.senha-field {
  position: relative;
  display: block;
  width: 100%;
}
.senha-field input {
  width: 100%;
  padding-right: 5.2rem;
}
.senha-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #0f766e;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}
.senha-toggle:hover,
.senha-toggle:focus-visible {
  background: rgba(15, 118, 110, 0.1);
  outline: none;
}
.auth-card .senha-toggle { color: #0f766e; }
.opcional { font-weight: 500; color: var(--muted); }
.check { flex-direction: row; align-items: center; font-weight: 500; }
.input-valor { font-size: 1.6rem !important; font-weight: 800; }

.tema-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.tema-opcao {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.8rem;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
}
.tema-opcao input {
  position: absolute;
  opacity: 0;
  width: 1px !important;
  height: 1px;
  padding: 0 !important;
  border: 0 !important;
}
.tema-opcao.ativo {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
  background: var(--surface);
}
.tema-opcao strong { font-size: 0.95rem; }
.tema-opcao small { color: var(--muted); font-weight: 500; line-height: 1.3; }
.tema-uso {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tema-preview {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  height: 88px;
}
.tema-preview-top { display: block; height: 18px; }
.tema-preview-body {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 10px;
}
.tema-preview-body span {
  display: block;
  height: 42px;
  border-radius: 8px;
}
.tema-preview-claro { background: #eef2f6; }
.tema-preview-claro .tema-preview-top { background: #fff; border-bottom: 1px solid #e2e8f0; }
.tema-preview-claro .tema-preview-body span:nth-child(1) { background: linear-gradient(#bbf7d0, #fff); }
.tema-preview-claro .tema-preview-body span:nth-child(2) { background: linear-gradient(#fecdd3, #fff); }
.tema-preview-claro .tema-preview-body span:nth-child(3) { background: #fff; }
.tema-preview-escuro { background: #020b16; }
.tema-preview-escuro .tema-preview-top { background: #071d33; border-bottom: 1px solid rgba(74, 168, 224, 0.28); }
.tema-preview-escuro .tema-preview-body span:nth-child(1) { background: linear-gradient(#0d6eb8, #0c3355); }
.tema-preview-escuro .tema-preview-body span:nth-child(2) { background: linear-gradient(#e07800, #0c3355); }
.tema-preview-escuro .tema-preview-body span:nth-child(3) { background: linear-gradient(#5f9e2f, #0c3355); }

.pill {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 0.4rem 0.8rem; cursor: pointer;
}
.pill.ativo { background: var(--primary); color: #fff; border-color: transparent; }

.acoes-parcela {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.btn-mais {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.btn-mais:hover,
.btn-mais:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  outline: none;
}
.btn-mais:active {
  transform: scale(0.94);
}
.btn-mais[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

.menu-popover {
  inset: unset;
  margin: 0;
  position: fixed;
  z-index: 4000;
  min-width: 196px;
  max-width: min(260px, calc(100vw - 1.5rem));
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(2, 11, 22, 0.38);
  display: none;
  flex-direction: column;
  gap: 0.12rem;
}
.menu-popover:popover-open,
.menu-popover.aberto-fallback {
  display: flex;
  animation: menu-popover-in 0.14s ease-out;
}
@keyframes menu-popover-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.menu-popover-titulo {
  margin: 0;
  padding: 0.45rem 0.7rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-popover-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.62rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.menu-popover-item:hover,
.menu-popover-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.menu-popover-item.perigo { color: var(--despesa); }
.menu-popover-item.perigo:hover,
.menu-popover-item.perigo:focus-visible {
  background: color-mix(in srgb, var(--despesa) 14%, var(--surface));
}
.menu-popover-ico {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  opacity: 0.85;
  font-size: 0.95rem;
}
.menu-popover form { margin: 0; }

.modal-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(440px, calc(100vw - 2rem));
}
.modal-dialog::backdrop {
  background: rgba(2, 11, 22, 0.55);
}
.modal-dialog-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  min-width: min(420px, 100%);
}
.modal-dialog-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.modal-dialog-card .card-head h2 { margin: 0; font-size: 1.1rem; }

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.num { text-align: right; }
.badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: var(--surface-2);
}
.badge.receita { color: var(--receita); }
.badge.despesa { color: var(--despesa); }
.badge.investimento { color: var(--investimento); }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0.4rem; }

.flash-stack { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.flash { padding: 0.75rem 1rem; border-radius: 12px; }
.flash-sucesso { background: #d1fae5; color: #065f46; }
.flash-erro { background: #ffe4e6; color: #9f1239; }
.flash-info { background: #e0f2fe; color: #075985; }
html[data-theme="escuro"] .flash-sucesso { background: #064e3b; color: #a7f3d0; }
html[data-theme="escuro"] .flash-erro { background: #4c0519; color: #fecdd3; }
html[data-theme="escuro"] .flash-info { background: #0c4a6e; color: #bae6fd; }

.empty { color: var(--muted); padding: 1rem 0; }
.preview { margin-top: 1rem; border-radius: 12px; border: 1px solid var(--border); }
.danger-zone { border-color: color-mix(in srgb, var(--despesa) 35%, var(--border)); }

.fab {
  display: none; position: fixed; right: 1.1rem; bottom: 1.1rem;
  width: 58px; height: 58px; border-radius: 18px; border: 0;
  background: var(--primary); color: #fff; font-size: 2rem; font-weight: 700;
  box-shadow: var(--shadow); z-index: 40; cursor: pointer;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: end center; z-index: 50; padding: 1rem;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); color: var(--text);
  width: min(520px, 100%); border-radius: 22px 22px 16px 16px;
  padding: 1.1rem 1.2rem 1.3rem; max-height: 92vh; overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.quick-types { display: flex; gap: 0.4rem; margin: 0.9rem 0 1rem; }
.chip-tipo {
  flex: 1; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 12px; padding: 0.55rem 0.3rem; cursor: pointer; color: var(--text);
}
.chip-tipo.ativo.receita { background: #d1fae5; color: #065f46; }
.chip-tipo.ativo.despesa { background: #ffe4e6; color: #9f1239; }
.chip-tipo.ativo.transferencia { background: #e0f2fe; color: #075985; }

.sidebar-backdrop { display: none; }
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  isolation: isolate;
  background: #020b16;
}
.auth-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 52% 48% at 90% 6%, rgba(34, 211, 238, 0.38), transparent 55%),
    radial-gradient(ellipse 36% 34% at 18% 18%, rgba(122, 193, 67, 0.26), transparent 55%),
    radial-gradient(ellipse 50% 48% at 6% 92%, rgba(13, 110, 184, 0.48), transparent 52%),
    radial-gradient(ellipse 34% 32% at 78% 88%, rgba(255, 143, 31, 0.28), transparent 55%),
    linear-gradient(148deg, #020b16 0%, #071d33 34%, #0c3d68 68%, #0d6eb8 120%);
}
.auth-card {
  position: relative;
  width: min(440px, 100%);
  background: #ffffff;
  color: #0f172a;
  border: 0;
  border-radius: 24px;
  padding: 1.7rem 1.6rem 1.4rem;
  box-shadow: 0 28px 64px rgba(2, 11, 22, 0.38);
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(90deg, #22d3ee, #0d6eb8 40%, #7ac143 70%, #ff8f1f);
}
.auth-card h1 { margin: 0.4rem 0; color: #0f172a; }
.auth-card .muted,
.auth-card .hint { color: #64748b; }
.auth-card code { background: #eef2f6; color: #0f172a; }
.hint { color: var(--muted); font-size: 0.85rem; }
code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 6px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-3 { grid-template-columns: 1fr; }
  .grid-charts, .grid-2-dash { grid-template-columns: 1fr; }
  .user-meta { display: none; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; transform: translateX(-105%);
    transition: transform 0.2s ease, width 0.2s ease, padding 0.2s ease;
    width: min(86vw, var(--sidebar));
  }
  html.sidebar-recolhida {
    --sidebar: 260px;
  }
  html.sidebar-recolhida .sidebar {
    --sidebar-pad-x: 1rem;
  }
  html.sidebar-recolhida .brand > div,
  html.sidebar-recolhida .side-nav .nav-label {
    display: initial;
  }
  html.sidebar-recolhida .brand > div {
    display: block;
  }
  html.sidebar-recolhida .side-nav .nav-label {
    display: inline;
  }
  html.sidebar-recolhida .brand {
    justify-content: flex-start;
  }
  html.sidebar-recolhida .sidebar-top {
    flex-direction: row;
    align-items: flex-start;
  }
  html.sidebar-recolhida .side-nav a {
    justify-content: flex-start;
    padding-left: 0.8rem;
    padding-right: 0.8rem;
    position: static;
  }
  html.sidebar-recolhida .side-nav .nav-badge {
    position: static;
    margin-left: auto;
  }
  .sidebar-collapse-btn { display: none; }
  .sidebar.aberto { transform: none; }
  .menu-btn, .fab { display: grid; place-items: center; }
  .sidebar-backdrop.visivel {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25;
  }
  .top-actions .btn { display: none; }
  .data-table thead { display: none; }
  .data-table tr {
    display: block; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border);
  }
  .data-table td {
    display: flex; justify-content: space-between; gap: 1rem;
    border: 0; padding: 0.2rem 0;
  }
  .data-table td::before { content: attr(data-label); color: var(--muted); }
}
