:root {
  --ink: #14261e;
  --pine: #1c6b48;
  --pine-deep: #0e3324;
  --leaf: #e7f6ee;
  --amber: #e7a11a;
  --amber-soft: #fff4d8;
  --sand: #f3efe6;
  --paper: #fffdf8;
  --line: #e4ddd0;
  --danger: #9d2c2c;
  --danger-soft: #fdeceb;
  --info: #1d4e89;
  --info-soft: #e7f0fa;
  --muted: #5c6b63;
  --shadow: 0 12px 32px rgba(20, 38, 30, .08);
  --radius: 18px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(231, 161, 26, .16), transparent 50%),
    var(--sand);
  min-height: 100vh;
}
body.com-nav { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
body.com-nav .btn,
body.com-nav input,
body.com-nav select,
body.com-nav textarea,
body.com-nav .item-card { scroll-margin-bottom: 140px; scroll-margin-top: 80px; }
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.cabeca { position: sticky; top: 0; z-index: 30; }
.vista-barra {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .55rem 1rem; background: #f6e7c3; color: var(--ink); border-bottom: 1px solid #e3cf96;
}
.vista-barra form { margin: 0; }
.vista-barra .btn { background: white; border-color: #e3cf96; color: var(--ink); }
.topbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem;
  background: var(--pine-deep);
  color: white;
  border-bottom: 3px solid var(--amber);
}
.brand { display: flex; align-items: center; gap: .65rem; color: white; text-decoration: none; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; overflow: hidden;
  background: var(--amber); color: var(--ink);
  font-family: var(--display); font-weight: 700;
}
.brand-mark img, .logo-preview {
  width: 100%; height: 100%; object-fit: contain; background: white;
}
.logo-preview {
  width: 72px; height: 72px; border-radius: 14px;
  border: 1px solid var(--line);
}
.brand-mark-grande { width: 64px; height: 64px; border-radius: 18px; font-size: 1.4rem; margin-bottom: .4rem; }
.brand-texto { display: flex; flex-direction: column; min-width: 0; }
.brand-texto strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.brand-texto small { color: #d7e7df; }
.top-nav { display: none; gap: .25rem; margin-left: auto; }
.nav-link, .bottom-nav a, .sair, .btn-icone {
  display: inline-flex; align-items: center; gap: .35rem;
  color: white; text-decoration: none; border-radius: 999px;
}
.nav-link { padding: .45rem .7rem; color: #d7e7df; }
.nav-link.is-active, .bottom-nav a.is-active { background: rgba(255,255,255,.12); color: white; }
.btn-icone { margin-left: auto; width: 44px; height: 44px; justify-content: center; }
.top-user { display: flex; align-items: center; gap: .6rem; margin-left: .2rem; }
.top-user span { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sair { padding: .35rem .55rem; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom));
  background: rgba(14, 51, 36, .94);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.08);
}
.bottom-nav a {
  flex: 1; flex-direction: column; justify-content: center;
  min-height: 52px; font-size: .72rem; color: #d7e7df;
}
.bottom-nav a.is-active { color: var(--amber); background: transparent; }

.page { width: min(1100px, calc(100% - 1.5rem)); margin: 1rem auto 2rem; }
.flashes { display: grid; gap: .5rem; margin-bottom: 1rem; }
.flash { padding: .75rem 1rem; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); }
.flash-ok { background: var(--leaf); border-color: #b7e4cb; }
.flash-erro { background: var(--danger-soft); border-color: #f0c2c2; }
.flash-info { background: var(--info-soft); border-color: #c5d7ee; }

.mes-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.mes-seta, .btn, .chip {
  min-height: 44px; border-radius: 12px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .45rem .85rem; text-decoration: none; cursor: pointer; background: var(--paper);
}
.mes-seta { color: var(--ink); border-color: var(--line); font-weight: 600; }
.mes-seta:hover { text-decoration: none; background: white; }
.mes-atual { text-align: center; }
.mes-atual strong { display: block; font-family: var(--display); font-size: 1.25rem; }
.mes-atual a { font-size: .85rem; }

.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: 1rem; }
.numero {
  display: flex; flex-direction: column; gap: .15rem;
  background: var(--paper); border-radius: var(--radius); padding: .9rem;
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
  animation: rise .4s ease both;
}
.numero:hover { text-decoration: none; transform: translateY(-2px); }
.numero span { color: var(--muted); font-size: .85rem; }
.numero strong {
  font-family: var(--display); font-size: clamp(1.35rem, 5vw, 2rem);
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.numero small { color: var(--muted); }
.numero.tem-atraso strong { color: #8a5a00; }
.numero.tem-resultado-neg strong { color: var(--danger); }

.bloco, .form-card, .item-card, .grafico-card {
  background: var(--paper); border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.bloco h1, .bloco h2, .form-card h1 { font-family: var(--display); margin: 0 0 .4rem; }
.bloco-topo, .item-card header { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; }
.item-card h3 { margin: 0; font-size: 1.05rem; }
.item-card h3 a { color: inherit; }
.item-card p { margin: .15rem 0; }
.valor { font-family: var(--display); font-size: 1.45rem; font-variant-numeric: tabular-nums; margin: .45rem 0; }
.meta, .ajuda, .registro-audit { color: var(--muted); }
.registro-audit { font-size: 0.85rem; margin: 0.15rem 0 0; }
.periodos { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; }
.periodos li { padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.aviso { background: var(--amber-soft); padding: .7rem .8rem; border-radius: 12px; }

.grade-cards, .somente-cards { display: flex; flex-direction: column; gap: .75rem; }
.item-card { animation: rise .35s ease both; }
.grade-cards .item-card:nth-child(2), .somente-cards .item-card:nth-child(2) { animation-delay: .04s; }
.grade-cards .item-card:nth-child(3), .somente-cards .item-card:nth-child(3) { animation-delay: .08s; }

.badge { border-radius: 999px; padding: .2rem .55rem; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-pago { background: var(--leaf); color: #0f5c3a; }
.badge-aberto { background: var(--info-soft); color: var(--info); }
.badge-atrasado { background: var(--amber-soft); color: #8a5a00; }

.btn { font-weight: 700; }
.btn-primary { background: var(--pine); color: white; }
.btn-recebi { background: var(--pine); color: white; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: transparent; border-color: #e7c1c1; color: var(--danger); margin-top: .8rem; }
.btn-zap { background: #e9f8ef; color: #0f5c3a; border-color: #b7e4cb; }
.btn:hover { text-decoration: none; filter: brightness(1.03); }
.acesso { margin-top: .9rem; }
.acesso h3 { margin: .9rem 0 .35rem; font-size: 1rem; }
.acesso-pessoa {
  margin-top: .75rem; padding: .75rem;
  border: 1px solid var(--line); border-radius: 12px; background: white;
}
.acesso .grade-form { grid-template-columns: 1fr; }
.acesso-pessoa form { margin-top: .55rem; }
.acoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.acoes form, .barra-acoes form { display: flex; }
.acoes .btn, .acoes form { flex: 1 1 40%; }
.acoes form .btn, .barra-acoes form .btn { width: 100%; }
.barra-acoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.acoes-tabela { display: flex; flex-wrap: wrap; gap: .35rem; }
.acoes-tabela form { display: inline; }

.busca-form { margin-bottom: .6rem; }
.busca {
  display: flex; align-items: center; gap: .45rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 0 .8rem;
}
.busca input, .campo input, .campo select, .campo textarea {
  width: 100%; min-height: 44px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; background: white;
}
.busca input { border: 0; padding-left: 0; background: transparent; }
.filtros { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; }
.chip { background: transparent; border-color: var(--line); white-space: nowrap; }
.chip.is-on { background: var(--ink); color: white; border-color: var(--ink); }
.campo { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.campo-select { min-width: 11rem; }
.grade-form { display: grid; gap: .75rem; }
.check { flex-direction: row; align-items: center; font-weight: 600; }
.check input { width: 1.1rem; height: 1.1rem; }
.contagem { color: var(--muted); min-height: 1.2rem; margin-top: 0; }

.somente-tabela { display: none; }
.tabela-wrap { overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--line); border-radius: 16px; }
.tabela { width: 100%; border-collapse: collapse; min-width: 720px; }
.tabela th, .tabela td { padding: .75rem .8rem; text-align: left; vertical-align: middle; }
.tabela th {
  position: sticky; top: 0; z-index: 2;
  background: var(--pine-deep); color: white; font-weight: 600; font-size: .85rem;
}
.tabela td { border-top: 1px solid var(--line); background: var(--paper); }
.tabela small { color: var(--muted); }

.dre-grid, .graficos, .plataforma-grid { display: grid; gap: .8rem; }
.linha { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.linha strong { font-variant-numeric: tabular-nums; }
.linha-total { font-weight: 700; }
.linha-resultado { font-family: var(--display); font-size: 1.25rem; border-bottom: 0; padding-top: .8rem; }
.linha-resultado.negativo strong { color: var(--danger); }
.grafico-card h2 { font-family: var(--display); font-size: 1rem; margin: 0 0 .6rem; }
.lista-simples { list-style: none; padding: 0; margin: 0 0 1rem; }
.lista-simples li { display: flex; justify-content: space-between; gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.erros { color: var(--danger); }
.vazio { color: var(--muted); background: rgba(255,255,255,.55); border-radius: 12px; padding: .9rem; }
.login-corpo { min-height: calc(100vh - 2rem); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); }
.ico { width: 1.15rem; height: 1.15rem; flex: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 800px) {
  .numeros { grid-template-columns: repeat(4, 1fr); }
  .grade-form { grid-template-columns: 1fr 1fr; }
  .campo-largo { grid-column: 1 / -1; }
  .dre-grid, .plataforma-grid { grid-template-columns: 1fr 1fr; }
  .graficos { grid-template-columns: 1fr 1fr; }
  .grafico-largo { grid-column: 1 / -1; }
  .grade-cards { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .top-nav { display: flex; }
  .bottom-nav { display: none; }
  body.com-nav { padding-bottom: 2rem; }
  .somente-cards { display: none; }
  .somente-tabela { display: block; }
  .btn-icone { margin-left: 0; }
}
@media (max-width: 420px) {
  .top-user span, .mes-seta span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
@media print {
  .cabeca, .topbar, .vista-barra, .bottom-nav, .mes-nav, .barra-acoes, .btn, .flashes { display: none !important; }
  body { background: white; }
  .bloco, .numero, .item-card { box-shadow: none; border: 1px solid #ddd; }
}
