/* =========================================================================
   Financeiro 360 — sistema visual (ver docs/DESIGN_SYSTEM.md)
   Estilo: minimalista/suíço para dados. Paleta: confiança (marinho) + acento dourado.
   Camadas: primitivas → semânticas → componentes. Componentes usam só tokens semânticos.
   ========================================================================= */
@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-latin.woff2") format("woff2");
}

:root {
  /* primitivas */
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1; --slate-400: #94a3b8;
  --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155; --slate-800: #1e293b; --slate-900: #0f172a; --slate-950: #020617;
  --navy-50: #eef2ff; --navy-100: #e0e7ff; --navy-600: #2f4fb8; --navy-700: #1e40af; --navy-800: #1e3a8a;
  --gold-500: #ca8a04; --gold-700: #a16207;
  --green-50: #ecfdf5; --green-700: #047857; --red-50: #fef2f2; --red-700: #b91c1c; --amber-50: #fffbeb; --amber-700: #b45309; --blue-50: #eff6ff; --blue-700: #1d4ed8;

  /* semânticas — tema único escuro (referência: painel verde-neon sobre quase-preto) */
  --mint-300: #6ff5c6; --mint-400: #2ee6a6; --mint-500: #14d38f; --mint-900: #0b2a20;
  --bg: #070b09; --surface: #0d1411; --surface-2: #121c18; --surface-3: #1a2822;
  --text: #ecf5f1; --text-2: #a7b8b0; --text-3: #7d9188;
  --border: rgb(46 230 166 / .14); --border-strong: rgb(46 230 166 / .28);
  --primary: var(--mint-400); --primary-hover: var(--mint-300); --on-primary: #04130d; --primary-soft: rgb(46 230 166 / .12); --primary-text: var(--mint-300);
  --accent: var(--mint-400);
  --positive: #34e3a0; --positive-bg: rgb(52 227 160 / .12);
  --negative: #ff6b6b; --negative-bg: rgb(255 107 107 / .12);
  --warning: #f5c451; --warning-bg: rgb(245 196 81 / .12);
  --info: #7cc7ff; --info-bg: rgb(124 199 255 / .1);
  --neutral-bg: rgb(255 255 255 / .06);
  --focus: var(--mint-300);
  --chart-1: var(--mint-400); --chart-2: #2b6b55; --chart-neg: #ff6b6b;
  --glow: 0 0 0 1px rgb(46 230 166 / .25), 0 0 24px rgb(46 230 166 / .25);
  --panel-grad: radial-gradient(120% 140% at 0% 0%, rgb(46 230 166 / .07), transparent 55%);

  /* tipografia: escala 12 · 14 · 16 · 18 · 20 · 24 · 32 · 40 */
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fs-xs: .75rem; --fs-sm: .875rem; --fs-base: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.25rem; --fs-2xl: 1.5rem; --fs-3xl: 2rem; --fs-4xl: 2.5rem;
  /* espaçamento: 4 · 8 · 12 · 16 · 24 · 32 · 48 */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px; --radius-pill: 999px;
  --shadow-sm: none; --shadow: 0 1px 0 rgb(255 255 255 / .02) inset, 0 8px 24px rgb(0 0 0 / .35);
  --shadow-lg: 0 20px 60px rgb(0 0 0 / .6);
  --ease: cubic-bezier(.2, .7, .2, 1); --dur: 180ms;
  --header-h: 64px; --touch: 44px;

  /* aliases legados (telas antigas) */
  --surface2: var(--surface-2); --muted: var(--text-2); --line: var(--border); --brand: var(--primary); --brand-2: var(--primary-text);
  --brand-ink: var(--on-primary); --ok: var(--positive); --warn: var(--warning); --bad: var(--negative);
  --ok-bg: var(--positive-bg); --warn-bg: var(--warning-bg); --bad-bg: var(--negative-bg); --muted-bg: var(--neutral-bg);
  color-scheme: dark;
}

/* base */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs-base)/1.5 var(--font); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
a { color: var(--primary-text); text-underline-offset: 2px; }
h1 { font-size: var(--fs-2xl); line-height: 1.25; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: var(--fs-lg); line-height: 1.3; font-weight: 600; margin: 0 0 var(--s-3); }
h3 { font-size: var(--fs-base); font-weight: 600; margin: var(--s-4) 0 var(--s-2); }
h4 { font-size: var(--fs-sm); font-weight: 600; margin: var(--s-3) 0 var(--s-1); }
p { margin: var(--s-2) 0; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); } .small { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); } .hidden { display: none !important; }
.warn-text { color: var(--warning); } .ok-text { color: var(--positive); } .danger-text { color: var(--negative); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; } .num.neg { color: var(--negative); } .num.pos { color: var(--positive); }
.masked { color: var(--text-3); letter-spacing: .08em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: .875em; } code.big { font-size: var(--fs-lg); display: inline-block; padding: 6px 10px; word-break: break-all; }
.ico { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.ico.sm { width: 16px; height: 16px; vertical-align: -3px; } .ico.lg { width: 24px; height: 24px; }

/* topo */
.demo-banner { background: #7c2d12; color: #fff; text-align: center; font-weight: 600; padding: 6px 12px; font-size: var(--fs-sm); }
.demo-banner.restored { background: var(--primary); }
.demo-banner .short { display: none; }
header.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-3); min-height: var(--header-h); padding: var(--s-2) var(--s-5);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-lg); font-weight: 600; text-decoration: none; color: var(--text); margin-right: auto; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--on-primary); display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: -.02em; }
.ctx { display: flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.ctx button, .ctx select { border: 0; background: transparent; color: var(--text-2); padding: 0 var(--s-3); min-height: 36px; font: 500 var(--fs-sm) var(--font); cursor: pointer; border-radius: 7px; transition: background var(--dur) var(--ease), color var(--dur); }
.ctx button:hover, .ctx select:hover { color: var(--text); }
.ctx button.on, .ctx select.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.ctx select { max-width: 190px; } .ctx .ghost-ctx { color: var(--text-3); }
.month-nav { display: flex; align-items: center; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; background: var(--surface); }
.month-nav span { min-width: 84px; text-align: center; font-weight: 600; font-size: var(--fs-sm); }
.icon-btn { display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--text-2); border-radius: 8px; min-width: 36px; min-height: 36px; cursor: pointer; transition: background var(--dur), color var(--dur); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.toggle-btn { display: inline-flex; align-items: center; gap: var(--s-2); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: var(--radius); min-height: 40px; padding: 0 var(--s-3); font: 500 var(--fs-sm) var(--font); cursor: pointer; }
.toggle-btn:hover { color: var(--text); border-color: var(--border-strong); } .toggle-btn[aria-pressed="true"] { color: var(--primary-text); background: var(--primary-soft); }
.menu-btn { display: none; }

/* layout e navegação lateral */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
nav.side { background: var(--surface); border-right: 1px solid var(--border); padding: var(--s-4) var(--s-3); display: flex; flex-direction: column; gap: 2px; position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow: auto; }
nav.side a { display: flex; gap: var(--s-3); align-items: center; min-height: 40px; padding: 0 var(--s-3); border-radius: 8px; text-decoration: none; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; transition: background var(--dur), color var(--dur); }
nav.side a:hover { background: var(--surface-2); color: var(--text); }
nav.side a.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
nav.side .nav-sep { height: 1px; background: var(--border); margin: var(--s-2) var(--s-2); }
.side-foot { margin-top: auto; padding: var(--s-3); font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }
nav.bottom { display: none; }
main { padding: var(--s-5) var(--s-6) var(--s-7); max-width: 1320px; width: 100%; min-width: 0; outline: none; }
.panel, .kpi, .state, .card { overflow-wrap: anywhere; }

/* cabeçalho de página */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head .sub { color: var(--text-2); font-size: var(--fs-sm); margin-top: var(--s-1); }

/* superfícies */
.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-5); margin-bottom: var(--s-4); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.card-head h2 { margin: 0; font-size: var(--fs-base); }
.card-head .ico { color: var(--text-3); }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.grid6 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); margin-bottom: var(--s-4); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }
.card-link { text-decoration: none; color: inherit; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-4) var(--s-5); box-shadow: var(--shadow); min-width: 0; }
.kpi h3 { margin: 0 0 var(--s-1); font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.kpi-v { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
details.composition { margin-top: var(--s-3); border-top: 1px solid var(--border); padding-top: var(--s-2); }
details.composition summary { cursor: pointer; color: var(--primary-text); font-weight: 600; font-size: var(--fs-sm); list-style: none; display: inline-flex; align-items: center; gap: var(--s-1); min-height: 32px; }
details.composition summary::-webkit-details-marker { display: none; }
details.composition summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform var(--dur); }
details.composition[open] summary::after { transform: rotate(225deg) translate(-2px, -2px); }
details.composition > div { margin-top: var(--s-2); }
dl.kv { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); gap: var(--s-2) var(--s-4); margin: var(--s-2) 0; font-size: var(--fs-sm); }
dl.kv dt { color: var(--text-2); } dl.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
dl.kv dt.sub { padding-left: var(--s-4); }
dl.kv.cols { grid-template-columns: repeat(2, minmax(0,1fr) minmax(0, max-content)); }
.notice { display: flex; gap: var(--s-3); align-items: flex-start; background: var(--info-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); font-size: var(--fs-sm); }
.notice .ico { color: var(--info); margin-top: 2px; } .notice p { margin: 0 0 var(--s-1); }
.notice.warn { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 30%, transparent); } .notice.warn .ico { color: var(--warning); }
.alerts { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.alert { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--radius); border: 1px solid var(--border); border-left: 3px solid var(--info); background: var(--surface); font-size: var(--fs-sm); }
.alert.high { border-left-color: var(--negative); } .alert.medium { border-left-color: var(--warning); } .alert a { color: var(--text); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1.5; vertical-align: 1px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--positive-bg); color: var(--positive); } .badge.warn { background: var(--warning-bg); color: var(--warning); } .badge.bad { background: var(--negative-bg); color: var(--negative); }
.badge.info { background: var(--info-bg); color: var(--info); } .badge.muted { background: var(--neutral-bg); color: var(--text-2); }

/* estados: carregando, vazio, erro */
.state { padding: var(--s-7) var(--s-5); text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.state .state-ico { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.state.error { border-style: solid; border-color: color-mix(in srgb, var(--negative) 35%, transparent); } .state.error .state-ico { background: var(--negative-bg); color: var(--negative); }
.state strong { font-size: var(--fs-lg); } .state p { color: var(--text-2); max-width: 52ch; margin: 0; }
.state .row { justify-content: center; margin-top: var(--s-2); }
.steps { list-style: none; padding: 0; margin: var(--s-3) 0 0; display: grid; gap: var(--s-2); text-align: left; counter-reset: st; }
.steps li { counter-increment: st; display: flex; gap: var(--s-3); align-items: center; color: var(--text-2); }
.steps li::before { content: counter(st); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: var(--fs-xs); font-weight: 700; display: grid; place-items: center; flex: 0 0 auto; }
.skeleton { display: grid; gap: var(--s-4); } .sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-lg); }
.sk-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: var(--s-2) 0; border-bottom: 1px solid var(--border); } ul.plain li:last-child { border: 0; }
.row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row-end { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-3); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 10px var(--s-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--surface); }
tbody tr { transition: background var(--dur); } tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.cell { width: 100%; min-width: 90px; } .num-in { text-align: right; max-width: 120px; }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 0 var(--s-4); min-height: 40px; font: 500 var(--fs-sm) var(--font); cursor: pointer; text-decoration: none; transition: background var(--dur) var(--ease), border-color var(--dur), color var(--dur), transform 80ms; white-space: nowrap; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary-text); } .btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { border-color: color-mix(in srgb, var(--negative) 50%, transparent); color: var(--negative); }
.btn.danger.primary, .modal .btn.danger[type=submit] { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn.wide { width: 100%; } .btn:disabled { opacity: .55; cursor: progress; }
.link { background: none; border: 0; color: var(--primary-text); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.link-more { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; color: var(--primary-text); min-height: 32px; }
.link-more:hover { text-decoration: underline; }

/* formulários */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-3); } .field > span { font-weight: 600; font-size: var(--fs-sm); } .field small { color: var(--text-2); font-size: var(--fs-xs); }
input, select, textarea { font: 400 var(--fs-base) var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 12px; min-height: 40px; max-width: 100%; transition: border-color var(--dur), box-shadow var(--dur); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
textarea { width: 100%; } input[type=checkbox], input[type=radio] { min-height: auto; width: 18px; height: 18px; accent-color: var(--primary); }
label.check { display: flex; gap: var(--s-2); align-items: center; margin: 6px 0; min-height: 32px; } label.check.sub { padding-left: 26px; font-size: var(--fs-sm); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin: 0 0 var(--s-3); } legend { font-weight: 600; font-size: var(--fs-sm); padding: 0 4px; }
fieldset.radio label { display: block; margin: 6px 0; }
.form-error { color: var(--negative); min-height: 1em; margin: 4px 0; font-size: var(--fs-sm); }
.filters { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-3); } .filters input { flex: 1; min-width: 160px; }
.bulk, .sticky-bar { position: sticky; top: calc(var(--header-h) + 4px); z-index: 5; background: var(--warning-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-2); margin-bottom: var(--s-3); display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.group { border-bottom: 1px solid var(--border); padding: var(--s-2) 0; }
.tabs { display: flex; gap: var(--s-1); flex-wrap: wrap; margin-bottom: var(--s-4); border-bottom: 1px solid var(--border); }
.tabs a, .tabs button { padding: var(--s-2) var(--s-3); min-height: 40px; display: inline-flex; align-items: center; text-decoration: none; color: var(--text-2); border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font: 500 var(--fs-sm) var(--font); cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs a.on, .tabs button[aria-selected=true] { color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--s-2); }
.seg button, .seg a { border: 0; background: transparent; padding: 0 var(--s-3); min-height: 32px; display: inline-flex; align-items: center; font: 500 var(--fs-sm) var(--font); cursor: pointer; color: var(--text-2); text-decoration: none; border-radius: 7px; }
.seg button:hover, .seg a:hover { color: var(--text); }
.seg .on, .seg [aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-pill); padding: 4px 12px; cursor: pointer; color: var(--text); font: 500 var(--fs-sm) var(--font); } .chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.bar-mini { width: 80px; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; } .bar-mini span { display: block; height: 100%; background: var(--primary); } .bar-mini span.over { background: var(--negative); }
.split-row { display: grid; grid-template-columns: 120px 1fr 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.balance-card { display: grid; grid-template-columns: 280px 1fr; gap: var(--s-5); }
.cat-list li { margin: 3px 0; }

/* calendário e gráficos */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h { text-align: center; font-size: var(--fs-xs); color: var(--text-3); }
.cal-cell { min-height: 78px; background: var(--surface-2); border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell.empty { background: transparent; } .cal-cell.today { outline: 2px solid var(--primary); }
.cal-d { font-size: var(--fs-xs); font-weight: 600; } .cal-it { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 0 4px; background: var(--negative-bg); }
.cal-it.receivable { background: var(--positive-bg); } .cal-more { font-size: .7rem; color: var(--text-3); }
svg.chart { width: 100%; height: auto; display: block; } .chart .bar { fill: var(--chart-1); } .chart .bar.est { fill: var(--chart-2); } .chart .bar.neg { fill: var(--chart-neg); }
.chart .zero { stroke: var(--border-strong); } .chart .grid { stroke: var(--border); stroke-dasharray: 2 4; } .chart .axis { font: 500 11px var(--font); fill: var(--text-3); }
.chart .val { font: 600 11px var(--font); fill: var(--text-2); }
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); margin-top: var(--s-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* assistente */
.msgs { display: flex; flex-direction: column; gap: var(--s-2); margin: var(--s-3) 0; max-height: 55vh; overflow: auto; }
.msg { padding: 10px 14px; border-radius: var(--radius-lg); max-width: 85%; } .msg.user { align-self: flex-end; background: var(--primary); color: var(--on-primary); } .msg.assistant { background: var(--surface-2); }
.msg small { display: block; margin-top: 4px; } .ask { display: flex; gap: var(--s-2); } .ask textarea { flex: 1; }

/* modal, toast, autenticação */
.modal-wrap { position: fixed; inset: 0; background: rgb(2 6 23 / .5); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh var(--s-3); overflow: auto; animation: fade var(--dur) var(--ease); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 540px; box-shadow: var(--shadow-lg); } .modal.wide { max-width: 880px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); } .modal header h2 { margin: 0; font-size: var(--fs-lg); }
.modal-body { padding: var(--s-4) var(--s-5); max-height: 72vh; overflow: auto; } .modal footer { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }
.modal .form-error { padding: 0 var(--s-5); }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: var(--s-5); right: var(--s-5); z-index: 60; display: flex; flex-direction: column; gap: var(--s-2); width: min(92vw, 420px); }
.toast { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--radius); background: var(--slate-900); color: #f8fafc; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: fade var(--dur) var(--ease); }
.toast .ico { color: #86efac; } .toast.error { background: #7f1d1d; } .toast.error .ico { color: #fecaca; }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--s-4); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-6); width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 640px; } .auth-card h1 b { color: var(--primary-text); }
.onb-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--s-4); font-size: var(--fs-xs); } .onb-steps span { padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-2); }
.onb-steps .on { background: var(--primary); color: var(--on-primary); } .onb-steps .done { color: var(--positive); }

/* =========================== tema escuro: superfícies e navegação =========================== */
body { background: radial-gradient(900px 500px at 85% -10%, rgb(46 230 166 / .08), transparent 60%), radial-gradient(700px 400px at -10% 110%, rgb(46 230 166 / .05), transparent 60%), var(--bg); background-attachment: fixed; }
.panel, .card, .kpi, .stat, .state { background-image: var(--panel-grad); }
header.top { background: rgb(7 11 9 / .82); }
.brand { font-size: var(--fs-xl); font-weight: 700; } .brand-text b { color: var(--primary); }
.brand-mark { background: var(--primary); color: var(--on-primary); box-shadow: var(--glow); }
.top-search { display: flex; align-items: center; gap: var(--s-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 var(--s-3); min-height: 38px; color: var(--text-3); min-width: 220px; }
.top-search input { border: 0; background: transparent; min-height: 36px; padding: 0; color: var(--text); font-size: var(--fs-sm); width: 100%; }
.top-search input:focus { box-shadow: none; }
.top-search:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgb(46 230 166 / .15); }
.user-chip { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text); }
.user-chip .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-xs); color: var(--primary-text); }
.user-chip small { display: block; color: var(--text-3); font-size: 11px; }
nav.side { background: rgb(13 20 17 / .7); }
nav.side .nav-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: var(--s-4) var(--s-3) var(--s-1); }
nav.side a { border-radius: var(--radius-pill); }
nav.side a.active { background: var(--primary); color: var(--on-primary); box-shadow: var(--glow); }
nav.side a.active .ico { stroke-width: 2.1; }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
nav.side a.active .nav-badge { background: var(--on-primary); color: var(--primary); }
.side-foot { display: flex; align-items: center; gap: var(--s-2); border-top: 1px solid var(--border); padding-top: var(--s-3); }
.side-foot .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.ctx button.on, .ctx select.on, .seg .on, .seg [aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.ctx select option { background: var(--surface); color: var(--text); }
.btn.primary { box-shadow: 0 0 18px rgb(46 230 166 / .25); }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); }
.badge.warn::before, .badge.bad::before { box-shadow: 0 0 6px currentColor; }

/* =========================== Início =========================== */
.home { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
.home > * { margin: 0; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; }
.col-stack { display: grid; gap: var(--s-4); align-content: stretch; }
.col-stack > .card { margin: 0; }
/* faixa de indicadores */
.kpi-strip { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); padding: var(--s-5) 0; }
.kpi-strip + .kpi-strip { margin-top: 0; }
.kpi-strip .kpi-item { padding: 0 var(--s-5); border-left: 1px solid var(--border); min-width: 0; }
.kpi-strip .kpi-item:first-child { border-left: 0; }
.kpi-item .k-label { color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.kpi-item .k-value { font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: var(--s-2) 0; }
.delta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.delta .arrow { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--neutral-bg); }
.delta.up { color: var(--positive); } .delta.up .arrow { background: var(--positive-bg); }
.delta.down { color: var(--negative); } .delta.down .arrow { background: var(--negative-bg); }
.delta .ctx-txt { color: var(--text-3); font-weight: 500; }
/* gráfico de área */
.chart-head { display: flex; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; align-items: flex-start; }
.chart-head .k-label { color: var(--text-2); font-size: var(--fs-sm); }
.chart-head .k-value { font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: var(--s-1) 0; }
svg.area { width: 100%; height: auto; display: block; margin-top: var(--s-3); overflow: visible; }
.area .gridline { stroke: rgb(255 255 255 / .06); } .area .ylab, .area .xlab { font: 500 11px var(--font); fill: var(--text-3); }
.area .l1 { fill: none; stroke: var(--mint-400); stroke-width: 2.5; filter: drop-shadow(0 0 6px rgb(46 230 166 / .5)); }
.area .l2 { fill: none; stroke: #ff6b6b; stroke-width: 2; opacity: .9; }
.area .zero { stroke: rgb(255 255 255 / .25); stroke-dasharray: 3 4; }
.area .pt { fill: #fff; stroke: var(--mint-400); stroke-width: 2; }
.legend i.l1 { background: var(--mint-400); } .legend i.l2 { background: #ff6b6b; }
/* anel */
.ring-wrap { display: grid; place-items: center; padding: var(--s-2) 0; }
.ring { width: 180px; height: 180px; }
.ring .track { stroke: rgb(46 230 166 / .12); } .ring .val { stroke: var(--mint-400); stroke-linecap: round; filter: drop-shadow(0 0 8px rgb(46 230 166 / .55)); transition: stroke-dashoffset .6s var(--ease); }
.ring text { fill: var(--text); font: 600 28px var(--font); }
.ring-legend { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--s-2); }
/* cartão de destaque (estilo promo) */
.promo .promo-title { color: var(--primary-text); font-size: var(--fs-2xl); font-weight: 700; line-height: 1.2; margin: var(--s-2) 0; }
.promo .promo-title .num { color: var(--primary-text); }
.promo p { color: var(--text-2); font-size: var(--fs-sm); }
.pills { display: flex; gap: var(--s-1); flex-wrap: wrap; margin-top: var(--s-3); }
.pills button { border: 1px solid var(--border); background: transparent; color: var(--text-2); border-radius: var(--radius-pill); min-height: 32px; padding: 0 var(--s-3); font: 500 var(--fs-xs) var(--font); cursor: pointer; }
.pills button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-text); border-color: var(--border-strong); }
.card-head .more { color: var(--text-3); }
/* lista de vencimentos com ícone circular */
.due-list { list-style: none; margin: 0; padding: 0; }
.due-list li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: var(--s-3); align-items: center; padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.due-list li:last-child { border-bottom: 0; }
.due-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); box-shadow: 0 0 14px rgb(46 230 166 / .3); }
.due-ico.over { background: var(--negative); color: #fff; box-shadow: 0 0 14px rgb(255 107 107 / .35); }
.due-ico.est { background: var(--surface-3); color: var(--primary-text); box-shadow: none; border: 1px solid var(--border-strong); }
.due-title { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.due-meta { font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.due-date { font-size: var(--fs-xs); color: var(--text-3); text-align: right; white-space: nowrap; }
.due-amt { font-weight: 600; font-size: var(--fs-sm); text-align: right; color: var(--primary-text); }
.due-amt .num.neg { color: var(--text); }
/* atenção e mês */
.attn-list { list-style: none; margin: 0; padding: 0; }
.attn-list li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); min-height: var(--touch); }
.attn-list li:last-child { border-bottom: 0; }
.attn-list .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--info); } .attn-list .dot.high { background: var(--negative); box-shadow: 0 0 8px var(--negative); } .attn-list .dot.medium { background: var(--warning); }
.attn-list a { color: var(--text); text-decoration: none; flex: 1; } .attn-list a:hover { color: var(--primary-text); }
.attn-list .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.mini { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-3); background: var(--surface-2); min-width: 0; }
.mini span { display: block; font-size: var(--fs-xs); color: var(--text-3); } .mini b { font-size: var(--fs-lg); font-weight: 600; }
.mbar { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; font-size: var(--fs-sm); margin-bottom: var(--s-3); }
.mbar .track { height: 8px; background: rgb(255 255 255 / .06); border-radius: var(--radius-pill); overflow: hidden; }
.mbar .fill { height: 100%; border-radius: var(--radius-pill); background: var(--positive); box-shadow: 0 0 10px rgb(52 227 160 / .5); } .mbar .fill.out { background: #7cc7ff; box-shadow: none; } .mbar .fill.unk { background: var(--warning); box-shadow: none; }
.mbar .label { color: var(--text-2); } .mbar .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* =========================== responsivo =========================== */
@media (max-width: 1180px) {
  .span-7, .span-5, .span-8, .span-4 { grid-column: span 12; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--s-5); }
  .kpi-strip .kpi-item:nth-child(3) { border-left: 0; }
  .top-search { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid6 { grid-template-columns: repeat(2, minmax(0,1fr)); } .balance-card { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --header-h: 56px; }
  header.top { gap: var(--s-2); padding: var(--s-2) var(--s-3); }
  .menu-btn { display: inline-grid; }
  .brand { font-size: var(--fs-base); } .brand-text { display: none; }
  .ctx { order: 3; width: 100%; overflow: hidden; } .ctx button, .ctx select { flex: 1 1 0; min-width: 0; padding: 0 var(--s-1); text-overflow: ellipsis; white-space: nowrap; overflow: hidden; } .ctx select { flex-grow: 1.3; }
  .demo-banner .long { display: none; } .demo-banner .short { display: inline; }
  .month-nav span { min-width: 70px; }
  .toggle-btn .lbl { display: none; } .toggle-btn { padding: 0 var(--s-2); }
  .layout { grid-template-columns: minmax(0, 1fr); }
  html, body { overflow-x: hidden; }
  .page-head { margin-bottom: var(--s-4); } .page-head > .row { width: 100%; }
  h1 { font-size: var(--fs-xl); }
  nav.side { position: fixed; left: 0; top: 0; bottom: 0; width: 82vw; max-width: 300px; z-index: 40; transform: translateX(-105%); transition: transform .22s var(--ease); height: 100vh; box-shadow: var(--shadow-lg); }
  body.menu-open nav.side { transform: none; }
  body.menu-open::after { content: ""; position: fixed; inset: 0; background: rgb(2 6 23 / .4); z-index: 35; }
  nav.bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; font-size: 11px; font-weight: 500; text-decoration: none; color: var(--text-3); }
  nav.bottom a.active { color: var(--primary-text); font-weight: 600; }
  main { padding: var(--s-4) var(--s-3) 96px; }
  .panel, .card { padding: var(--s-4); border-radius: var(--radius); }
  .home { gap: var(--s-3); }
  .hero-value { font-size: var(--fs-3xl); }
  .kpi-strip { padding: var(--s-4) 0; } .kpi-strip .kpi-item { padding: 0 var(--s-3); } .kpi-item .k-value, .chart-head .k-value { font-size: var(--fs-xl); }
  .user-chip .who { display: none; }
  .due-list li { grid-template-columns: 36px minmax(0, 1fr) auto; } .due-date { display: none; } .due-ico { width: 36px; height: 36px; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .stats { gap: var(--s-3); }
  .stat { padding: var(--s-3); } .stat-value { font-size: var(--fs-xl); } .stat-label .ico-wrap { display: none; }
  .mbar { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .sk-row { grid-template-columns: repeat(2, 1fr); }
  #toasts { left: 50%; right: auto; transform: translateX(-50%); bottom: 72px; }
  .grid6 { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  dl.kv.cols { grid-template-columns: fit-content(50%) minmax(0, 1fr); }
  .filters > * { flex: 1 1 140px; min-width: 0; }
  select { max-width: 100%; }
  .split-row { grid-template-columns: 1fr 1fr; }
  .cal-cell { min-height: 54px; } .cal-it { display: none; } .cal-cell:has(.cal-it)::after { content: "•"; color: var(--negative); }
  .bulk, .sticky-bar { top: 104px; }
  .kpi-v { font-size: var(--fs-xl); }
  .modal-wrap { padding: 0; } .modal { border-radius: 0; min-height: 100vh; border: 0; } .modal-body { max-height: none; }
}
@media (max-width: 340px) { .stats { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print { nav, header.top, .btn, .toggle-btn { display: none !important; } .layout { display: block; } }

/* vermelho só para o que é ruim (saldo/livre negativo, vencido); saída prevista é neutra */
.due-amt .num.neg, .stat-sub .num.neg, .mini .num.neg { color: var(--text); }
@media (max-width: 1500px) { .user-chip .who { display: none; } }
@media (max-width: 1280px) { .toggle-btn .lbl { display: none; } .toggle-btn { padding: 0 var(--s-2); } }
.link-more { white-space: nowrap; } .card-head h2 { min-width: 0; }

/* estrutura comum de páginas */
.back-link { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-sm); color: var(--text-3); text-decoration: none; margin-bottom: var(--s-1); min-height: 28px; }
.back-link:hover { color: var(--primary-text); }
.page-head h1 { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
main > .kpi-strip, main > .tabs { margin-bottom: var(--s-4); }
.panel > h2:first-child, .panel > .row.between:first-child h2 { color: var(--text); }
.panel h2 { font-size: var(--fs-base); }
.upload-zone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: var(--s-5); background: rgb(46 230 166 / .03); display: grid; gap: var(--s-3); }
.upload-zone .uz-ico { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.split-2 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
.split-2 > .main-col { grid-column: span 8; min-width: 0; } .split-2 > .side-col { grid-column: span 4; min-width: 0; }
.split-2 > * > .panel:last-child { margin-bottom: 0; }
.goal-card { display: block; height: 100%; } .goal-card .kpi { height: 100%; transition: border-color var(--dur), box-shadow var(--dur); }
.goal-card:hover .kpi { border-color: var(--border-strong); box-shadow: var(--glow); }
.progress { height: 8px; background: rgb(255 255 255 / .06); border-radius: var(--radius-pill); overflow: hidden; margin: var(--s-2) 0; }
.progress > span { display: block; height: 100%; background: var(--primary); box-shadow: 0 0 10px rgb(46 230 166 / .5); border-radius: var(--radius-pill); }
@media (max-width: 1180px) {
  .kpi-strip { grid-template-columns: repeat(min(var(--n, 4), 2), minmax(0, 1fr)); }
  .kpi-strip .kpi-item:nth-child(odd) { border-left: 0; }
  .split-2 > .main-col, .split-2 > .side-col { grid-column: span 12; }
}
.r { text-align: right; }
.auth-brand { margin-bottom: var(--s-2); } .auth-card { background-image: var(--panel-grad); box-shadow: var(--shadow-lg); }
.auth-card .tabs { margin-top: var(--s-4); }
.upload-zone .row { flex-wrap: nowrap; align-items: flex-start; } .upload-zone .row > div { min-width: 0; flex: 1; } .upload-zone .uz-ico { flex: 0 0 auto; } .upload-zone input[type=file] { max-width: 100%; }
.upload-zone { grid-template-columns: minmax(0, 1fr); } .upload-zone select, .upload-zone .field { width: 100%; min-width: 0; }
input[type=file] { padding: 6px; } input[type=file]::file-selector-button { font: 600 var(--fs-sm) var(--font); background: var(--primary-soft); color: var(--primary-text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 12px; margin-right: var(--s-3); cursor: pointer; }
.warn-panel { border: 1px solid var(--warning); background: var(--warn-bg); }
.warn-panel ul.plain { margin: var(--s-2, 8px) 0 0; }

.table-sort { display: flex; justify-content: flex-end; margin: 0 0 var(--s-2, 8px); font-size: var(--fs-xs); color: var(--text-3); }
.table-sort select { margin-left: 6px; padding: 4px 8px; font-size: var(--fs-xs); }
table[data-sortable] th[data-col] { cursor: pointer; user-select: none; }
table[data-sortable] th[aria-sort="descending"]::after { content: " ↓"; }
table[data-sortable] th[aria-sort="ascending"]::after { content: " ↑"; }
.section-title { font-size: var(--fs-lg, 1.1rem); margin: var(--s-5, 24px) 0 var(--s-1, 4px); }

.month-summary .ms-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-4, 16px); }
.prev-line { margin-top: 6px; color: var(--text-3); font-size: var(--fs-sm, .9rem); font-variant-numeric: tabular-nums; }
.prev-line span { font-size: var(--fs-xs, .8rem); }
.forecast-box > summary { cursor: pointer; list-style: none; }
.forecast-box > summary::before { content: "▸ "; } .forecast-box[open] > summary::before { content: "▾ "; }

.ctx-co select { appearance: none; -webkit-appearance: none; background: transparent; border: 0; color: inherit; font: inherit; padding: 6px 22px 6px 12px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
.ctx-co.on { background: var(--primary); color: var(--on-primary); border-radius: 999px; }
/* aviso de atualização na paleta da marca (não amarelo) */
.warn-panel { border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); border-left: 4px solid var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.warn-panel .ico { color: var(--primary); }

/* =========================================================================
   Refinamento visual (30/10) — mesma estrutura, mais legibilidade e consistência
   ========================================================================= */
/* números: algarismos de largura fixa para colunas alinhadas e leitura rápida */
.r, td.r, .k-value, .kpi-v, .num, .due-amt, .mbar .v, .prev-line, dd { font-variant-numeric: tabular-nums; }

/* resumo do mês no Início: colunas separadas, rótulo discreto, valor em destaque */
.month-summary .ms-grid > div { padding: var(--s-1) 0 var(--s-1) var(--s-4); border-left: 1px solid var(--border); }
.month-summary .ms-grid > div:first-child { border-left: 0; padding-left: 0; }
.month-summary .k-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.month-summary .k-value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.02em; margin: var(--s-1) 0 2px; line-height: 1.2; }
.prev-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; color: var(--text-2); }
.prev-line::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1.5px dashed var(--text-3); flex: none; transform: translateY(-1px); }
.prev-line span { color: var(--text-3); }

/* blocos recolhíveis com o mesmo chevron da plataforma */
.forecast-box > summary { display: flex; align-items: baseline; gap: var(--s-2); padding: var(--s-1) 0; }
.forecast-box > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary);
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease); flex: none; align-self: center; margin-right: 2px; }
.forecast-box[open] > summary::before { transform: rotate(45deg); }
.forecast-box > summary::-webkit-details-marker { display: none; }

/* títulos de seção (Metas: Projetos / Reservas / Planos) com mais respiro e hierarquia */
.section-title { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.01em; margin: var(--s-6) 0 var(--s-1); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.section-title + p { margin: 0 0 var(--s-4); }

/* links dentro de tabelas: sem sublinhado até o hover, para menos ruído visual */
td a:not(.btn) { text-decoration: none; font-weight: 500; }
td a:not(.btn):hover { text-decoration: underline; }

/* barras de progresso mais finas em listas, menos brilho */
td .progress { height: 4px; margin: 6px 0 0; }
td .progress > span { box-shadow: none; opacity: .85; }

/* anotações longas: largura de leitura confortável */
.panel p[style*="pre-line"] { max-width: 78ch; color: var(--text-2); line-height: 1.6; }

/* simulador: régua na cor da marca e alça grande o suficiente para o dedo */
.sim-range { accent-color: var(--primary); height: var(--touch); cursor: pointer; }
.sim .sim-total { font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; }
.sim .check { min-height: 36px; align-items: center; }

/* ordenação de tabelas: cabeçalho clicável com feedback */
table[data-sortable] th[data-col]:hover { color: var(--text); }
.table-sort select { min-height: 32px; border-radius: var(--radius-sm); }

/* seletor de contexto: foco visível também no select estilizado */
.ctx-co { display: inline-flex; align-items: center; border-radius: 7px; }
.ctx-co:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.ctx-co.on select { color: var(--on-primary); font-weight: 600; }

/* aviso de atualização: compacto */
.warn-panel { padding: var(--s-3) var(--s-4); }
.warn-panel details { margin-top: var(--s-1); }

/* toque confortável no celular */
@media (max-width: 760px) {
  .btn, .ctx button, .ctx select, .icon-btn, input, select { min-height: var(--touch); }
  .month-summary .ms-grid > div { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: var(--s-3); }
  .month-summary .ms-grid > div:first-child { border-top: 0; padding-top: 0; }
  .section-title { margin-top: var(--s-5); }
}

/* quem prefere menos movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}

/* =========================================================================
   Celular (30/10 · revisão UI/UX mobile): gaveta opaca, abas roláveis,
   tabelas como cartões legíveis, formulários empilhados, áreas seguras
   ========================================================================= */
.cv { min-width: 0; }
@media (max-width: 760px) {
  header.top { padding-top: max(var(--s-2), env(safe-area-inset-top)); background: rgb(7 11 9 / .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }

  /* gaveta: fundo sólido, cobre a altura toda, fundo escurecido e sem rolar a página por trás */
  nav.side { background: var(--surface); border-right: 1px solid var(--border-strong); width: min(84vw, 320px); max-width: none; height: 100dvh;
    padding: max(var(--s-4), env(safe-area-inset-top)) var(--s-3) max(var(--s-4), env(safe-area-inset-bottom)); gap: 2px; overscroll-behavior: contain;
    box-shadow: 24px 0 48px rgb(0 0 0 / .55); visibility: hidden; transition: transform .24s var(--ease), visibility 0s linear .24s; }
  body.menu-open nav.side { visibility: visible; transition: transform .24s var(--ease), visibility 0s; }
  body.menu-open { overflow: hidden; }
  body.menu-open::after { background: rgb(0 0 0 / .62); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
  nav.side a { min-height: 48px; font-size: var(--fs-base); padding: 0 var(--s-4); }
  nav.side .nav-group { padding: var(--s-4) var(--s-4) var(--s-1); }
  nav.side .drawer-head + .nav-group { padding-top: var(--s-2); }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s-2) var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); margin-bottom: var(--s-1); }
  .drawer-head .brand-text { display: inline; }
  .side-foot { margin-top: auto; }

  /* barra inferior acima da área do gesto do iPhone */
  nav.bottom { background: rgb(13 20 17 / .96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  nav.bottom a { font-size: 11.5px; }
  main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

  /* abas: uma linha só, rolando para o lado, a aba ativa sempre visível */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; gap: 0; margin-left: calc(-1 * var(--s-3)); margin-right: calc(-1 * var(--s-3)); padding: 0 var(--s-3);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%); }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a, .tabs button { flex: none; white-space: nowrap; min-height: var(--touch); padding: 0 var(--s-3); }
  .panel .tabs, form .tabs { margin-left: 0; margin-right: 0; padding: 0; }

  /* tabelas viram cartões: título à esquerda, valor em destaque, demais dados em linhas rótulo → valor */
  .table-wrap table, .table-wrap thead, .table-wrap tbody { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--s-3); row-gap: 2px; align-items: start;
    border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--s-2); padding: var(--s-3) var(--s-4); background: var(--surface); }
  .table-wrap tbody tr:hover { background: var(--surface); }
  .table-wrap td { grid-column: 1 / -1; border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); text-align: right; min-width: 0; font-size: var(--fs-sm); }
  .table-wrap td::before { content: attr(data-label); color: var(--text-3); font-size: var(--fs-xs); text-align: left; flex: 0 1 auto; max-width: 45%; }
  .table-wrap td .cv { flex: 1 1 auto; text-align: right; overflow-wrap: anywhere; }
  .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap td[data-label=""] .cv { text-align: left; }
  .table-wrap td[data-label=""]:empty, .table-wrap td[data-label=""]:has(.cv:empty) { display: none; }
  /* título do cartão */
  .table-wrap td.m-title { grid-column: 1 / span 2; grid-row: 1; padding: 0 0 var(--s-1); font-size: var(--fs-base); line-height: 1.35; }
  .table-wrap td.m-title::before { content: none; }
  .table-wrap td.m-title .cv { text-align: left; }
  .table-wrap td.m-title .cv > a, .table-wrap td.m-title .cv > b { font-weight: 600; }
  .table-wrap td.m-title small { font-size: var(--fs-xs); }
  .table-wrap tr:has(.m-sel) td.m-title { grid-column: 2 / span 1; }
  .table-wrap tr:not(:has(.m-amt)) td.m-title { grid-column-end: -1; }
  /* valor em destaque ao lado do título */
  .table-wrap td.m-amt { grid-column: 3; grid-row: 1; padding: 0; font-size: var(--fs-base); font-weight: 600; white-space: nowrap; }
  .table-wrap td.m-amt::before { content: none; }
  /* metadados discretos sob o título */
  .table-wrap td.m-meta { grid-column: 2 / -1; justify-content: flex-start; padding: 0; color: var(--text-3); font-size: var(--fs-xs); }
  .table-wrap tr:not(:has(.m-sel)) td.m-meta { grid-column: 1 / -1; }
  .table-wrap td.m-meta::before { content: none; }
  .table-wrap td.m-meta .cv { text-align: left; }
  /* caixa de seleção com área de toque de 44px */
  .table-wrap td.m-sel { grid-column: 1; grid-row: 1 / span 3; padding: 0; align-self: center; }
  .table-wrap td.m-sel input { width: 22px; height: 22px; margin: 11px; }
  /* cartões mais firmes quando a linha é clicável */
  .table-wrap td.m-title a { color: var(--text); }

  /* rótulo → valor sem esmagar (Configurações, resumos) */
  dl.kv { grid-template-columns: fit-content(50%) minmax(0, 1fr); column-gap: var(--s-3); }

  /* formulários em linha empilham: campo ocupa a largura, botões lado a lado */
  form.row.wrap { align-items: stretch; }
  form.row.wrap > input, form.row.wrap > .field, form.row.wrap > label.check, form.row.wrap > select { flex: 1 1 100%; min-width: 0; }
  form.row.wrap > .btn { flex: 1 1 auto; }

  /* textos de cabeçalho e números grandes */
  .page-head p, .page-head .muted { font-size: var(--fs-sm); }
  .stat-value, .kpi-v { overflow-wrap: anywhere; }
}
@media (min-width: 761px) { .drawer-head { display: none; } }

/* Notificações, calendário e segurança */
.notif-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-4); }
.sub-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: var(--s-4); margin-bottom: var(--s-4); display: grid; gap: var(--s-3); align-content: start; }
.notif-grid .sub-card { margin-bottom: 0; }
.sub-head { display: flex; gap: var(--s-3); align-items: flex-start; }
.sub-head > .ico { flex: none; width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); }
.sub-head h3 { margin: 0 0 2px; font-size: var(--fs-base); display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.sub-head p { margin: 0; }
.switch-row { display: flex; gap: var(--s-3); align-items: center; min-height: var(--touch); padding: var(--s-1) 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row:last-of-type { border-bottom: 0; }
.switch-row span { display: grid; } .switch-row small { color: var(--text-3); font-size: var(--fs-xs); }
.switch-row input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur); margin: 0; min-height: 0; padding: 0; }
.switch-row input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur) var(--ease), background var(--dur); }
.switch-row input[type=checkbox]:checked { background: var(--primary); border-color: var(--primary); }
.switch-row input[type=checkbox]:checked::after { transform: translateX(18px); background: var(--on-primary); }
.switch-row input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.callout { display: flex; gap: var(--s-3); padding: var(--s-3); border-radius: var(--radius-sm); background: var(--info-bg); color: var(--text); font-size: var(--fs-sm); line-height: 1.5; }
.callout .ico { flex: none; color: var(--info); margin-top: 2px; }
.ok-line { display: flex; gap: var(--s-2); align-items: center; color: var(--positive); font-weight: 600; margin: 0; }
.copy-row { display: flex; gap: var(--s-2); } .copy-row input { flex: 1; min-width: 0; font-size: var(--fs-xs); }
ol.steps { padding-left: 1.2em; display: grid; gap: var(--s-2); margin: var(--s-2) 0; } ol.steps li { line-height: 1.6; }
.qr { display: grid; place-items: center; } .qr svg { width: 200px; height: 200px; border-radius: var(--radius-sm); }
pre.codes { background: var(--surface-3); padding: var(--s-3); border-radius: var(--radius-sm); font-size: var(--fs-base); line-height: 1.8; columns: 2; text-align: center; user-select: all; }
.btn.wide { width: 100%; justify-content: center; }
@media (max-width: 760px) { .notif-grid { grid-template-columns: 1fr; } .sub-card { padding: var(--s-3); } }

/* seleção em lote: ferramentas no cabeçalho e barra de ação */
.sel-tools { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.bulk { background: var(--surface-3); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.bulk b { color: var(--primary-text); margin-right: var(--s-1); }
@media (max-width: 760px) {
  /* barra de ação presa embaixo, perto do polegar, acima da navegação */
  .bulk { position: fixed; top: auto; left: var(--s-2); right: var(--s-2); bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 28; margin: 0;
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); padding: var(--s-3); border-radius: var(--radius-lg); }
  .bulk.hidden { display: none; }
  .bulk > b { grid-column: 1 / -1; }
  .bulk select { width: 100%; min-width: 0; }
  .bulk .btn { width: 100%; justify-content: center; }
  .card-head .sel-tools .btn { min-height: 36px; }
}
@media (max-width: 760px) { body:has(.bulk:not(.hidden)) #toasts { bottom: calc(250px + env(safe-area-inset-bottom)); } .card-head:has(.sel-tools) { flex-wrap: wrap; gap: var(--s-2); } }
.note-in { margin-top: var(--s-1); width: 100%; font-size: var(--fs-sm); }
td .cv > select.cell, td .cv > input.note-in { width: 100%; }
@media (max-width: 760px) {
  /* campos editáveis dentro do cartão: rótulo em cima, campo na largura toda */
  .table-wrap td:not(.m-title):not(.m-amt):not(.m-sel):has(select, input:not([type=checkbox])) { flex-direction: column; align-items: stretch; gap: 4px; padding-top: var(--s-2); }
  .table-wrap td:not(.m-title):not(.m-amt):not(.m-sel):has(select, input:not([type=checkbox]))::before { max-width: none; }
  .table-wrap td.m-amt input.cell { width: 7.5em; text-align: right; }
}

/* valores ocultos: desfoque instantâneo (o número continua no lugar, só não dá para ler) */
.money { transition: filter .15s ease; }
.hide-values .money, .hide-values svg .ylab { filter: blur(0.42em); user-select: none; }
.eye-btn { width: 40px; padding: 0; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .money { transition: none; } }
