/* Nexa Financeiro — identidade Nexa: preto, branco, verde-lima #B7D80A */
:root {
  --bg: #F4F4F1; --surface: #FFFFFF; --surface-2: #FAFAF8; --ink: #0B0B0B; --muted: #6B6B66; --line: #E2E2DD;
  --lime: #B7D80A; --on-lime: #0B0B0B; --side: #0B0B0B; --side-ink: #EDEDEA; --side-muted: #8E8E88;
  --in: #2E7A1F; --out: #B3261E; --warn-bg: #FFF4C7; --warn-ink: #725400; --bad-bg: #FDE3E1; --ok-bg: #E6F4DA;
  --s-in: #1baf7a; --s-out: #eb6834; --grid: #E8E8E3;
  --f-display: "Space Grotesk", system-ui, sans-serif; --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "DM Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E0D; --surface: #171716; --surface-2: #1D1D1B; --ink: #F0F0EC; --muted: #9C9C96; --line: #2C2C29;
    --in: #8BD46E; --out: #FF8A80; --warn-bg: #3A3000; --warn-ink: #F2D36B; --bad-bg: #3B1512; --ok-bg: #1C2E14;
    --s-in: #199e70; --s-out: #d95926; --grid: #2A2A27; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.num, .money { font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--in); } .neg { color: var(--out); } .muted { color: var(--muted); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 4px 8px; }
.brand img { display: block; max-width: 100%; }
.brand span { font: 500 11px var(--f-mono); color: var(--side-muted); text-transform: uppercase; letter-spacing: .14em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { text-decoration: none; padding: 9px 10px; border-radius: 8px; color: var(--side-muted); font-weight: 500; display: flex; justify-content: space-between; }
.nav a:hover { color: var(--side-ink); background: #1A1A19; }
.nav a.on { color: var(--on-lime); background: var(--lime); }
.nav .sep { height: 1px; background: #232321; margin: 8px 4px; }
.side .user { margin-top: auto; font-size: 12px; color: var(--side-muted); padding: 0 8px; display: flex; flex-direction: column; gap: 6px; }
.side .user b { color: var(--side-ink); font-weight: 600; }
.side .user button { background: none; border: 1px solid #2C2C2A; color: var(--side-ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; text-align: left; }
.main { padding: 26px clamp(16px, 3vw, 36px) 60px; min-width: 0; }
.topbar { display: none; }
@media (max-width: 880px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .app.menu .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--side); color: var(--side-ink); padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; position: sticky; top: 0; z-index: 20; }
  .topbar button { background: none; border: 1px solid #333; color: inherit; border-radius: 8px; padding: 6px 10px; }
  .main { padding-top: 18px; }
}

/* ---------- títulos e blocos ---------- */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.head h1 { font: 700 clamp(24px, 3.4vw, 30px)/1.05 var(--f-display); letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.head p { margin: 4px 0 0; color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.card h2 { font: 700 16px var(--f-display); margin: 0 0 12px; }
.card h2 small { font: 400 12px var(--f-body); color: var(--muted); margin-left: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.eyebrow { font: 500 11px var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .v { font: 500 clamp(17px, 1.9vw, 21px) var(--f-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.kpi.dark .eyebrow, .kpi.dark .s { color: inherit; opacity: .7; }

/* ---------- controles ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--lime); border-color: var(--lime); color: var(--on-lime); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.link { border: 0; background: none; padding: 2px 4px; font-weight: 500; text-decoration: underline; color: var(--muted); }
.btn.danger { color: var(--out); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
input, select, textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
.inline-input { padding: 6px 8px; border-radius: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 6px 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--bg); }
.seg button.on.e-in { background: var(--in); color: #fff; } .seg button.on.e-out { background: var(--out); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.picker { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.picker button { border: 0; background: none; border-radius: 7px; padding: 6px 10px; cursor: pointer; font-weight: 700; }
.picker span { font: 600 14px var(--f-display); min-width: 120px; text-align: center; }

/* ---------- tabelas ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font: 600 11px var(--f-body); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
td.r, th.r { text-align: right; }
tr:hover td { background: var(--surface-2); }
tr.total td { font-weight: 700; background: var(--surface-2); }
tr.destaque td { font-weight: 700; background: var(--ink); color: var(--bg); }
tr.destaque td .neg { color: #FF8A80; } tr.destaque td .pos { color: #B7D80A; }
tr.pct td { font-size: 12px; color: var(--muted); font-style: italic; }
tr.secao td { background: var(--lime); color: var(--on-lime); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tr.sub td:first-child { padding-left: 26px; color: var(--muted); }
.wide table { min-width: 1180px; }
.wide td:first-child, .wide th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 240px; }
.wide tr.total td:first-child { background: var(--surface-2); } .wide tr.destaque td:first-child { background: var(--ink); } .wide tr.secao td:first-child { background: var(--lime); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); border-color: transparent; color: var(--in); }
.tag.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn-ink); }
.tag.bad { background: var(--bad-bg); border-color: transparent; color: var(--out); }
.tag.lime { background: var(--lime); border-color: transparent; color: var(--on-lime); }
.bar-in, .bar-out { display: inline-block; width: 4px; height: 18px; border-radius: 2px; vertical-align: middle; margin-right: 8px; }
.bar-in { background: var(--in); } .bar-out { background: var(--out); }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 700 16px var(--f-display); margin-bottom: 4px; }

/* ---------- gráfico ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 11px var(--f-mono); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 8px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; }
.tip b { font-family: var(--f-mono); font-weight: 500; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--side); }
.login .box { background: var(--surface); width: min(400px, 100%); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font: 700 26px var(--f-display); margin: 0; }
.login-wrap { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.login-wrap .brand { align-items: center; padding: 12px; }

/* ---------- avisos ---------- */
.banner { border-radius: 10px; padding: 10px 14px; font-size: 13px; background: var(--warn-bg); color: var(--warn-ink); margin-bottom: 16px; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; font-weight: 500; max-width: calc(100% - 32px); }
.toast.err { background: var(--out); color: #fff; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); }
.drop.on { border-color: var(--lime); background: var(--surface-2); }
.dim td { opacity: .5; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
