:root {
  --bg: #f5f4f2; --panel: #ffffff; --ink: #1c1f26; --muted: #6f7480; --line: #e7e4e0;
  /* Paleta: grena com preto e azul escuro; o ouro fica reservado a balanca e aos titulos de grupo. */
  --grena: #6e1b2b; --grena-clara: #8a2437; --grena-escura: #571421;
  --preto: #15171c; --azul: #16233b; --azul-claro: #29477a;
  --ouro: #c9a227; --ouro-claro: #e0c35c; --ouro-escuro: #a8861b;
  --brand: var(--azul); --brand-2: var(--grena);
  --ok: #1d6f4a; --warn: #a97116; --danger: #9d2118; --info: #24406b;
  --radius: 8px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 13.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--azul-claro); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 500; margin: 0 0 3px; letter-spacing: -.2px; }
h2 { font-size: 15px; font-weight: 500; margin: 0 0 8px; }
h3 { font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.muted { color: var(--muted); }
small { font-size: 12px; }

.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--preto) 0%, var(--azul) 100%); border-right: 3px solid var(--grena); color: #d8dae1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 20px 18px 15px; border-bottom: 1px solid rgba(201,162,39,.22); margin-bottom: 6px; }
.brand a { display: flex; align-items: center; gap: 9px; color: #fff; }
.brand a:hover { text-decoration: none; opacity: .85; }
.marca-icone { width: 21px; height: 21px; flex: none; color: var(--ouro); }
.marca { font-size: 19px; font-weight: 300; letter-spacing: .2px; }
.marca em { font-style: normal; font-weight: 300; color: var(--ouro); }
.sidebar nav { display: flex; flex-direction: column; padding: 0 10px; }
.sidebar nav a { color: #d2d5dd; padding: 6px 10px; border-radius: 5px; font-size: 13px; font-weight: 300; border-left: 2px solid transparent; }
.sidebar nav a:hover { background: rgba(110,27,43,.55); border-left-color: var(--ouro); color: #fff; text-decoration: none; }
.nav-group { margin: 15px 10px 3px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: var(--ouro); opacity: .8; }
.sidebar-footer { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(201,162,39,.2); font-size: 13px; }
.sidebar-footer .user { margin-bottom: 4px; }
button.link { background: none; border: 0; color: var(--ouro-claro); cursor: pointer; padding: 0; font-size: 13px; }
.content { padding: 22px 30px; max-width: 1400px; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header .acoes { display: flex; gap: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .rotulo { font-size: 11.5px; font-weight: 400; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi .valor { font-size: 23px; font-weight: 400; margin-top: 2px; letter-spacing: -.3px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.ok { border-left: 4px solid var(--ok); } .kpi.warn { border-left: 4px solid var(--warn); } .kpi.danger { border-left: 4px solid var(--danger); } .kpi.info { border-left: 4px solid var(--info); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #fbfcfd; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.alerta td { background: #fff5f5; }
.table tr.aviso td { background: #fffaf0; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: #ece9e6; color: var(--azul); white-space: nowrap; }
.tag.ok { background: #e3f5ea; color: var(--ok); } .tag.warn { background: #fdf1dc; color: var(--warn); } .tag.danger { background: #fde4e1; color: var(--danger); } .tag.info { background: #e1ebfa; color: var(--info); }
.semaforo { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.semaforo.verde { background: var(--ok); } .semaforo.amarelo { background: var(--warn); } .semaforo.vermelho { background: var(--danger); }

form .campo { margin-bottom: 12px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=email], input[type=password], input[type=time], input[type=file], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #cfd5de; border-radius: 6px; font: inherit; background: #fff;
}
textarea { min-height: 90px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.btn { display: inline-block; padding: 6px 13px; border-radius: 5px; font-weight: 400; border: 1px solid var(--brand-2); background: var(--brand-2); color: #fff; font: inherit; cursor: pointer; }
.btn:hover { background: var(--grena-escura); border-color: var(--grena-escura); text-decoration: none; }
.btn.secundario { background: #fff; color: var(--brand-2); }
.btn.perigo { background: var(--danger); border-color: var(--danger); }
.btn.pequeno { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash.ok { background: #e3f5ea; color: var(--ok); } .flash.erro { background: #fde4e1; color: var(--danger); }
.paginacao { display: flex; gap: 14px; margin-top: 12px; align-items: center; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 6px 0 10px 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); }
.timeline .quando { font-size: 12px; color: var(--muted); }
.barra { display: flex; height: 18px; border-radius: 4px; overflow: hidden; background: #eee; }
.barra span { display: block; height: 100%; }
.barra .tempo { background: var(--azul); } .barra .despesas { background: var(--grena); } .barra .overhead { background: #9a9186; }
.memoria { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 10px; white-space: pre-wrap; max-height: 360px; overflow: auto; }
.login-box { max-width: 370px; margin: 12vh auto; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--grena); border-radius: 10px; padding: 30px 28px; }
.login-box .brand { padding: 0 0 20px; }
.login-box .marca { font-size: 25px; color: var(--azul); }
.login-box .marca-icone { width: 26px; height: 26px; color: var(--ouro-escuro); }
.login-box .marca em { color: var(--grena); }
.aviso-ia { background: #fff8e6; border: 1px solid #f0d9a0; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.definicoes dt { font-size: 12px; color: var(--muted); margin-top: 8px; }
.definicoes dd { margin: 0; }

/* Formulários: blocos que aparecem conforme pessoa física ou jurídica, e busca de CEP. */
[hidden] { display: none !important; }
.campo small.muted { display: block; margin-top: 3px; font-size: 11px; }
input.buscando { background-image: linear-gradient(90deg, transparent, rgba(110,27,43,.10), transparent); background-size: 200% 100%; animation: jf-buscando 1s linear infinite; }
@keyframes jf-buscando { from { background-position: 200% 0; } to { background-position: -200% 0; } }
