/* =============================================================================================
   Financeiro — design system

   Mundo visual: FinTech premium. Azul #106EBE conduz, menta #0FFCBE marca o que é seu (saldo,
   foco, progresso). Superfícies sólidas com profundidade suave (sombra com deslocamento + borrão,
   nunca halo), vidro só onde há algo atrás para desfocar.

   Os tokens são declarados UMA vez com `light-dark()`: o tema é escolhido por `color-scheme`,
   que segue o sistema ou o `data-theme` gravado pelo static/theme.js. Não existem dois blocos
   escuros para manter em sincronia.
   ============================================================================================= */

@font-face {
  font-family: "Jakarta";
  src: url("/static/fonts/jakarta-latin.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Jakarta";
  src: url("/static/fonts/jakarta-latin-ext.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "InterVar";
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "InterVar";
  src: url("/static/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- tokens ---------------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --brand: #106ebe;
  --mint: #0ffcbe;

  /* superfícies: cinza-azulado frio no claro, azul-noite no escuro (mesmo matiz da marca) */
  --ground: light-dark(#eef2f8, #070c14);
  --surface: light-dark(#ffffff, #0e1724);
  --surface-2: light-dark(#f6f8fc, #142032);
  --surface-3: light-dark(#eceff6, #1b2942);
  --sidebar: light-dark(#ffffff, #0a111c);
  --line: light-dark(#d9e1ee, #1d2b41);
  --line-strong: light-dark(#c2cddf, #2a3c58);
  --hover: light-dark(#eef2f8, #17243a);

  --ink: light-dark(#0a1220, #e9f1fb);
  --muted: light-dark(#566579, #8ba1c0);
  --faint: light-dark(#5d6b7e, #8094ad);

  --accent: light-dark(#0d5c9f, #5cb0f8);
  --accent-ink: light-dark(#ffffff, #04121f);
  --accent-soft: light-dark(#e3eefb, #10263e);
  --accent-line: light-dark(#a9cbef, #1f4a72);

  --pos: light-dark(#04795b, #24e3ac);
  --pos-soft: light-dark(#dff5ee, #06301f);
  --neg: light-dark(#c42a30, #ff6b6b);
  --neg-soft: light-dark(#fdeaea, #33131a);
  --warn: light-dark(#8a5300, #f9b449);
  --warn-soft: light-dark(#fdf1de, #33250c);
  --info: light-dark(#0f5fa6, #58b2ff);
  --info-soft: light-dark(#e5effa, #0d2540);

  /* séries dos gráficos: azul, menta, violeta, âmbar, rosa, ciano */
  --s1: light-dark(#106ebe, #46a6f5);
  --s2: light-dark(#0b9e7c, #0ffcbe);
  --s3: light-dark(#6d4bd8, #a78bfa);
  --s4: light-dark(#b26b00, #f9b449);
  --s5: light-dark(#c03b86, #f472b6);
  --s6: light-dark(#0e7490, #38bdf8);
  --s-other: light-dark(#6b7789, #64768e);
  --grid: light-dark(#e4e9f2, #1a2740);
  --track: light-dark(#e6ebf3, #162236);
  /* A menta só tem contraste suficiente no escuro; no claro o anel de foco é o azul. */
  --focus: light-dark(#0b4a86, #0ffcbe);

  --shadow-1: 0 1px 2px light-dark(rgb(12 27 51 / 6%), rgb(0 0 0 / 40%));
  --shadow-2: 0 2px 4px light-dark(rgb(12 27 51 / 5%), rgb(0 0 0 / 34%)),
    0 8px 20px -6px light-dark(rgb(12 27 51 / 9%), rgb(0 0 0 / 46%));
  --shadow-3: 0 4px 10px light-dark(rgb(12 27 51 / 7%), rgb(0 0 0 / 40%)),
    0 16px 32px -12px light-dark(rgb(12 27 51 / 15%), rgb(0 0 0 / 58%));
  /* no escuro a sombra some no fundo: o relevo vem de uma luz de 1px na aresta de cima */
  --edge: inset 0 1px 0 light-dark(rgb(255 255 255 / 0%), rgb(255 255 255 / 5%));

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --display: "Jakarta", "InterVar", system-ui, "Segoe UI", sans-serif;
  --ui: "InterVar", system-ui, "Segoe UI", -apple-system, sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* --- base e superfícies do navegador --------------------------------------------------------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv05" 1;
  accent-color: var(--accent);
  caret-color: var(--accent);
}

::selection { background: color-mix(in srgb, var(--mint) 34%, transparent); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Em superfície colorida (cartão, botão primário) o anel precisa da menta para aparecer. */
.credit-card :focus-visible, .btn:focus-visible { outline-color: var(--mint); }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(1.5rem, 2.4vw, 1.9rem); }
td, .tx-main strong, .rank .name strong { text-wrap: pretty; }
h2 { font-size: 1.0625rem; letter-spacing: -0.014em; }
h3 { font-size: 0.9375rem; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, currentcolor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentcolor; }

.num, .amt, td.num, th.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 0.8125rem; }
.lead { font-size: 1.0625rem; line-height: 1.6; max-width: 68ch; color: var(--ink); }
/* ATENÇÃO: aplique .sr-only num <div> que ENVOLVE a tabela, nunca na própria <table>.
   Uma tabela não encolhe abaixo do seu conteúdo mínimo, então ignora `width: 1px` e continua
   ocupando centenas de pixels — o que esticava a área de rolagem do Painel em ~2100px de vazio. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* --- estrutura: trilho lateral que empurra o conteúdo ---------------------------------------- */

.shell {
  --rail: 264px;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100dvh;
}
@supports selector(:has(*)) {
  .shell { --rail: 72px; transition: grid-template-columns 0.32s var(--ease); }
  .shell:has(.sidebar:hover), .shell:has(.sidebar:focus-within) { --rail: 264px; transition-delay: 0.05s; }
  .shell:has(.sidebar:hover) .sidebar .label,
  .shell:has(.sidebar:focus-within) .sidebar .label,
  .shell:has(.sidebar:hover) .nav-group > span,
  .shell:has(.sidebar:focus-within) .nav-group > span { opacity: 1; }
  .sidebar .label, .nav-group > span { opacity: 0; transition: opacity 0.2s var(--ease); }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  overflow: hidden auto;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 16px;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.0625rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  flex: none;
  display: grid;
  place-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--brand), color-mix(in srgb, var(--brand) 62%, #04122a));
  color: #fff;
  box-shadow: var(--shadow-2), inset 0 0 0 1px color-mix(in srgb, var(--mint) 42%, transparent);
}
.brand-mark svg { width: 19px; height: 19px; }

.nav-group {
  display: grid;
  gap: 2px;
  margin-top: 10px;
}
.nav-group > span {
  padding: 6px 12px 3px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.16s, color 0.16s;
}
.side-nav a .icon { flex: none; }
.side-nav a:hover { background: var(--hover); color: var(--ink); }
.side-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.side-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 2px;
}
.side-foot form { margin: 0; }
.side-foot button, .side-foot a {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font: inherit; font-size: 0.875rem; text-align: left;
  cursor: pointer; white-space: nowrap;
}
.side-foot button:hover, .side-foot a:hover { background: var(--hover); color: var(--ink); }

.content { padding: 28px clamp(16px, 2.6vw, 38px) 64px; width: 100%; min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-sub { color: var(--muted); margin: 5px 0 0; font-size: 0.875rem; max-width: 64ch; }

.topbar, .tabbar { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--sidebar) 86%, transparent);
    backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--line);
  }
  .topbar .tools { display: flex; gap: 4px; }
  .content { padding: 20px 16px calc(78px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; inset: auto 0 0; z-index: 30;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--sidebar) 88%, transparent);
    backdrop-filter: blur(16px) saturate(150%);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 3px; padding: 7px 2px;
    border-radius: 10px; color: var(--muted); font-size: 0.6875rem; font-weight: 500;
    text-decoration: none;
  }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
}

/* gaveta de navegação no celular (sem JS: <details>) */
.drawer { position: relative; }
.drawer > summary { list-style: none; }
.drawer > summary::-webkit-details-marker { display: none; }
.drawer[open] > summary { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.drawer-body {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  width: min(280px, calc(100vw - 32px));
  max-height: min(70dvh, 560px); overflow: auto;
  padding: 10px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  display: grid; gap: 4px;
}
.drawer-body nav { display: grid; gap: 2px; }
.drawer-title {
  padding: 10px 10px 3px; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint);
}
.drawer-body a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: 9px; color: var(--muted); font-size: 0.875rem; font-weight: 500;
  text-decoration: none;
}
.drawer-body a:hover { background: var(--hover); color: var(--ink); }
.drawer-body a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.drawer-body form { margin: 6px 0 0; padding-top: 8px; border-top: 1px solid var(--line); }
.drawer-body form button { width: 100%; justify-content: center; }
@media (min-width: 900px) { .drawer { display: none; } }

/* --- grade de painéis ------------------------------------------------------------------------ */

/* `stretch` (e não `start`) para que painéis vizinhos terminem na mesma linha: com `start` o
   painel mais curto parava no meio e deixava um degrau visível ao lado do mais alto. */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.dash > section { display: flex; flex-direction: column; }
/* A altura extra vai para a área do gráfico, não para um vão no rodapé do painel. */
.dash > section > .line,
.dash > section > .cf,
.dash > section > .heat,
.dash > section > .hbars-wrap { flex: 1; min-height: 0; }
.dash > section > .cf { display: flex; flex-direction: column; }
.dash > section > .cf .cf-grid { flex: 1; }
.span-12 { grid-column: 1 / -1; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
@media (max-width: 1199px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: 1 / -1; }
}
.stack { display: grid; gap: 16px; }
/* Filho de grade/flex nasce com `min-width: auto` e se recusa a encolher abaixo do próprio
   conteúdo. No celular isso empurrava a página inteira para o lado: a tabela de Dívidas vazava
   441px e a escada de Investimentos, 62px. Com `0` o contêiner volta a mandar e `.table-wrap`
   passa a rolar sozinha, como sempre foi a intenção. */
.stack > *, .grid > *, .grid-2 > *, .dash > section, .dash > .side-stack,
.side-stack > *, .cards-grid > * { min-width: 0; }

/* Coluna com dois painéis menores empilhados dentro de uma célula da grade do painel.
   `start` e não `stretch`: os dois juntos não precisam esticar até a altura do vizinho alto. */
.dash > .side-stack { display: grid; gap: 16px; align-content: start; }

/* Lista compacta para quando o ranking divide a coluna com outro painel. */
.rank.compact li { padding: 9px 0; }
.rank.compact .name strong { font-size: 0.875rem; }
.rank.compact .muted { font-size: 0.75rem; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1), var(--edge);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 { display: flex; align-items: center; gap: 9px; }
.panel-head h2 .icon { color: var(--accent); }
.panel.fill { display: flex; flex-direction: column; }
.panel.fill > .hbars-wrap { flex: 1; align-content: center; }

/* --- controles ------------------------------------------------------------------------------- */

.btn, button.secondary, .secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s, border-color 0.16s, transform 0.12s var(--ease), box-shadow 0.16s;
}
.btn {
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-2);
}
.btn:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn:active { transform: translateY(1px); }
button.secondary, .secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-1), var(--edge);
  text-decoration: none;
}
button.secondary:hover, .secondary:hover { background: var(--hover); border-color: var(--faint); }
.btn[disabled], button[disabled], .secondary[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.danger, button.danger { background: var(--neg); color: #fff; border-color: transparent; box-shadow: var(--shadow-1); }
.btn.danger:hover, button.danger:hover { background: color-mix(in srgb, var(--neg) 86%, #000); }

.icon-btn {
  display: inline-grid; place-content: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--muted); cursor: pointer;
  box-shadow: var(--shadow-1), var(--edge);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

svg.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentcolor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.side-nav a.active .icon, .tabbar a.active .icon { stroke-width: 2.1; }
/* feedback de carregamento do HTMX */
button.htmx-request svg.icon { animation: spin 0.9s linear infinite; }
button.htmx-request { opacity: 0.7; pointer-events: none; }

input, select, textarea {
  font: inherit;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  width: 100%;
  min-width: 0;
}
input:hover, select:hover { border-color: var(--faint); }
input::placeholder { color: var(--faint); }
label { display: grid; gap: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--muted);
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 99px;
  background: currentcolor; flex: none;
}
.badge.ok { background: var(--pos-soft); color: var(--pos); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--neg-soft); color: var(--neg); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.plain::before { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--muted); font-size: 0.8125rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.chip:hover { background: var(--hover); color: var(--ink); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a, .tabs button {
  padding: 7px 14px; border-radius: 99px; border: 1px solid transparent;
  background: none; color: var(--muted); font: inherit; font-size: 0.8125rem;
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.tabs a:hover, .tabs button:hover { background: var(--hover); color: var(--ink); }
.tabs a.active, .tabs button.active { background: var(--accent-soft); color: var(--accent); }

/* botão de tema: mostra só o ícone do modo ativo (theme.js grava data-mode) */
[data-theme-toggle] .m-light, [data-theme-toggle] .m-dark { display: none; }
[data-theme-toggle] .m-auto { display: inline-flex; }
:root[data-theme="light"] [data-theme-toggle] .m-auto,
:root[data-theme="dark"] [data-theme-toggle] .m-auto { display: none; }
:root[data-theme="light"] [data-theme-toggle] .m-light,
:root[data-theme="dark"] [data-theme-toggle] .m-dark { display: inline-flex; }
[data-theme-toggle] span { display: inline-flex; }

/* plano de ação da IA */
.ai-plan h3 { font-size: 0.9375rem; margin: 18px 0 7px; }
.ai-plan .lead { margin-bottom: 12px; }
code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-size: 0.875em; padding: 1px 6px; border-radius: 5px;
  background: var(--surface-3); color: var(--ink);
}
.badge.accent { background: var(--accent); color: var(--accent-ink); }
.badge.accent::before { background: currentcolor; }

/* --- cockpit: a faixa do patrimônio ---------------------------------------------------------- */

.cockpit {
  position: relative;
  overflow: hidden;
  padding: 26px 26px 22px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-2), var(--edge);
}
.cockpit::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--mint) 62%, transparent);
}
.greeting { font-size: 0.875rem; color: var(--muted); }
.greeting strong { color: var(--ink); font-weight: 600; }
.hero-value {
  font-family: var(--display);
  font-size: clamp(2.1rem, 5.4vw, 3.15rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.04;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 2px;
}
.hero-value.neg { color: var(--neg); }
.delta { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; font-weight: 600; }
.delta.pos { color: var(--pos); }
.delta.neg { color: var(--neg); }
.delta .muted { font-weight: 400; }

/* tira de números: hairlines entre as colunas, sem virar quatro cartõezinhos iguais */
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 20px;
  /* O fundo é a própria superfície: com o truque de `gap` sobre a cor da linha, uma linha
     incompleta (6 números em 4 colunas) deixava um bloco vazio à mostra. */
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--line);
}
.strip > div {
  padding: 13px 16px;
  box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
}
.strip dt, .strip .label {
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
  letter-spacing: 0.01em; margin: 0;
}
.strip dd, .strip .val {
  margin: 3px 0 0; font-size: 1.125rem; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  font-family: var(--display);
}
.strip .val.pos, .strip dd.pos { color: var(--pos); }
.strip .val.neg, .strip dd.neg { color: var(--neg); }
.strip .val.mint { color: light-dark(#04795b, var(--mint)); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 22px; margin: 16px 0 0; }
.kv dt { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.kv dd { margin: 3px 0 0; font-variant-numeric: tabular-nums; font-weight: 600; }

/* escada de etapas (quando sobra dinheiro) */
.ladder {
  list-style: none; margin: 20px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px;
  counter-reset: step;
}
.ladder li {
  counter-increment: step;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 0.8125rem; color: var(--muted);
}
.ladder li::before {
  content: counter(step);
  display: grid; place-content: center; flex: none;
  width: 21px; height: 21px; border-radius: 99px;
  background: var(--track); color: var(--faint);
  font-size: 0.6875rem; font-weight: 700;
}
.ladder li.on {
  background: var(--accent-soft); border-color: transparent;
  color: var(--accent); font-weight: 600;
}
.ladder li.on::before { background: var(--accent); color: var(--accent-ink); }

/* --- gráficos -------------------------------------------------------------------------------- */

.line { position: relative; margin-top: 14px; min-height: 180px; color: var(--accent); }
.line svg { display: block; width: 100%; height: 100%; min-height: 180px; overflow: visible; }
.line .grid { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 5; }
.line .area { fill: url(#netfill); }
.line .stroke {
  fill: none; stroke: var(--accent); stroke-width: 2.25;
  stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke;
}
.line .end {
  position: absolute; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--accent) 34%, transparent);
}
.line .lo, .line .hi {
  position: absolute; left: 0; font-size: 0.6875rem; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  padding: 0 5px; border-radius: 4px; font-variant-numeric: tabular-nums;
}
.line .hi { top: 0; } .line .lo { bottom: 0; }
.axis { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 8px; }

/* barras horizontais: partes de um total */
.hbars-wrap { display: grid; gap: 15px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 15px; }
.hbars li { display: grid; gap: 7px; }
.hbars .row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; font-size: 0.875rem; }
.hbars .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hbars .val { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hbars .val em { font-style: normal; font-weight: 500; color: var(--muted); margin-left: 9px; }
.hbars .track { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.hbars .bar {
  display: block; height: 100%; width: var(--w); min-width: 5px;
  background: var(--c); border-radius: inherit; transform-origin: left center;
}
.hbars-total {
  display: flex; justify-content: space-between; gap: 14px; margin: 0; padding-top: 13px;
  border-top: 1px solid var(--line); font-size: 0.875rem;
}
.hbars-total span { color: var(--muted); }
.hbars-total strong { font-variant-numeric: tabular-nums; }
.s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); }
.s4 { --c: var(--s4); } .s5 { --c: var(--s5); } .s6 { --c: var(--s6); }
.s-other { --c: var(--s-other); }

/* medidores de saúde: barra com marca no limite de alerta */
.gauges { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 640px) and (max-width: 1199px) { .gauges { grid-template-columns: 1fr 1fr; } }
.meter { display: grid; gap: 6px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meter-name { font-weight: 600; font-size: 0.875rem; }
.meter-value {
  font-family: var(--display); font-size: 1.5rem; font-weight: 700;
  letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.meter[data-state="danger"] .meter-value { color: var(--neg); }
.meter-track { position: relative; height: 10px; border-radius: 99px; background: var(--track); margin: 5px 0 3px; }
.meter-fill {
  position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), light-dark(#04795b, var(--mint)));
}
.meter[data-state="danger"] .meter-fill { background: var(--neg); }
.meter-tick {
  position: absolute; top: -4px; bottom: -4px; left: var(--at); width: 2px; margin-left: -1px;
  background: var(--ink); opacity: 0.45; border-radius: 1px;
}
.meter .muted { display: block; }

/* fluxo de caixa */
.cf { display: grid; gap: 10px; margin-top: 14px; }
.cf-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.cf-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; min-height: 170px; }
/* `minmax(0, 15px)` em vez de largura fixa: 15px é o teto, não o piso. Com largura fixa as seis
   colunas do ano somavam mais que a tela a 360px e empurravam a página para o lado. */
.cf-col {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 15px);
  gap: 4px; align-items: end; height: 100%; justify-content: center;
}
.cf-col i {
  display: block; width: 100%; border-radius: 5px 5px 2px 2px;
  height: var(--h); min-height: 3px; transform-origin: bottom center;
}
.cf-col i.income { background: linear-gradient(180deg, light-dark(#0b9e7c, #0ffcbe), light-dark(#04795b, #12b489)); }
.cf-col i.expense { background: linear-gradient(180deg, var(--neg), color-mix(in srgb, var(--neg) 70%, #000)); }
.cf-cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; text-align: center; font-size: 0.75rem; color: var(--muted); }
.legend { display: flex; gap: 16px; align-items: center; font-size: 0.8125rem; color: var(--muted); }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; }
.dot.income { background: light-dark(#0b9e7c, #0ffcbe); }
.dot.expense { background: var(--neg); }

/* mapa de calor */
.heat { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 1fr); font-size: 0.6875rem; color: var(--muted); align-items: center; }
.heat-grid { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; gap: 3px; }
.heat-grid i { display: block; height: 17px; border-radius: 4px; background: var(--track); }
.heat-grid i.blank { background: none; }
.heat-grid i[data-l="1"] { background: color-mix(in srgb, var(--neg) 42%, var(--track)); }
.heat-grid i[data-l="2"] { background: color-mix(in srgb, var(--neg) 62%, var(--track)); }
.heat-grid i[data-l="3"] { background: color-mix(in srgb, var(--neg) 81%, var(--track)); }
.heat-grid i[data-l="4"] { background: var(--neg); }
.heat-scale { display: flex; align-items: center; gap: 5px; justify-content: flex-end; font-size: 0.6875rem; color: var(--muted); margin-top: 8px; }
.heat-scale i { width: 13px; height: 13px; border-radius: 4px; display: block; }
@media (max-width: 560px) { .heat-grid i { height: 14px; } .heat-grid { gap: 2px; } }
@media (max-width: 560px) { .cf-bars, .cf-cols { gap: 5px; } .cf-col { gap: 3px; } }


/* --- alertas --------------------------------------------------------------------------------- */

.alerts { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 9px; }
.alert {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 12px 15px; border-radius: var(--r);
  background: var(--info-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--info) 22%, transparent);
}
.alert .icon { margin-top: 1px; color: var(--info); }
.alert.warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.alert.warning .icon { color: var(--warn); }
.alert.danger { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 26%, transparent); }
.alert.danger .icon { color: var(--neg); }
p.alert { margin: 0 0 18px; }
.alerts-block h2 { margin-bottom: 4px; }
@media (max-width: 1199px) { .dash > .notice { order: -1; } }

/* --- tabelas e listas ------------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--faint); padding: 0 12px 9px; white-space: nowrap;
}
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
th.num, td.num { text-align: right; }
.amount-status { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
tbody tr:hover td { background: var(--hover); }
tfoot th { border-top: 1px solid var(--line-strong); padding-top: 12px; font-size: 0.8125rem; text-transform: none; letter-spacing: 0; color: var(--ink); }

.rank { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; }
.rank li {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 12px; border-radius: var(--r); margin: 0 -12px;
}
.rank li:hover { background: var(--hover); }
.rank .name { display: grid; gap: 2px; min-width: 0; }
.rank .name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- cartões de crédito ---------------------------------------------------------------------- */

.cards-grid {
  display: grid; gap: 18px;
  /* `min()` evita que a trilha mínima estoure o contêiner a 360px. */
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
}
.credit-card {
  position: relative;
  aspect-ratio: 1.585;
  min-height: 200px;
  padding: 22px;
  border-radius: var(--r-xl);
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: linear-gradient(140deg, var(--c1), var(--c2));
  box-shadow: var(--shadow-3);
  --c1: #1b3a63; --c2: #0c1c30;
}
.credit-card[data-brand="VISA"] { --c1: #1a4f9c; --c2: #0a1f45; }
.credit-card[data-brand="MASTERCARD"] { --c1: #8a3a1f; --c2: #2b1008; }
.credit-card[data-brand="ELO"] { --c1: #1f2933; --c2: #050709; }
.credit-card[data-brand="AMEX"] { --c1: #0a5760; --c2: #032226; }
.credit-card[data-brand="HIPERCARD"] { --c1: #94222a; --c2: #2c0709; }
.credit-card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(90% 120% at 82% 6%, rgb(255 255 255 / 20%), transparent 58%);
  pointer-events: none;
}
.credit-card::after {
  content: "";
  position: absolute; inset: auto -22% -58% auto; width: 78%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--mint) 24%, transparent), transparent 66%);
  pointer-events: none;
}
.credit-card > * { position: relative; }
.cc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cc-bank { font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; font-size: 0.9375rem; }
/* Texto secundário sobre o gradiente é tingido a partir dele, não esmaecido: opacidade
   em 11px come o antialias e derruba o contraste abaixo de 4,5:1. */
.cc-sub { font-size: 0.75rem; color: #dbe7f5; }
.cc-brand { font-family: var(--display); font-weight: 800; font-size: 0.8125rem; letter-spacing: 0.1em; }
.cc-chip {
  width: 38px; height: 28px; border-radius: 6px; align-self: center;
  background: linear-gradient(135deg, #e8d49a, #b08f45 52%, #f2e4b4);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 14%);
}
.cc-mid { display: flex; align-items: center; gap: 16px; }
.cc-number { font-size: 1.0625rem; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
.cc-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.cc-foot .label {
  font-size: 0.6875rem; color: #cfe0f2;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.cc-foot .val { font-family: var(--display); font-weight: 700; font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
.cc-usage { margin-top: 12px; height: 5px; border-radius: 99px; background: rgb(255 255 255 / 22%); overflow: hidden; }
.cc-usage i { display: block; height: 100%; width: var(--w); background: var(--mint); border-radius: inherit; }

/* --- cartões de conta, dívida e plano -------------------------------------------------------- */

.entity {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1), var(--edge);
}
.entity:hover { border-color: var(--line-strong); }
.entity-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.entity-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.entity-title h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex: none; display: grid; place-content: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--display); font-weight: 800; font-size: 0.875rem;
}
.avatar[data-source="registrato"] { background: color-mix(in srgb, var(--s3) 16%, transparent); color: var(--s3); }
.avatar[data-source="manual"] { background: var(--pos-soft); color: var(--pos); }
.entity-figure {
  font-family: var(--display); font-size: 1.5rem; font-weight: 700;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.entity-figure.neg { color: var(--neg); }
.entity-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 13px; border-top: 1px solid var(--line); }
.entity-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.progress { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress i {
  display: block; height: 100%; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), light-dark(#04795b, var(--mint)));
}
.progress.warn i { background: var(--warn); }
.progress.err i { background: var(--neg); }

/* --- movimentações --------------------------------------------------------------------------- */

.tx-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.tx {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
}
.tx:hover { background: var(--hover); }
.tx-icon {
  display: grid; place-content: center; width: 38px; height: 38px; border-radius: 11px;
  background: var(--surface-3); color: var(--muted);
}
.tx[data-dir="in"] .tx-icon { background: var(--pos-soft); color: var(--pos); }
.tx-main { min-width: 0; display: grid; gap: 2px; }
.tx-main strong { font-weight: 600; font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 0.75rem; color: var(--muted); }
.tx-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.tx-amount { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.02em; }
.tx[data-dir="in"] .tx-amount { color: var(--pos); }
.tx-day { position: sticky; top: 0; padding: 9px 16px; background: var(--surface-2); font-size: 0.75rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters label { font-size: 0.6875rem; }
.filters .field { display: grid; gap: 5px; min-width: 140px; }
.filters .grow { flex: 1 1 220px; }

/* --- planos de ação -------------------------------------------------------------------------- */

.plan { margin: 0; padding-left: 1.25rem; display: grid; gap: 15px; max-width: 78ch; }
.plan li::marker { color: var(--accent); font-weight: 700; }
.plan strong { font-weight: 600; }
.plan ul { margin: 7px 0 0; padding-left: 1.1rem; display: grid; gap: 5px; color: var(--muted); }
.plan-notes { max-width: 78ch; margin: 8px 0 0; padding-left: 1.1rem; color: var(--muted); display: grid; gap: 5px; }

.tasks { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--surface); }
.task:hover { background: var(--hover); }
.task input[type="checkbox"] { width: 19px; height: 19px; margin: 1px 0 0; flex: none; cursor: pointer; }
.task .body { display: grid; gap: 3px; min-width: 0; flex: 1; }
.task.done .body strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.task label { font-size: inherit; font-weight: inherit; color: inherit; cursor: pointer; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; display: grid; gap: 18px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 5px; bottom: 5px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline li { position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -22px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong);
}
.timeline li.on::before { background: var(--accent); border-color: var(--accent); }

/* paginação, detalhes do cartão e do plano */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pager .muted { font-variant-numeric: tabular-nums; }

.card-slot { display: grid; gap: 10px; align-content: start; }
.card-detail > summary {
  list-style: none; cursor: pointer; padding: 9px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface);
  font-size: 0.8125rem; font-weight: 600; color: var(--muted); text-align: center;
}
.card-detail > summary::-webkit-details-marker { display: none; }
.card-detail > summary:hover { background: var(--hover); color: var(--ink); }
.card-detail[open] > summary { color: var(--accent); border-color: var(--accent-line); }
.card-detail-body {
  margin-top: 10px; padding: 18px; border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1), var(--edge);
}

details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .icon { margin-left: auto; color: var(--faint); transition: transform 0.2s var(--ease); }
details.panel[open] > summary .icon { transform: rotate(180deg); }

.plan-card .avatar { font-size: 0.8125rem; letter-spacing: -0.03em; white-space: nowrap; }
.plan-card .avatar small { font-size: 0.5625rem; font-weight: 600; opacity: 0.75; margin-left: 1px; }
.plan-card[data-status="atrasado"] .avatar { background: var(--neg-soft); color: var(--neg); }
.plan-card[data-status="concluido"] .avatar { background: var(--pos-soft); color: var(--pos); }
.plan-card .task form { margin: 0; display: flex; }

/* --- estados --------------------------------------------------------------------------------- */

.empty {
  display: grid; justify-items: center; gap: 12px; text-align: center;
  padding: 44px 24px; color: var(--muted);
}
.empty .icon-wrap {
  display: grid; place-content: center; width: 54px; height: 54px; border-radius: 16px;
  background: var(--surface-3); color: var(--faint);
}
.empty .icon-wrap .icon { width: 24px; height: 24px; }
.empty h3 { color: var(--ink); }
.empty p { max-width: 46ch; font-size: 0.875rem; }

.skeleton {
  background: linear-gradient(90deg, var(--track), var(--surface-3) 46%, var(--track));
  background-size: 220% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

.notice {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line);
}

/* --- páginas específicas --------------------------------------------------------------------- */

/* --- seleção em lote --------------------------------------------------------------------------
   A barra gruda no topo quando há algo marcado: em tabela longa, a ação precisa continuar ao
   alcance sem rolar de volta. */

.bulk-bar {
  position: sticky; top: 12px; z-index: 3;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: var(--r);
  background: color-mix(in srgb, var(--accent-soft) 88%, var(--surface));
  box-shadow: var(--shadow-2);
}
.bulk-bar[hidden] { display: none; }
.bulk-count { font-size: 0.875rem; color: var(--ink); margin-right: auto; }
.bulk-count strong { font-variant-numeric: tabular-nums; }
.bulk-note { font-size: 0.75rem; }
@media (max-width: 720px) { .bulk-note { display: none; } }

th.pick, td.pick { width: 36px; padding-right: 0; }
td.pick input, th.pick input { width: 17px; height: 17px; margin: 0; cursor: pointer; accent-color: var(--brand); }

/* Aviso do fluxo de conexão (abre o widget da Pluggy direto, sem caixa no meio). */
.connect-status { margin: 0; font-size: 0.875rem; color: var(--muted); }
.connect-status:empty { display: none; }

/* --- identidade das instituições, bandeiras e categorias --------------------------------------
   Sem logo de banco no repositório (marca de terceiro + dependência de rede). A identidade sai do
   nome: iniciais sobre a cor real da marca. Ver services/brands.py. */

.inst {
  display: inline-grid; place-content: center; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--inst); color: var(--inst-ink, #fff);
  /* A tinta vem calculada por contraste (services/brands.py): fixar branco reprovava em
     17 das 37 cores de marca — branco no amarelo do Will dava 1,79:1. */
  font-family: var(--display); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.02em;
  /* Contorno interno para a marca não encostar na superfície, em qualquer cor de fundo. */
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%);
  overflow: hidden;
}
/* Com logo de verdade o selo vira uma placa clara: o logo já traz a cor da marca, e pintar o
   fundo com ela de novo esconderia metade do desenho. Sem logo, a cor da marca É a identidade. */
.inst.has-logo { background: #fff; box-shadow: inset 0 0 0 1px var(--line); padding: 4px; }
.inst img { width: 100%; height: 100%; object-fit: contain; }
.inst.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 0.625rem; }
.inst.lg { width: 44px; height: 44px; border-radius: 13px; font-size: 0.9375rem; }

.flag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 6px;
  background: var(--flag-bg); color: var(--flag-ink);
  font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 20%);
}

.cat-icon {
  display: inline-grid; place-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--surface-3); color: var(--muted);
}
.cat-icon .icon { width: 17px; height: 17px; }

/* Marca + texto lado a lado, sem o texto escorregar para baixo do ícone. */
.cell-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* `grid` e não um span comum: `<strong>` é inline, e `overflow: hidden` não vale para inline —
   a reticência de nome longo só volta a funcionar quando o pai blocifica os filhos. */
.cell-mark > .cm-text { display: grid; gap: 2px; min-width: 0; }
.cell-mark > .cm-text > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-bank { display: flex; align-items: center; gap: 8px; }
tr:hover .cat-icon, li:hover .cat-icon { color: var(--accent); }

/* --- entrar ----------------------------------------------------------------------------------
   Duas colunas: a arte conta o que o app faz, o formulário fica numa coluna estreita e calma.
   A arte é um SVG desenhado (app/static/auth-bg.svg), não uma foto: sem licença para resolver,
   sem CDN e nítido em qualquer densidade de tela. */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  background: var(--ground);
}

.auth-art {
  position: relative;
  display: flex; align-items: flex-end;
  padding: 52px;
  overflow: hidden;
  background: #071527 url("/static/auth-bg.svg") center / cover no-repeat;
  /* O painel é escuro nos DOIS temas: a arte é desenhada em azul e menta, e trocar o fundo
     embaixo dela derrubaria o contraste do texto que fica por cima. */
  color-scheme: dark;
}
/* `rem`, não `ch`: `ch` mede na fonte do corpo (16px) e espremia um título de 38px em 5 linhas. */
/* Véu entre a arte e o texto. Sem ele, onde a linha azul clara do gráfico passa por baixo do
   texto o contraste cai para 2,04:1 (medido rasterizando o SVG) — abaixo dos 4,5:1 exigidos.
   O véu é forte no canto de baixo à esquerda, onde o texto fica, e some no canto oposto, para a
   arte continuar respirando. */
.auth-art::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top right,
    rgb(3 9 18 / 92%) 0%,
    rgb(3 9 18 / 78%) 30%,
    rgb(3 9 18 / 34%) 55%,
    rgb(3 9 18 / 0%) 78%);
}
.auth-art-body { position: relative; max-width: 30rem; }

.auth-eyebrow {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mint); margin: 0 0 18px;
}
.auth-headline {
  font-family: var(--display);
  font-size: clamp(1.65rem, 2.7vw, 2.4rem);
  font-weight: 700; line-height: 1.18; letter-spacing: -0.02em;
  color: #f3f8ff; margin: 0;
}
.auth-headline em { font-style: normal; color: var(--mint); }

.auth-points { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 13px; max-width: 34ch; }
.auth-points li {
  display: flex; align-items: flex-start; gap: 11px;
  font-size: 0.875rem; line-height: 1.45; color: #c2d6ec;
}
.auth-points .icon { flex: none; margin-top: 1px; color: var(--mint); }

.auth-form { display: grid; place-items: center; padding: 32px 24px; }
.auth-card {
  width: 100%; max-width: 396px; padding: 34px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-3), var(--edge);
  display: grid; gap: 20px;
}
.auth-intro h1 { font-size: 1.75rem; margin: 0 0 5px; }
.auth-intro p { margin: 0; }
.auth-card .alert { margin: 0; }

.auth-fields { display: grid; gap: 15px; }
.auth-fields input { padding: 11px 13px; background: var(--surface-2); }
.auth-submit { width: 100%; justify-content: center; padding: 12px 16px; font-size: 0.9375rem; }

.auth-foot {
  display: flex; align-items: flex-start; gap: 9px;
  margin: 0; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 0.8125rem; line-height: 1.45; color: var(--faint);
}
.auth-foot .icon { flex: none; margin-top: 1px; }

.auth-theme { position: fixed; top: 18px; right: 18px; z-index: 2; }

/* O amarelo do autopreenchimento do Chrome/Edge ignora `background` e só cede a um `box-shadow`
   interno. Sem isto os campos ficam mostarda sobre o tema escuro, como já aconteceu. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  box-shadow: inset 0 0 0 100px var(--surface-2);
  caret-color: var(--ink);
  transition: background-color 600000s 0s;
}

/* Abaixo de 900px a arte deixa de ser coluna e passa a ser o fundo da página inteira, com o
   cartão flutuando sobre ela — a imagem continua à vista, sem roubar a primeira dobra. */
@media (max-width: 899px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art {
    position: fixed; inset: 0; z-index: 0;
    padding: 0; align-items: stretch;
  }
  .auth-art::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgb(4 11 22 / 55%), rgb(4 11 22 / 78%));
  }
  .auth-art-body { display: none; }
  .auth-form { position: relative; z-index: 1; min-height: 100dvh; }
  .auth-card { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); }
}
@media (max-width: 420px) { .auth-card { padding: 24px; } }

.guide { display: grid; gap: 2px; margin: 0; }
.guide-row { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); align-items: start; gap: 18px; padding: 15px 0; border-top: 1px solid var(--line); }
.guide dt a { display: inline-flex; align-items: center; gap: 10px; }
.guide dt { font-weight: 600; }
.guide dt .icon { color: var(--accent); flex: none; }
.guide dd { margin: 0; max-width: 68ch; color: var(--muted); font-size: 0.875rem; }
@media (max-width: 640px) { .guide-row { grid-template-columns: 1fr; gap: 5px; } }

.steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 11px; max-width: 68ch; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.mvv { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mvv p { max-width: 46ch; color: var(--muted); font-size: 0.875rem; }
.values { margin: 0; padding: 0; list-style: none; display: grid; gap: 11px; max-width: 68ch; }
.values li { display: grid; gap: 3px; }

.upload { display: grid; gap: 12px; }
.strategy-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: rankn; }
.priority { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.priority .rank-n {
  flex: none; display: grid; place-content: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--surface-3); color: var(--muted); font-family: var(--display); font-weight: 800; font-size: 0.875rem;
}
.priority:first-child .rank-n { background: var(--accent); color: var(--accent-ink); }

.remove summary { cursor: pointer; color: var(--muted); font-size: 0.8125rem; list-style: none; }
.remove summary::-webkit-details-marker { display: none; }
.remove summary:hover { color: var(--neg); }
.remove[open] summary { color: var(--neg); font-weight: 600; }
.remove .body { margin-top: 12px; padding: 14px; border-radius: var(--r); background: var(--neg-soft); border: 1px solid color-mix(in srgb, var(--neg) 22%, transparent); display: grid; gap: 11px; }
.remove label { display: flex; align-items: center; gap: 9px; font-weight: 500; color: var(--ink); font-size: 0.875rem; }
.remove input[type="checkbox"] { width: auto; }

.nick { display: flex; gap: 8px; align-items: center; }
.nick input { max-width: 220px; }

/* --- movimento: uma entrada, só na 1ª carga -------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  body:not(.swapped) .dash > *,
  body:not(.swapped) .content > .page-head,
  body:not(.swapped) .content > .panel,
  body:not(.swapped) .content > .stack > * {
    animation: rise 0.52s var(--ease) backwards;
  }
  .dash > *:nth-child(2) { animation-delay: 0.045s; }
  .dash > *:nth-child(3) { animation-delay: 0.09s; }
  .dash > *:nth-child(4) { animation-delay: 0.135s; }
  .dash > *:nth-child(5) { animation-delay: 0.18s; }
  .dash > *:nth-child(6) { animation-delay: 0.225s; }
  .dash > *:nth-child(7) { animation-delay: 0.27s; }
  body:not(.swapped) .hbars .bar,
  body:not(.swapped) .meter-fill,
  body:not(.swapped) .progress i,
  body:not(.swapped) .cc-usage i { animation: growx 0.72s var(--ease) 0.12s backwards; }
  body:not(.swapped) .cf-col i { animation: growy 0.66s var(--ease) 0.1s backwards; }
  @keyframes growx { from { transform: scaleX(0); } }
  @keyframes growy { from { transform: scaleY(0); } }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); filter: blur(3px); } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media print {
  .sidebar, .topbar, .tabbar, .actions { display: none; }
  .shell { display: block; }
  .panel { box-shadow: none; break-inside: avoid; }
}

/* Telas de 320px (iPhone SE, Androids antigos). Três folgas que cabem no desktop mas estouram
   aqui: o respiro do painel, o `min-height` do cartão brigando com a proporção fixa (200 × 1,585
   = 317px de largura mínima, mais do que a tela tem) e o vão entre rótulo e valor nas barras. */
@media (max-width: 400px) {
  .panel, .cockpit { padding: 15px; }
  .credit-card { min-height: 0; padding: 17px; }
  .hbars .row { gap: 8px; }
  .table-wrap { margin: 0; padding: 0; }
  /* A marca da instituição mais o selo de status não cabem lado a lado nesta largura. */
  .entity-head { flex-wrap: wrap; }
  .inst.lg { width: 36px; height: 36px; border-radius: 11px; font-size: 0.8125rem; }
}
