:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #e4e7ec;
  --brand: #1f4e79; --brand-2: #2f6fa8; --ok: #12805c; --bad: #c0392b; --warn: #b7791f;
  --ok-bg: #e7f6ef; --bad-bg: #fdecea; --warn-bg: #fff6e0;
  --radius: 10px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
nav.lateral { background: #14304d; color: #cfd8e3; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
nav.lateral .marca { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
nav.lateral a { display: block; color: #cfd8e3; padding: 8px 10px; border-radius: 8px; }
nav.lateral a:hover, nav.lateral a.ativo { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
nav.lateral .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8aa0b8; margin: 16px 10px 6px; }
nav.lateral form button { background: none; border: 0; color: #cfd8e3; padding: 8px 10px; cursor: pointer; font: inherit; }
main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.topo { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topo h1 { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grade { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; container-type: inline-size; }
.kpi .rot { color: var(--muted); font-size: 13px; }
.kpi .val { font-size: clamp(15px, 9cqi, 22px); font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: #fafbfc; }
.tabela-wrap { overflow-x: auto; }
.btn, button.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn.sec { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.perigo { background: var(--bad); }
.btn.peq { padding: 4px 9px; font-size: 12px; }
.acoes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.acoes form { display: inline; margin: 0; }
form.campos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
form.campos .l2 { grid-column: span 2; } form.campos .l3 { grid-column: 1 / -1; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd4dc; border-radius: 8px; font: inherit; font-size: 14px; background: #fff; color: var(--ink); }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filtros > div { min-width: 130px; }
.barra-lote { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px;
              background: var(--bad-bg); border-radius: 8px; }
.barra-lote[hidden] { display: none; }
.lote-resumo { font-weight: 600; margin-right: auto; }
th.ordenavel { cursor: pointer; user-select: none; white-space: nowrap; }
th.ordenavel:hover { color: var(--brand-2); }
th.ordenavel::after { content: " ↕"; opacity: .35; }
th.ordenavel[data-ordem="asc"]::after { content: " ▲"; opacity: 1; }
th.ordenavel[data-ordem="desc"]::after { content: " ▼"; opacity: 1; }
.busca-tabela { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.busca-tabela input { max-width: 460px; padding: 9px 12px; border-radius: 99px; background: #f8fafc; }
.busca-tabela input:focus { outline: 2px solid var(--brand-2); background: #fff; }
.busca-contador { color: var(--muted); font-size: 13px; white-space: nowrap; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.erro { background: var(--bad-bg); color: var(--bad); }
.aviso { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #eef1f5; color: #475467; white-space: nowrap; }
.tag.pago { background: var(--ok-bg); color: var(--ok); }
.tag.atrasado { background: var(--bad-bg); color: var(--bad); }
.tag.previsto { background: #eaf1fb; color: var(--brand-2); }
.receita { color: var(--ok); } .despesa { color: var(--bad); }
.muted { color: var(--muted); font-size: 13px; }
.barras { display: flex; gap: 6px; align-items: flex-end; height: 160px; padding-top: 10px; }
.barras .mes { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.barras .par { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.barras .b { width: 42%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.barras .b.r { background: #2e9e6e; } .barras .b.d { background: #d9534f; }
.barras .rot { font-size: 11px; color: var(--muted); }
.legenda { font-size: 12px; color: var(--muted); display: flex; gap: 14px; margin-top: 6px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.login { max-width: 400px; margin: 10vh auto; }
.login .card { padding: 28px; }
.login h1 { text-align: center; }
.codigo-input { font-size: 26px; letter-spacing: .4em; text-align: center; }
dl.det { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 20px; margin: 0; }
dl.det dt { font-size: 12px; color: var(--muted); }
dl.det dd { margin: 2px 0 0; }
.dois { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  nav.lateral { position: static; height: auto; }
  form.campos, dl.det, .dois { grid-template-columns: 1fr; }
  form.campos .l2 { grid-column: auto; }
  main { padding: 16px; }
}
