:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --border: #dde3e2;
  --text: #16221f;
  --muted: #62726d;
  --accent: #0d9488;
  --accent-hover: #0b7c72;
  --danger: #dc2626;
  --ok: #16a34a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  overflow-x: auto;
}
.topbar a { color: var(--muted); text-decoration: none; font-size: 0.92rem; white-space: nowrap; }
.topbar a.brand { color: var(--text); font-weight: 700; font-size: 1rem; }
.topbar a:hover { color: var(--accent); }
.topbar a.active { color: var(--accent); font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem; }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 0.75rem; }
.muted { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.flash { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash.ok { background: #ecfdf5; color: var(--ok); }
.flash.erro { background: #fef2f2; color: var(--danger); }

.campo { margin-bottom: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; }
.campo label { font-size: 0.82rem; color: var(--muted); }
input, select, textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--panel);
  color: var(--text);
  width: 100%;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 720px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button.perigo { background: var(--danger); }

summary.botao-abrir {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  cursor: pointer;
  list-style: none;
}
summary.botao-abrir::-webkit-details-marker { display: none; }
details[open] > summary.botao-abrir { margin-bottom: 1rem; }

.acoes { display: flex; gap: 0.6rem; align-items: center; }

.kpi .valor { font-size: 1.6rem; font-weight: 700; margin: 0.15rem 0; }
.kpi .valor.alerta { color: var(--danger); }
.kpi .sub { font-size: 0.78rem; color: var(--muted); }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--panel-2, #f0f2f2);
  color: var(--muted);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }

/* gráfico de barras mensal */
.barras-mensal {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 220px;
  padding-top: 1rem;
}
.barras-mensal.pequeno { height: 140px; }
.coluna { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 2.6rem; height: 100%; }
.par { display: flex; align-items: flex-end; gap: 0.25rem; height: calc(100% - 1.4rem); width: 100%; justify-content: center; }
.barra {
  width: 0.85rem;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
}
.barra.recebido { background: #f59e0b; }
.barra.danger { background: var(--danger); width: 1.4rem; }
.barra.ok { background: var(--ok); width: 1.4rem; }
.rotulo { font-size: 0.68rem; color: var(--muted); margin-top: 0.4rem; white-space: nowrap; }

.legenda-barras { display: flex; gap: 1.2rem; margin-top: 0.9rem; font-size: 0.8rem; color: var(--muted); }
.legenda-barras .ponto { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: middle; }
.ponto.faturado { background: var(--accent); }
.ponto.recebido { background: #f59e0b; }

[data-tooltip] { position: relative; cursor: default; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #16221f;
  color: #fff;
  padding: 0.3rem 0.55rem;
  border-radius: 5px;
  font-size: 0.72rem;
  white-space: nowrap;
  margin-bottom: 0.4rem;
  z-index: 20;
  pointer-events: none;
}
