/* AMFin — design system
   Casca no estilo do painel GenSec (trilho lateral escuro, barra superior translúcida, cartões arredondados, Manrope),
   com a paleta AMSetup: grafite + vermelho institucional. Tokens documentados em docs/DESIGN.md. */

:root {
  color-scheme: light;
  --brand: #C8202B; --brand-2: #A81A24; --brand-soft: #FBEAEB; --on-brand: #fff;
  --page: #F4F5F7; --surface: #FFFFFF; --surface-2: #EFF1F4; --border: rgba(30, 34, 39, .10); --border-strong: rgba(30, 34, 39, .18);
  --ink: #16191D; --ink-2: #4A525C; --muted: #737B85; --grid: #E4E7EB; --axis: #C5CBD2;
  --link: #B01C26; --focus: #C8202B;
  --shadow: 0 1px 2px rgba(20, 24, 30, .05), 0 10px 28px rgba(20, 24, 30, .06);
  --side-bg: #1E2228; --side-ink: #ECEEF1; --side-muted: #9AA3AD; --side-hover: rgba(255, 255, 255, .07); --side-active: rgba(255, 255, 255, .12); --side-mark: #FF5A63;
  --top-bg: rgba(244, 245, 247, .86);
  --positive: #1B7F52; --negative: #C0292B; --warning: #9A6400; --info: #2D6CB0;
  --f-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rail-w: 68px; --side-w: 252px; --top-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #E5484D; --brand-2: #F0666A; --brand-soft: #3A1A1C;
    --page: #0E1013; --surface: #16191D; --surface-2: #1D2126; --border: rgba(230, 234, 240, .09); --border-strong: rgba(230, 234, 240, .16);
    --ink: #E9ECEF; --ink-2: #B3BAC2; --muted: #858D97; --grid: #23272D; --axis: #3A4049;
    --link: #FF7A80; --focus: #FF7A80; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --side-bg: #0A0C0E; --side-ink: #E2E5E9; --side-muted: #8A929B; --side-hover: rgba(255, 255, 255, .05); --side-active: rgba(229, 72, 77, .16);
    --top-bg: rgba(14, 16, 19, .86);
    --positive: #3DBB7E; --negative: #F06B6B; --warning: #E0A43A; --info: #6BA6E6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #E5484D; --brand-2: #F0666A; --brand-soft: #3A1A1C;
  --page: #0E1013; --surface: #16191D; --surface-2: #1D2126; --border: rgba(230, 234, 240, .09); --border-strong: rgba(230, 234, 240, .16);
  --ink: #E9ECEF; --ink-2: #B3BAC2; --muted: #858D97; --grid: #23272D; --axis: #3A4049;
  --link: #FF7A80; --focus: #FF7A80; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --side-bg: #0A0C0E; --side-ink: #E2E5E9; --side-muted: #8A929B; --side-hover: rgba(255, 255, 255, .05); --side-active: rgba(229, 72, 77, .16);
  --top-bg: rgba(14, 16, 19, .86);
  --positive: #3DBB7E; --negative: #F06B6B; --warning: #E0A43A; --info: #6BA6E6;
}

* , *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--f-ui); background: var(--page); color: var(--ink); -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
: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; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--positive); } .neg { color: var(--negative); } .muted { color: var(--muted); } .small { font-size: 12.5px; }

/* ---------------- marca ---------------- */
.byline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }
.byline img { height: 20px; width: auto; }

/* ---------------- casca: trilho lateral + barra superior ---------------- */
@media (min-width: 760px) { body.app { padding-left: var(--rail-w); } }
.app-side { position: fixed; z-index: 45; top: 0; left: 0; bottom: 0; width: var(--rail-w); background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 12px 10px 14px; gap: 14px; transition: width .18s ease, box-shadow .18s ease, transform .2s ease; overflow: hidden; }
.app-side.open { width: var(--side-w); box-shadow: 8px 0 40px rgba(0, 0, 0, .28); }
.side-head { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.app-logo { display: flex; align-items: center; gap: 10px; padding: 3px 4px; min-height: 44px; color: var(--side-ink); text-decoration: none !important; }
.app-logo .logo-ico { width: 38px; height: 38px; flex: none; }
.app-logo .logo-full { height: 40px; width: auto; display: none; }
.app-side.open .app-logo .logo-full { display: block; } .app-side.open .app-logo .logo-ico { display: none; }
.app-sub { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); padding: 0 8px; margin-top: -8px; white-space: nowrap; display: none; }
.app-side.open .app-sub { display: block; }
.rail-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--side-ink); cursor: pointer; display: none; align-items: center; justify-content: center; flex: none; margin-left: auto; }
.rail-btn:hover { background: var(--side-hover); }
.app-side.open .rail-btn { display: inline-flex; }
.app-nav { display: grid; gap: 4px; }
.app-nav a, .app-nav button { position: relative; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-radius: 10px; color: var(--side-ink);
  text-decoration: none; font-size: 14px; font-weight: 600; opacity: .82; white-space: nowrap; border: 0; background: none; width: 100%; cursor: pointer; text-align: left; }
.app-nav a:hover, .app-nav button:hover { background: var(--side-hover); opacity: 1; text-decoration: none; }
.app-nav a[aria-current="page"] { background: var(--side-active); opacity: 1; box-shadow: inset 3px 0 0 var(--side-mark); }
.app-nav .icon { width: 20px; height: 20px; stroke-width: 1.8; }
.app-nav .lbl { opacity: 0; transition: opacity .12s ease; }
.app-side.open .app-nav .lbl { opacity: 1; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 6px 6px; }
.side-foot { margin-top: auto; display: grid; gap: 6px; }
.side-foot .byline { padding: 6px 14px 0; display: none; color: var(--side-muted); }
.app-side.open .side-foot .byline { display: flex; flex-direction: column; align-items: flex-start; }
.side-backdrop { position: fixed; inset: 0; z-index: 44; background: rgba(0, 0, 0, .28); display: none; }
.side-backdrop.show { display: block; }
@media (max-width: 759px) {
  .app-side { transform: translateX(-100%); width: var(--side-w); }
  .app-side.open { transform: none; }
  .app-side .app-nav .lbl { opacity: 1; }
  .app-side .app-logo .logo-full, .app-side .app-sub { display: block; }
  .app-side .app-logo .logo-ico { display: none; }
  .app-side .side-foot .byline { display: flex; flex-direction: column; align-items: flex-start; }
}

.app-top { position: sticky; top: 0; z-index: 35; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--top-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.top-title { font-weight: 700; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top-title b { color: var(--ink); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-btn { height: 36px; border-radius: 10px; padding: 0 14px; cursor: pointer; font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap; border: 1px solid var(--border); background: var(--surface); color: var(--ink); text-decoration: none !important; }
.top-btn:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.top-btn .icon { width: 16px; height: 16px; stroke-width: 2; }
.top-btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.top-btn.primary:hover { background: var(--brand-2); }
.theme-btn, .menu-btn { padding: 0; width: 38px; justify-content: center; }
.theme-btn .ico-sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-btn .ico-moon { display: none; } :root:not([data-theme="light"]) .theme-btn .ico-sun { display: block; } }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; } :root[data-theme="dark"] .theme-btn .ico-sun { display: block; }
.menu-btn { display: none; }
@media (max-width: 759px) { .menu-btn { display: inline-flex; } #side-t { display: none; } .app-top { padding: 0 16px; gap: 8px; } }
@media (max-width: 560px) { .top-new .lbl { display: none; } .top-new { width: 38px; padding: 0; justify-content: center; } }

.wrap { padding: 0 24px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
main.main { padding: 4px 0 64px; display: grid; gap: 18px; }

/* ---------------- cabeçalho de página ---------------- */
.page-head { padding: 18px 0 0; display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.page-head h1 { font-size: 25px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.center { justify-content: center; }

/* ---------------- botões ---------------- */
.btn { height: 38px; border-radius: 10px; padding: 0 14px; cursor: pointer; font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); text-decoration: none !important; }
.btn:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.btn .icon { width: 16px; height: 16px; stroke-width: 2; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--negative); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-block { width: 100%; }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: gira .7s linear infinite; }
.inline { display: inline; margin: 0; }

/* ---------------- cartões ---------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 18px 20px 0; }
.panel-head h2 { font-size: 15px; font-weight: 750; letter-spacing: -.01em; }
.panel-head .desc { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.panel-head a { font-size: 13px; font-weight: 600; }
.panel-body { padding: 14px 20px 18px; }
@media (max-width: 640px) { .panel-head { padding: 14px 14px 0; } .panel-body { padding: 12px 14px 14px; } }
.grid { display: grid; gap: 18px; min-width: 0; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid-dash { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); } }

/* indicadores (tiles) */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 900px) { .kpis { grid-template-columns: 1.35fr 1fr 1fr 1fr; } }
.kpi { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--surface); min-width: 0; box-shadow: var(--shadow); }
.kpi.wide { grid-column: 1 / -1; background: linear-gradient(160deg, var(--brand-soft), var(--surface) 72%); border-color: color-mix(in srgb, var(--brand) 28%, var(--border)); }
@media (min-width: 900px) { .kpi.wide { grid-column: auto; } }
.kpi-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 800; margin-top: 2px; letter-spacing: -.02em; }
.kpi.wide .kpi-value { font-size: 30px; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.delta.up-bad, .delta.down-bad { color: var(--negative); } .delta.up-good, .delta.down-good { color: var(--positive); }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--grid); }
.list > .row:first-child, .date-group + .row { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title a { color: var(--ink); }
.row-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 3px 10px; align-items: center; margin-top: 1px; }
.row-meta .icon { width: 13px; height: 13px; vertical-align: -2px; }
.row-amount { text-align: right; font-weight: 700; }
.row-actions { display: flex; gap: 2px; }
.dot { width: 9px; height: 9px; flex: none; }
.kind-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.kind-ico .icon { width: 17px; height: 17px; }
.kind-ico.in { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }
.kind-ico.out { background: var(--surface-2); color: var(--ink-2); }
.kind-ico.tr { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.date-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 16px 0 4px; list-style: none; }
.list > .date-group:first-child { padding-top: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.warn { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.badge.bad { background: color-mix(in srgb, var(--negative) 14%, transparent); color: var(--negative); }
.badge.good { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }

/* barras por categoria (SVG, compatível com CSP estrita) */
.bars { display: grid; gap: 12px; }
.bar-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 5px; }
.bar-line > span:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.bar-track { display: block; width: 100%; height: 8px; overflow: visible; }
.bar-track .track { fill: var(--surface-2); }
.bar-track .fill { transform-box: fill-box; transform-origin: 0 50%; animation: cresceX .9s cubic-bezier(.16, 1, .3, 1) both; }

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 600 13px var(--f-ui); }
.chart .grid-line { stroke: var(--axis); }
.chart .b-in { fill: var(--positive); } .chart .b-out { fill: var(--brand); }
.chart rect.col { transform-box: fill-box; transform-origin: 50% 100%; animation: sobe .7s cubic-bezier(.16, 1, .3, 1) both; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-in { background: var(--positive); } .legend .l-out { background: var(--brand); }

/* ---------------- formulários ---------------- */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.hint { font-size: 12px; color: var(--muted); }
.input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 12px; color: var(--ink); font-size: 14px; }
textarea.input { height: auto; min-height: 80px; padding: 9px 12px; resize: vertical; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 0; border-color: var(--brand); }
.input[aria-invalid="true"] { border-color: var(--negative); }
.input-money { height: 48px; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.input-prefix > .input { padding-left: 42px; }
.field-error { color: var(--negative); font-size: 12.5px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); width: fit-content; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label, .segmented .btn { border: 0; border-radius: 0; background: var(--surface); padding: 0 14px; height: 36px; display: inline-flex; align-items: center; cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 700; }
.segmented label + input + label, .segmented .btn + .btn { border-left: 1px solid var(--border); }
.segmented input:checked + label, .segmented .btn.btn-primary { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--brand); }
.segmented input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -2px; }
/* Formulários ocupam toda a largura; no celular o cartão encosta nas bordas da tela. */
.panel-form { width: 100%; }
@media (max-width: 640px) {
  .panel-form { margin: 0 -16px; width: auto; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .panel-form > .panel-body, .panel-form > .panel-head { padding-left: 16px; padding-right: 16px; }
  .form-actions .btn { flex: 1 1 auto; }
}
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding-top: 4px; }
details.more > summary { cursor: pointer; font-weight: 700; color: var(--ink-2); list-style: none; }

.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
.filters .q { grid-column: 1 / -1; }
@media (min-width: 720px) { .filters { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; } .filters .q { grid-column: auto; } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--ink-2); font-weight: 700; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--brand); }

.totals { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.totals strong { color: var(--ink); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 16px 0 0; font-size: 13px; }

/* ---------------- alertas e estados ---------------- */
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 11px 14px; font-size: 13px; border: 1px solid; }
.alert .icon { margin-top: 1px; width: 17px; height: 17px; }
.alert-success { border-color: color-mix(in srgb, var(--positive) 40%, var(--border)); background: color-mix(in srgb, var(--positive) 9%, var(--surface)); color: var(--positive); }
.alert-error { border-color: color-mix(in srgb, var(--negative) 45%, var(--border)); background: color-mix(in srgb, var(--negative) 8%, var(--surface)); color: var(--negative); }
.alert-info { border-color: color-mix(in srgb, var(--info) 40%, var(--border)); background: color-mix(in srgb, var(--info) 8%, var(--surface)); color: var(--info); }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty .icon { width: 30px; height: 30px; margin-bottom: 8px; }
.empty h2 { color: var(--ink); font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.empty p { font-size: 13px; margin-bottom: 12px; color: var(--ink-2); }
.empty p:last-child { margin-bottom: 0; }
.fab { position: fixed; right: 16px; bottom: 20px; z-index: 30; width: 56px; height: 56px; border-radius: 18px; background: var(--brand); color: #fff; display: none; place-items: center;
  box-shadow: 0 10px 26px -6px color-mix(in srgb, var(--brand) 70%, transparent); }
.fab .icon { width: 24px; height: 24px; stroke-width: 2.2; }
@media (max-width: 759px) { .fab { display: grid; } }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 12.5px; flex: none; border: 1px solid var(--border); }
button.avatar { cursor: pointer; padding: 0; font: inherit; font-weight: 800; font-size: 12.5px; }
button.avatar:hover, button.avatar[aria-expanded="true"] { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }

/* menu da conta (avatar na barra superior) */
.user-menu { position: relative; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 260px; max-width: calc(100vw - 24px); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, .18);
  animation: popIn .16s cubic-bezier(.16, 1, .3, 1); }
.user-pop-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; min-width: 0; }
.user-pop-head > div { min-width: 0; }
.user-pop-head b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop-head span:not(.avatar) { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop form { margin: 0; }
.user-pop a, .user-pop button { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 10px; border: 0; border-radius: 9px;
  background: none; color: var(--ink); font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none !important; text-align: left; }
.user-pop a:hover, .user-pop button:hover, .user-pop a:focus-visible, .user-pop button:focus-visible { background: var(--surface-2); outline: none; }
.user-pop a[aria-current="page"] { color: var(--brand); }
.user-pop .danger { color: var(--negative); }
.user-pop .icon { width: 17px; height: 17px; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------- WhatsApp ---------------- */
.code-box { border: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--border)); background: var(--brand-soft); border-radius: 14px; padding: 16px; margin: 4px 0 16px; display: grid; gap: 8px; justify-items: start; }
.code-box .code { font-size: 32px; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.code-msg { font-family: var(--mono, ui-monospace, Consolas, monospace); font-weight: 700; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples span { font-size: 12.5px; background: var(--surface-2); border-radius: 999px; padding: 4px 10px; color: var(--ink-2); }
.chat { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 460px; overflow: auto; }
.bubble { max-width: min(80%, 520px); padding: 8px 12px; border-radius: 14px; font-size: 13.5px; }
.bubble.in { justify-self: end; background: color-mix(in srgb, #25A366 14%, var(--surface)); border-bottom-right-radius: 4px; }
.bubble.out { justify-self: start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.status-list dd { text-align: right; }
.err-text { color: var(--negative); font-weight: 600; max-width: 60%; overflow-wrap: anywhere; }
.copy-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.copy-row code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.mt { margin-top: 14px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--grid); }
.admin-actions form { margin: 0; }
.test-form { display: flex; flex-wrap: wrap; gap: 8px; }
.test-form .input { width: auto; min-width: 200px; height: 38px; }
.err-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }

/* ---------------- orçamentos ---------------- */
.limit-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .limit-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .limit-grid { grid-template-columns: repeat(3, 1fr); } }
.limit-grid .field > label { display: flex; align-items: center; gap: 6px; }
.limit-grid .meter { margin-top: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.formula { display: grid; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.formula b { color: var(--ink); }

/* ---------------- dashboard ---------------- */
.warn-t { color: var(--warning); }
.kpis-8 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .kpis-8 .kpi.wide { grid-column: auto; } }
.kpi .meter { margin-top: 8px; }

.dash-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 14px 16px; align-items: end; }
@media (min-width: 760px) { .dash-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .dash-filters { grid-template-columns: 1fr 1fr 1fr 1.2fr 1.4fr 1.2fr auto; } }
.filter-actions { display: flex; gap: 8px; grid-column: 1 / -1; }
@media (min-width: 1200px) { .filter-actions { grid-column: auto; } }
.dash-filters .input { height: 38px; }

.onboarding .panel-body { padding: 20px; }
.onboarding h2 { font-size: 18px; font-weight: 800; }
.onb-steps { display: grid; gap: 14px; margin-top: 14px; }
@media (min-width: 900px) { .onb-steps { grid-template-columns: repeat(3, 1fr); } }
.onb { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.onb b { display: block; font-size: 14px; }
.onb p { color: var(--ink-2); font-size: 13px; margin: 3px 0 10px; }
.onb .btn { margin: 0 6px 6px 0; }
.onb-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; background: var(--brand-soft); color: var(--brand); }

.meter { display: block; width: 100%; height: 8px; overflow: visible; }
.meter.big { height: 12px; margin: 14px 0 6px; }
.meter .track { fill: var(--surface-2); }
.meter .fill { fill: var(--positive); transform-box: fill-box; transform-origin: 0 50%; animation: cresceX .9s cubic-bezier(.16, 1, .3, 1) both; }
.meter.m-warn .fill { fill: var(--warning); } .meter.m-over .fill { fill: var(--negative); }

.spend-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
.spend-value { font-size: 34px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
.spend-daily { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.kv-list { margin: 12px 0 0; display: grid; gap: 0; }
.kv-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--grid); font-size: 13px; }
.kv-list > div:first-child { border-top: 0; }
.kv-list dt { color: var(--ink-2); } .kv-list dd { margin: 0; font-weight: 700; }
.kv-list .total { border-top: 1px solid var(--border-strong); font-size: 14px; }
.kv-list .total dt { color: var(--ink); font-weight: 700; }
#quanto-posso-gastar .alert { margin-top: 12px; }
.alert-warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: color-mix(in srgb, var(--warning) 9%, var(--surface)); color: var(--warning); }
.mini-h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 18px 0 10px; }
.cat-limits { display: grid; gap: 12px; }

.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.top-item, .bar-btn { display: grid; width: 100%; border: 1px solid transparent; background: none; color: var(--ink); text-align: left; cursor: pointer; border-radius: 12px; font: inherit; }
.top-item { grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-color: var(--border); }
.top-item:hover, .bar-btn:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.bar-btn { padding: 6px 8px; margin: -6px -8px; width: calc(100% + 16px); }
.top-rank { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; font-size: 12.5px; color: var(--ink-2); }
.top-main { min-width: 0; display: grid; gap: 2px; }
.top-name { display: flex; align-items: center; gap: 8px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.top-val { font-weight: 800; }

.seg-links { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg-links a { padding: 5px 10px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); text-decoration: none; }
.seg-links a + a { border-left: 1px solid var(--border); }
.seg-links a[aria-current="page"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--brand); }

.chart-wrap { position: relative; }
.chart .hit { fill: transparent; }
.chart .day, .chart .month { cursor: pointer; outline: none; }
.chart .day:hover .hit, .chart .day:focus-visible .hit, .chart .month:hover .hit, .chart .month:focus-visible .hit { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.chart .day.today text { fill: var(--brand); font-weight: 800; }
.chart .b-out.is-max { fill: var(--brand-2); }
.chart .b-out { opacity: .78; } .chart .b-out.above { opacity: 1; }
.chart .avg-line { stroke: var(--ink-2); stroke-width: 1.4; stroke-dasharray: 5 5; }
.chart .avg-label { fill: var(--ink-2); font-size: 12px; font-weight: 700; }
.chart .res-line { fill: none; stroke: var(--info); stroke-width: 2.4; stroke-linejoin: round; }
.chart .res-dot { fill: var(--surface); stroke: var(--info); stroke-width: 2.4; } .chart .res-dot.neg { stroke: var(--negative); }
.legend .l-res { background: var(--info); height: 3px; vertical-align: 3px; }
.daily-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.daily-stats b { color: var(--ink); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  border-radius: 10px; padding: 7px 10px; font-size: 12.5px; font-weight: 600; max-width: 280px; transform: translate(-50%, -100%); white-space: normal; }

.badge.src-wa { background: color-mix(in srgb, #25A366 14%, transparent); color: #1B7F52; }
:root[data-theme="dark"] .badge.src-wa { color: #4fd18b; }
.badge .icon { width: 12px; height: 12px; }

/* painel lateral de detalhes (como no GenSec) */
.drawer { position: fixed; z-index: 55; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .16); display: flex; flex-direction: column; animation: drawerIn .2s cubic-bezier(.16, 1, .3, 1); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 800; flex: 1; }
.drawer-body { padding: 14px 18px 40px; overflow: auto; }
.drawer-bg { position: fixed; inset: 0; z-index: 54; background: rgba(0, 0, 0, .28); }
.drill-sum { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.drill-more { margin-top: 14px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 20px 0; }
.loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--brand); animation: gira .8s linear infinite; }
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- abertura depois do login ----------------
   Começa exatamente como a tela de login termina (ícone ao centro sobre o fundo escuro com brilho vermelho),
   revela a logo completa e some, mostrando o sistema. Só CSS: nada a carregar, e a CSP continua estrita. */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; align-content: center; gap: 18px; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #5a141a 0%, #2a0e11 35%, #0E1013 75%);
  animation: splashSai .55s cubic-bezier(.65, 0, .35, 1) 1.9s forwards; }
.splash-logo { position: relative; width: 281px; height: 112px; display: grid; place-items: center; }
.splash-ico { position: absolute; width: 112px; height: 112px; filter: drop-shadow(0 16px 30px rgba(0, 0, 0, .55));
  animation: splashIco .7s cubic-bezier(.16, 1, .3, 1) .25s forwards; }
.splash-full { width: 281px; height: auto; clip-path: inset(0 100% 0 0); filter: drop-shadow(0 12px 26px rgba(0, 0, 0, .5));
  animation: splashRevela .85s cubic-bezier(.16, 1, .3, 1) .55s forwards; }
.splash-sub { color: rgba(236, 238, 241, .7); font-size: 14px; font-weight: 600; letter-spacing: .02em; opacity: 0;
  animation: splashTexto .6s ease 1.05s forwards; }
body:has(.splash) main.main > * { animation-delay: 2.05s; }
@keyframes splashIco { to { opacity: 0; transform: scale(.55) translateX(-90px); } }
@keyframes splashRevela { to { clip-path: inset(0 0 0 0); } }
@keyframes splashTexto { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes splashSai { to { opacity: 0; transform: scale(1.04); visibility: hidden; } }
@media (max-width: 480px) { .splash-logo, .splash-full { width: 220px; } .splash-logo { height: 90px; } }

/* ---------------- animações (como no GenSec) ---------------- */
@view-transition { navigation: auto; }
.app-side { view-transition-name: am-lado; }
.app-top { view-transition-name: am-topo; }
::view-transition-group(am-lado), ::view-transition-group(am-topo) { animation-duration: 0s; }
::view-transition-old(root) { animation: sai .16s ease both; }
::view-transition-new(root) { animation: entra .28s cubic-bezier(.16, 1, .3, 1) both; }
main.main > * { animation: surge .5s cubic-bezier(.16, 1, .3, 1) both; }
main.main > :nth-child(2) { animation-delay: .04s; } main.main > :nth-child(3) { animation-delay: .08s; }
main.main > :nth-child(4) { animation-delay: .12s; } main.main > :nth-child(n+5) { animation-delay: .16s; }
@keyframes sai { to { opacity: 0; } }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes surge { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sobe { from { transform: scaleY(0); opacity: 0; } 30% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes cresceX { from { transform: scaleX(0); } to { transform: none; } }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .splash { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
