:root {
  color-scheme: light;
  /* ── Identidade Analitika Digital ─────────────────────────────── */
  --azul: #2f6fb3;            /* primária (azul médio Analitika) */
  --azul-claro: #5b9bd5;      /* azul claro de apoio */
  --azul-profundo: #1b2a63;   /* azul-marinho (texto/headings/totais) */
  --amarelo: #fbbd3a;
  --laranja: #f07d3a;
  --rosa: #e23d4d;            /* agora VERMELHO — valores negativos */
  --verde: #2cb4a0;           /* verde — valores positivos */
  --cinza: #f4f4f4;
  --cinza-claro: #f5f5f5;
  --cinza-escuro: #706f6f;
  --texto: #737272;
  --preto: #000000;
  --branco: #ffffff;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --ink: #1b2a63;
  --muted: #706f6f;
  --line: #ededed;
  --accent: #2f6fb3;          /* marca (botões, destaques) = azul */
  --accent-dark: #235a92;
  --success: #2cb4a0;
  --warn: #fff6df;
  --shadow: 0 18px 45px rgba(27, 42, 99, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Poppins", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: var(--cinza-claro);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  min-height: 92px;
  padding: 0 32px 0 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar::before {
  background: var(--branco);
  content: "";
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: min(42vw, 520px);
  z-index: -1;
}

.brand {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 12px;
  min-height: 64px;
  padding: 0 24px;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-text strong {
  color: var(--azul-profundo);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-text small {
  color: var(--azul);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-top: 3px;
}

nav {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  gap: 18px;
  justify-content: flex-end;
  text-transform: uppercase;
}

nav a:hover {
  color: var(--azul);
}

nav form {
  margin: 0;
}

.page {
  margin: 0 auto;
  max-width: 1280px;
  padding: 42px 32px;
}

.toolbar {
  align-items: end;
  background: var(--branco);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 24px;
  overflow: hidden;
  padding: 30px 34px;
  position: relative;
}

.toolbar::before {
  background: linear-gradient(180deg, var(--azul-claro), var(--azul-profundo));
  content: "";
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 10px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  color: var(--azul-profundo);
  font-size: 38px;
  font-weight: 900;
  line-height: 1.15;
}

h2 {
  color: var(--azul-profundo);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
}

h3 {
  color: var(--azul-profundo);
}

p,
span,
label {
  color: var(--muted);
}

p {
  font-weight: 300;
}

.grid {
  display: grid;
  gap: 20px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel h2 {
  align-items: center;
  display: flex;
  gap: 10px;
}

.panel h2::before {
  background: var(--azul);
  border-radius: 999px;
  content: "";
  display: inline-block;
  flex: 0 0 auto;
  height: 10px;
  width: 10px;
}

.row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 0;
}

.row:first-of-type {
  border-top: 0;
}

.row span {
  display: block;
  margin-top: 4px;
}

.actions,
.chips,
.connect-bar,
.inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  display: grid;
  font-size: 14px;
  font-weight: 600;
  gap: 6px;
  margin-bottom: 14px;
}

input,
select {
  background: var(--branco);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 10px 14px;
}

input:focus,
select:focus {
  border-color: var(--azul);
  outline: 2px solid rgba(47, 111, 179, 0.18);
}

.button,
.chip,
.link-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--branco);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  min-height: 40px;
  padding: 10px 18px;
  text-transform: uppercase;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.button:hover,
.chip:hover,
.link-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--branco);
}

.button.ghost,
.chip,
.link-button {
  background: var(--branco);
  border-color: var(--accent);
  color: var(--accent);
}

.link-button {
  min-height: 32px;
  padding: 5px 10px;
}

.login-body {
  background: var(--cinza-claro);
}

.login-shell {
  background:
    linear-gradient(90deg, var(--azul-profundo) 0 38%, transparent 38%),
    var(--cinza-claro);
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  border: 0;
  box-shadow: 0 24px 60px rgba(33, 30, 65, 0.18);
  max-width: 420px;
  padding: 34px;
  width: 100%;
}

.login-kicker {
  color: var(--azul);
  display: block;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.error {
  background: #ffe8e8;
  border: 1px solid #f3b4b4;
  border-radius: 10px;
  color: #8a1f1f;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.notice {
  background: var(--warn);
  border: 1px solid var(--amarelo);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  padding: 16px;
}

pre {
  background: var(--azul-profundo);
  border-radius: 10px;
  color: #e5edf5;
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
}

/* ── Report page layout ─────────────────────────────────────── */

.reports-toolbar {
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

/* ── Sync bar ───────────────────────────────────────────────────── */

.sync-bar {
  align-items: center;
  display: flex;
  gap: 10px;
}

.sync-status {
  align-items: center;
  border-radius: 20px;
  display: flex;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
  padding: 5px 12px;
  white-space: nowrap;
}

.sync-ok {
  background: #e6f7f5;
  color: var(--verde);
}

.sync-never {
  background: #fff6df;
  color: #a06000;
}

.sync-dot {
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  height: 7px;
  width: 7px;
}

.sync-ok .sync-dot    { background: var(--verde); }
.sync-never .sync-dot { background: var(--amarelo); }

.sync-badge {
  background: rgba(0,0,0,0.08);
  border-radius: 10px;
  font-size: 10px;
  padding: 1px 6px;
}

/* ── Client selector grid ───────────────────────────────────────── */

.client-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: 28px;
}

.client-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  text-decoration: none;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.12s;
}

.client-card:hover {
  border-color: var(--azul);
  box-shadow: 0 20px 48px rgba(33,30,65,0.14);
  transform: translateY(-2px);
}

.client-card-name {
  color: var(--azul-profundo);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.client-card-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.client-card-meta {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 6px;
}

.client-card-meta > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.client-oauth {
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
}

.client-oauth-ok  { background: #e6f7f5; color: var(--verde); }
.client-oauth-off { background: var(--cinza); color: var(--muted); }

/* ── Company status badges ──────────────────────────────────────── */

.co-badge {
  border-radius: 6px;
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  text-transform: uppercase;
}

.co-badge-ok   { background: #e6f7f5; color: var(--verde); }
.co-badge-sync { background: #f0f4ff; color: #3a5cc4; }
.co-badge-warn { background: var(--warn); color: #a06000; }
.co-badge-off  { background: var(--cinza); color: var(--muted); }

/* ── Cash position panel ────────────────────────────────────────── */

.cash-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

/* ── Lançamentos page ───────────────────────────────────────────── */

.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding: 18px 22px;
}

.filter-row {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 700;
  gap: 5px;
  margin: 0;
  min-width: 120px;
}

.filter-field span { color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.filter-field select,
.filter-field input { font-size: 13px; min-height: 36px; padding: 6px 10px; }

.filter-field-wide { min-width: 200px; }

.filter-actions {
  align-items: flex-end;
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.lc-summary {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.lc-table { table-layout: fixed; }
.lc-table th:nth-child(1) { width: 92px; }
.lc-table th:nth-child(2) { width: auto; }
.lc-table th:nth-child(3) { width: 160px; }
.lc-table th:nth-child(4) { width: 150px; }
.lc-table th:nth-child(5) { width: 150px; }
.lc-table th:nth-child(6) { width: 110px; }
.lc-table th:nth-child(7) { width: 90px; }
.lc-table th:nth-child(8) { width: 80px; }

.lc-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lc-tag {
  background: var(--cinza);
  border-radius: 5px;
  color: var(--azul-profundo);
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lc-tag-locked { background: #fff6df; color: #a06000; }
.lc-tag-empty  { background: transparent; color: var(--muted); font-weight: 400; }

.lc-status {
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.lc-status-ok   { background: #e6f7f5; color: var(--verde); }
.lc-status-over { background: #ffeaf0; color: var(--rosa); }
.lc-status-pend { background: #fff6df; color: #a06000; }

.lc-edit-btn {
  color: var(--azul);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.lc-edit-btn:hover { color: var(--accent-dark); }
.lc-edit-cancel    { color: var(--muted); }

tr.lc-editing { background: #f0faf9; }

tr.lc-edit-row td {
  background: #eef4fb;
  border-bottom: 2px solid var(--azul);
  padding: 14px 16px;
}

.lc-edit-form {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.lc-edit-note {
  color: var(--muted);
  font-size: 11px;
  margin: 8px 0 0;
}

.lc-pagination {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.lc-page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--azul-profundo);
  font-size: 13px;
  font-weight: 600;
  min-width: 36px;
  padding: 6px 10px;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
}

.lc-page:hover        { background: var(--cinza); }
.lc-page-active       { background: var(--accent); border-color: var(--accent); color: #fff; }
.lc-page-gap          { color: var(--muted); padding: 6px 4px; }

.filter-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chips .chip {
  font-size: 12px;
  min-height: 32px;
  padding: 5px 12px;
}

/* ── Section headers ────────────────────────────────────────── */

.report-section {
  margin-bottom: 32px;
}

.section-header {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header h3 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.section-header::after {
  background: var(--line);
  content: "";
  flex: 1;
  height: 1px;
}

/* ── KPI strip ──────────────────────────────────────────────── */

.kpi-strip {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 28px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.kpi-value {
  color: var(--azul-profundo);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 4px;
}

.kpi-value.positive { color: var(--verde); }
.kpi-value.negative { color: var(--rosa); }

.kpi-sub {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ── Report 2/3-col grids ───────────────────────────────────── */

.r2 {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 14px;
}

.r3 {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}

.r5 {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 14px;
}

.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

/* ── Financial statement (DRE) ──────────────────────────────── */

.fin-row {
  align-items: baseline;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 0;
}

/* O atributo hidden precisa vencer o display:flex acima (subgrupos da DRE) */
.fin-row[hidden] { display: none !important; }

.fin-row:first-child { border-top: 0; }

.fin-row.total {
  border-top: 2px solid var(--azul-profundo);
  font-weight: 800;
  margin-top: 2px;
  padding-top: 10px;
}

.fin-row.space {
  border-top: 0;
  padding: 4px 0 0;
}

.fin-label {
  color: var(--muted);
  font-size: 13px;
}

.fin-label.indent { padding-left: 14px; }

.fin-row.total .fin-label {
  color: var(--azul-profundo);
  font-size: 14px;
}

.fin-val {
  color: var(--azul-profundo);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.fin-row.total .fin-val { font-size: 14px; }
.fin-val.positive { color: var(--verde); }
.fin-val.negative { color: var(--rosa); }

/* ── Bar charts ─────────────────────────────────────────────── */

.bar-list { display: grid; gap: 10px; }

.bar-item { display: grid; gap: 5px; }

.bar-meta {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.bar-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-amount {
  color: var(--azul-profundo);
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.bar-track {
  background: var(--cinza);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.bar-fill {
  background: var(--azul);
  border-radius: 999px;
  height: 100%;
  min-width: 3px;
}

.bar-fill.warn    { background: var(--amarelo); }
.bar-fill.orange  { background: var(--laranja); }
.bar-fill.danger  { background: var(--rosa); }
.bar-fill.accent  { background: var(--azul-profundo); }

/* ── Badges ─────────────────────────────────────────────────── */

.badge {
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  text-transform: uppercase;
}

.badge-a { background: #e6f7f5; color: var(--verde); }
.badge-b { background: #fff6df; color: #a06000; }
.badge-c { background: #ffeaf0; color: var(--rosa); }

/* ── Data table ─────────────────────────────────────────────── */

.data-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}

.data-table th {
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 7px 8px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  border-bottom: 1px solid var(--line);
  color: var(--azul-profundo);
  padding: 9px 8px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num { font-weight: 600; text-align: right; white-space: nowrap; }
.data-table td.muted { color: var(--muted); }

/* ── Progress bar (budget vs actual) ───────────────────────── */

.progress-track {
  background: var(--cinza);
  border-radius: 999px;
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  background: var(--azul);
  border-radius: 999px;
  height: 100%;
  min-width: 3px;
  transition: width 0.4s ease;
}

.progress-fill.over { background: var(--rosa); }

/* ── Gap indicator ──────────────────────────────────────────── */

.gap-flag {
  background: var(--warn);
  border: 1px solid var(--amarelo);
  border-radius: 7px;
  color: #7a5500;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 12px;
  padding: 7px 10px;
}

/* ── Collapsible data gaps ──────────────────────────────────── */

.gaps-toggle {
  align-items: center;
  background: var(--warn);
  border: 1px solid var(--amarelo);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  justify-content: space-between;
  list-style: none;
  margin-bottom: 20px;
  padding: 12px 16px;
}

.gaps-toggle::-webkit-details-marker { display: none; }

details.gaps-block[open] .gaps-toggle {
  border-radius: 10px 10px 0 0;
  margin-bottom: 0;
}

.gaps-body {
  background: var(--warn);
  border: 1px solid var(--amarelo);
  border-radius: 0 0 10px 10px;
  border-top: 0;
  display: grid;
  font-size: 12px;
  gap: 6px;
  margin-bottom: 20px;
  padding: 10px 16px 14px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0 4px;
  text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 760px) {
  .topbar,
  .toolbar,
  .row {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 0 20px 18px;
  }

  .topbar::before,
  .brand {
    width: 100%;
  }

  nav {
    justify-content: flex-start;
  }

  .page {
    padding: 20px;
  }

  .two {
    grid-template-columns: 1fr;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .login-shell {
    background:
      linear-gradient(180deg, var(--azul-profundo) 0 26%, transparent 26%),
      var(--cinza-claro);
  }

  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .r2, .r3, .r5 {
    grid-template-columns: 1fr;
  }

  .span2, .span3 { grid-column: span 1; }

  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Tooltips de métricas ────────────────────────────────────────── */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  background: var(--branco);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: help;
  position: relative;
  vertical-align: middle;
  user-select: none;
  flex: none;
}
.tip:hover,
.tip:focus-visible {
  color: var(--branco);
  background: var(--azul-profundo);
  border-color: var(--azul-profundo);
  outline: none;
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 250px;
  background: var(--azul-profundo);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  letter-spacing: .1px;
  text-align: left;
  padding: 9px 11px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity .14s ease;
  z-index: 60;
  pointer-events: none;
  white-space: normal;
}
.tip::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--azul-profundo);
  opacity: 0;
  visibility: hidden;
  transition: opacity .14s ease;
  z-index: 60;
  pointer-events: none;
}
.tip:hover::after,
.tip:hover::before,
.tip:focus-visible::after,
.tip:focus-visible::before {
  opacity: 1;
  visibility: visible;
}
/* Tooltips em células de tabela alinhadas à direita não cortam */
.data-table .tip::after { left: auto; right: 0; transform: none; }
.data-table .tip::before { left: auto; right: 6px; transform: none; }

/* ── Badge "novo" no quadro de produtos ──────────────────────────── */
.pill-new {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--verde);
  background: rgba(44, 180, 160, 0.12);
  border: 1px solid rgba(44, 180, 160, 0.4);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ── Gráficos: seletor de período (6M / 12M / 24M) ───────────────── */
.chart-period-btns {
  display: inline-flex;
  gap: 3px;
  margin-left: auto;
  padding: 3px;
  background: var(--cinza-claro);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.chart-period-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: "Poppins", sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.chart-period-btn:hover {
  color: var(--azul-profundo);
}
.chart-period-btn.active {
  background: var(--azul-profundo);
  color: #fff;
  box-shadow: 0 2px 6px rgba(33, 30, 65, 0.18);
}
.chart-panel h2 {
  margin-bottom: 10px;
}
.chart-panel canvas {
  width: 100% !important;
  max-height: 300px;
}

/* ── Cadastros (settings) ────────────────────────────────────────── */
.settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  align-items: start;
}
.settings-grid .panel { margin: 0; }
.field-grid {
  display: grid;
  gap: 12px 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 14px;
}
.field-grid label { margin-bottom: 0; }
.help-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  margin: -2px 0 14px;
}
.status-pill {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  vertical-align: middle;
}
.status-ok  { color: var(--verde); background: rgba(44, 180, 160, 0.12); }
.status-off { color: var(--laranja); background: rgba(240, 125, 58, 0.12); }
.mono {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--azul-profundo);
}

/* ── CRUD inline (editar/excluir) em Cadastros ───────────────────── */
.crud-row { align-items: flex-start; }
.crud-row .actions { gap: 6px; }
.button.tiny {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1;
}
.inline-edit { position: relative; }
.inline-edit > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.inline-edit > summary::-webkit-details-marker { display: none; }
.edit-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px;
}
.edit-pop input { min-height: 34px; padding: 6px 10px; width: 130px; }
.edit-pop-wide { flex-wrap: wrap; width: 280px; }
.edit-pop-wide input { width: 100%; }

/* ── Estados inativos e chips de vínculo ─────────────────────────── */
.is-inactive { opacity: 0.55; }
.chip-active {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Toggle de subgrupos da DRE ──────────────────────────────────── */
.dre-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--azul-profundo);
  background: var(--cinza-claro);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
}
.dre-toggle:hover { background: var(--azul-profundo); color: #fff; border-color: var(--azul-profundo); }

/* ── Abas dos relatórios ─────────────────────────────────────────── */
.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 20px;
}
.rtab {
  background: var(--branco);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.rtab:hover { color: var(--azul); border-color: var(--azul-claro); }
.rtab.active { background: var(--azul); border-color: var(--azul); color: #fff; }
[data-tab][hidden] { display: none !important; }

/* ── Simulador (sliders) ─────────────────────────────────────────── */
.sim-sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.sim-slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.sim-slider strong { color: var(--azul); }
.sim-slider input[type="range"] { width: 100%; accent-color: var(--azul); }

/* ── Responsivo / overflow (mobile) ───────────────────────────────── */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, canvas { max-width: 100%; height: auto; }
.canvas, .chart-panel canvas { height: auto; }

/* Tabelas largas rolam DENTRO de um container (não estouram a tela) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .data-table { min-width: 560px; }

/* Espaçamentos da tela de Cadastros */
.settings-grid { gap: 18px; }
.field-grid { gap: 14px 18px; margin-bottom: 18px; }
.settings-grid .panel h2 { margin-bottom: 14px; }
.report-section .help-text { margin-bottom: 16px; }

@media (max-width: 860px) {
  .page { padding: 20px 14px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 14px; padding: 20px 16px; }
  h1 { font-size: 26px; }
  h2 { font-size: 18px; }
  .topbar { min-height: 60px; padding-right: 12px; }
  .topbar::before { width: 70%; }
  .brand { padding: 0 14px; gap: 10px; }
  .brand-text strong { font-size: 16px; }
  nav { gap: 10px; font-size: 11px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 20px; }
  .r2, .r3, .r5 { grid-template-columns: 1fr; }
  .report-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rtab { white-space: nowrap; }
  .filter-row, .sim-sliders { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
}

@media (max-width: 460px) {
  .kpi-strip { grid-template-columns: 1fr; }
}

/* ── Fix overflow das listas de barras (nomes longos truncam) ─────── */
.bar-item { min-width: 0; }
.bar-meta { min-width: 0; }
.bar-meta .bar-label { flex: 1 1 auto; min-width: 0; }
.bar-track { max-width: 100%; }

/* ── Saúde dos Dados (insights de cadastro) ──────────────────────── */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.health-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--laranja);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: block;
}
.health-card.health-link { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.health-card.health-link:hover { border-color: var(--azul); transform: translateY(-2px); }
.health-count { font-size: 26px; font-weight: 900; color: var(--azul-profundo); line-height: 1; }
.health-count.negative { color: var(--rosa); }
.health-label { font-size: 13px; font-weight: 700; color: var(--ink); margin-top: 6px; }
.health-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Menu hambúrguer (mobile) ────────────────────────────────────── */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--azul-profundo);
  font-size: 20px;
  line-height: 1;
  padding: 6px 12px;
  cursor: pointer;
}
@media (max-width: 860px) {
  .topbar { position: relative; }
  .nav-toggle { display: inline-flex; align-items: center; margin-left: auto; margin-right: 12px; }
  nav {
    display: none;
    position: absolute;
    top: 100%;
    right: 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 16px 20px;
    z-index: 40;
    min-width: 200px;
    text-transform: none;
  }
  body.nav-open nav { display: flex; }
}

/* ── Páginas de edição / conexão de ERP ──────────────────────────── */
.form-page { max-width: 560px; }
.erp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}
.erp-card { display: flex; flex-direction: column; gap: 10px; }
.erp-card h2 { margin: 0; }
.erp-card .button { margin-top: auto; }
input.invalid { border-color: var(--rosa); outline-color: rgba(226,61,77,.25); }
