:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --border: #e3e5df;
  --text: #1b1d1a;
  --text-muted: #64695f;
  /* Azul extraído diretamente da marca YiQ (logo_topo.png), para o site usar
     exatamente a mesma cor de identidade visual em botões, ícones e realces. */
  --primary: #2c5f8a;
  --primary-rgb: 44, 95, 138;
  --primary-dark: #1b3f5c;
  --primary-light: #6b98c4;
  --ink: #001f50;
  --ink-soft: #0f3a63;
  /* Laranja extraído diretamente da pena/asa da marca YiQ, usado como cor de
     destaque (atualmente só na barra de rolagem). */
  --accent-orange: #ca5e26;
  --accent-orange-dark: #a24b1e;
  --silver: #d7d7d7;
  --danger: #b3423a;
  --draft: #9a7b1f;
  --draft-bg: #fbf1d8;
  --published-bg: #e9f2dc;
  --published: #547814;
}

* { box-sizing: border-box; }

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

/* Cursor de digitação (caret) e seleção de texto na cor da marca YiQ. */
input, textarea, select {
  caret-color: var(--primary);
}

::selection {
  background: var(--primary);
  color: #ffffff;
}

/* Barra de rolagem sempre visível (em vez da barra fina que alguns
   navegadores só mostram enquanto a pessoa está rolando) — para deixar
   claro que dá para arrastar o cursor da barra para cima e para baixo em
   telas com mais conteúdo do que cabe na tela, como a lista de Módulos. */
html {
  scrollbar-width: auto;
  scrollbar-color: var(--accent-orange) var(--bg);
}

::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background-color: var(--accent-orange);
  border-radius: 10px;
  border: 3px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-orange-dark);
}

.topbar {
  /* Degradê da identidade YiQ: azul escuro do lado da logo, clareando em
     direção ao lado onde ficam os seletores de Empresa e Administrador. */
  background: linear-gradient(90deg, var(--ink) 0%, var(--primary) 100%);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 3px solid var(--primary-dark);
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}

.brand-logo {
  height: 48px;
  width: auto;
  display: block;
}

.container {
  /* Usa a maior parte da largura da tela (até um teto razoável), em vez de
     um valor fixo pequeno que deixa muito espaço vazio nas laterais em
     monitores largos. Em telas estreitas o 95vw acompanha a largura do
     celular normalmente, e o @media (max-width: 640px) abaixo ajusta o padding. */
  max-width: min(1320px, 95vw);
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 4px 0 0;
  font-size: 22px;
  color: var(--ink);
}

.back-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 4px;
}

.back-link:hover {
  color: var(--primary-dark);
}

.module-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.module-nav .btn {
  font-size: 13px;
  padding: 6px 12px;
}

.category-description {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-danger {
  color: var(--danger);
}

/* ---------- Tela inicial: hero com a identidade visual do YiQ ---------- */

.home-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-soft) 55%, var(--ink) 100%);
  border-radius: 18px;
  padding: 52px 24px 44px;
  margin-bottom: 28px;
  text-align: center;
}

.home-hero-glow {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 12% 18%, rgba(var(--primary-rgb), 0.30), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(var(--primary-rgb), 0.20), transparent 46%);
}

.home-hero-shape {
  position: absolute;
  z-index: -1;
  width: 240px;
  height: 240px;
  background: var(--primary);
  opacity: 0.08;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.home-hero-shape-a { top: -70px; left: -70px; transform: rotate(12deg); }
.home-hero-shape-b { bottom: -100px; right: -50px; width: 280px; height: 280px; transform: rotate(-20deg); }

.home-hero-logo {
  height: 44px;
  width: auto;
  margin-bottom: 20px;
}

.home-hero-tagline {
  color: #ffffff;
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.2px;
}

.home-hero-sub {
  color: var(--silver);
  opacity: 0.85;
  font-size: 14px;
  margin: 0;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

/* Variante usada na tela do eSocial: os cards ficam um embaixo do outro,
   ocupando a largura toda, em vez de lado a lado. */
.module-grid-vertical {
  grid-template-columns: 1fr;
}

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}

.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  opacity: 0;
  transition: opacity 0.18s ease;
}

.module-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(13, 13, 13, 0.10);
  transform: translateY(-3px);
}

.module-card:hover::before {
  opacity: 1;
}

.module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--primary);
}

.module-icon svg {
  width: 26px;
  height: 26px;
}

.module-name {
  font-size: 17px;
  font-weight: 700;
}

.module-description {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.module-count {
  margin-top: 4px;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--published-bg);
  border-radius: 999px;
  padding: 3px 10px;
}

.module-card-disabled {
  cursor: default;
  opacity: 0.65;
}

.module-card-disabled:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

.module-card-disabled:hover::before {
  opacity: 0;
}

.module-count-em-breve {
  color: var(--text-muted);
  background: var(--bg);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.category-card:hover {
  border-color: var(--primary);
}

.category-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.18);
  background: var(--published-bg);
}

.category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--primary-dark);
}

.category-icon svg {
  width: 22px;
  height: 22px;
}

.category-icon-all {
  color: var(--text-muted);
}

.category-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.category-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 9px;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filters input, .filters select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.group-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  margin: 28px 0 10px;
  color: var(--text);
}

.group-heading:first-of-type {
  margin-top: 4px;
}

.group-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--primary-dark);
}

.group-icon svg {
  width: 18px;
  height: 18px;
}

.pop-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.pop-table th, .pop-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.pop-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pop-table tr:hover {
  background: #fafbfc;
  cursor: pointer;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag-area {
  background: #eef1f6;
  color: #445;
}

.tag-codigo {
  background: var(--ink);
  color: #fff;
  font-family: "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.02em;
}

.rodape-assinaturas {
  display: flex;
  gap: 40px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.rodape-assinaturas div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.tag-published {
  background: var(--published-bg);
  color: var(--published);
}

.tag-draft {
  background: var(--draft-bg);
  color: var(--draft);
}

.meta-bar {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.flow-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px 26px;
  margin-bottom: 20px;
}

.flow-block h2 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--primary-dark);
}

.risk-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px 24px;
  margin-bottom: 20px;
}

.risk-block h2 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--primary-dark);
}

.risk-table {
  width: 100%;
  border-collapse: collapse;
}

.risk-table th, .risk-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

.risk-table th {
  background: #fafbfc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.risco-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.risco-baixo {
  background: #e9f2dc;
  color: #547814;
}

.risco-medio {
  background: #fbf1d8;
  color: #9a7b1f;
}

.risco-alto {
  background: #fbe4d5;
  color: #b0561f;
}

.risco-critico {
  background: #f8dcda;
  color: #a3352c;
}

.alert-erro {
  background: #f8dcda;
  border: 1px solid #e3aca6;
  color: #8a2c24;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.risk-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}

.risk-section-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.risk-section-header h2 {
  font-size: 16px;
  margin: 0;
}

.radio-group {
  display: flex;
  gap: 16px;
  align-items: center;
  height: 38px;
}

.radio-inline,
.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  cursor: pointer;
}

.radio-inline input,
.checkbox-inline input {
  width: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 20px;
  margin-bottom: 8px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-item span:first-child {
  font-size: 12px;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.detail-item span:last-child {
  font-size: 14px;
}

.required-mark {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

.risk-form-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.risk-form-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 4px 6px;
}

.risk-form-table td {
  padding: 4px 6px;
  vertical-align: top;
}

.risk-form-table input, .risk-form-table select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.btn-remove-risco {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
}

.flow-block-canvas {
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.flowchart-svg {
  max-width: 100%;
  height: auto;
}

.fc-box {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 1.5;
}

.fc-box-terminal {
  fill: #fbf1ee;
  stroke: var(--danger);
  stroke-dasharray: 4 3;
}

.fc-decision {
  fill: #eef2e3;
  stroke: var(--primary-dark);
  stroke-width: 1.5;
}

.fc-label {
  font-size: 13px;
  fill: var(--text);
  text-anchor: middle;
  font-family: inherit;
}

.fc-label-sm {
  font-size: 12px;
  font-weight: 600;
}

.fc-oval {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 2;
}

.fc-box-alt {
  stroke-dasharray: 5 4;
}

.fc-predefined-bar {
  stroke: var(--primary-dark);
  stroke-width: 1.5;
}

.fc-manual {
  fill: #eef2e3;
  stroke: var(--primary-dark);
  stroke-width: 1.5;
}

.fc-document {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 1.5;
}

.fc-connector {
  fill: #eef2e3;
  stroke: var(--primary-dark);
  stroke-width: 1.5;
}

.fc-wait {
  fill: #fbf1d8;
  stroke: var(--draft);
  stroke-width: 1.5;
}

.fc-arrow {
  stroke: var(--primary-dark);
  stroke-width: 1.5;
}

.fc-arrowhead {
  fill: var(--primary-dark);
}

.fc-edge-label-bg {
  fill: var(--bg);
}

.fc-edge-label {
  font-size: 11px;
  fill: var(--text-muted);
  text-anchor: middle;
  font-family: inherit;
}

.pop-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  line-height: 1.65;
  font-size: 15px;
}

.pop-content h2 {
  margin-top: 1.7em;
  margin-bottom: 0.6em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.pop-content h2:first-child {
  margin-top: 0;
}

.pop-content h4 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: var(--primary-dark);
}

.pop-content p {
  margin: 0 0 14px;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.pop-content ul, .pop-content ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.pop-content li {
  margin-bottom: 5px;
  text-align: justify;
  text-justify: inter-word;
}

.pop-content li > p {
  margin: 0;
}

.pop-content strong {
  color: var(--text);
}

.pop-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 4px 0 18px;
}

.pop-content th, .pop-content td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 14px;
  text-align: left;
}

.pop-content th {
  background: #fafbfc;
}

.pop-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.pop-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.pop-form input, .pop-form select, .pop-form textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.pop-form input:focus, .pop-form select:focus, .pop-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.pop-form textarea {
  font-family: "SFMono-Regular", Consolas, monospace;
  resize: vertical;
}

.hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.hint code {
  background: #f1f2ee;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 12px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row label {
  flex: 1;
}

.empty {
  color: var(--text-muted);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Layout para celular ---------- */
@media (max-width: 640px) {
  .container {
    padding: 16px 12px 40px;
  }

  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand-logo {
    height: 34px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .page-header h1 {
    font-size: 19px;
  }

  .actions {
    flex-wrap: wrap;
  }

  .actions .btn, .actions form {
    flex: 1 1 auto;
  }

  .actions .btn {
    text-align: center;
  }

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

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

  .home-hero {
    padding: 38px 18px 32px;
    border-radius: 14px;
  }

  .home-hero-logo {
    height: 34px;
  }

  .home-hero-tagline {
    font-size: 17px;
  }

  /* Painel "trocar empresa" mais estreito que a tela em celulares pequenos:
     sem isso, os 270px fixos podem passar da borda da tela em aparelhos
     bem estreitos (< 360px de largura). */
  .empresa-switcher-panel {
    width: min(270px, calc(100vw - 32px));
    right: -8px;
  }

  .filters {
    flex-direction: column;
  }

  .filters input, .filters select, .filters button {
    width: 100%;
  }

  .meta-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .form-row {
    flex-direction: column;
    gap: 16px;
  }

  .pop-form {
    padding: 16px;
  }

  .pop-content {
    padding: 18px 16px;
  }

  .flow-block, .risk-block {
    padding: 16px;
  }

  /* Tabelas (inclusive as geradas a partir do Markdown, como a Matriz RACI)
     viram uma faixa com rolagem horizontal em vez de espremer o texto. */
  .pop-content table,
  .risk-table,
  .risk-form-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Lista de POPs: em vez de rolar para o lado, mostra só o essencial. */
  .pop-table th:nth-child(3), .pop-table td:nth-child(3),
  .pop-table th:nth-child(4), .pop-table td:nth-child(4),
  .pop-table th:nth-child(6), .pop-table td:nth-child(6) {
    display: none;
  }

  .rodape-assinaturas {
    flex-direction: column;
    gap: 16px;
  }

  .risk-section-header {
    gap: 6px;
  }
}

.print-header {
  display: none;
}

/* ---------- PGR — Programa de Gerenciamento de Riscos ---------- */

.ghe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.ghe-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ghe-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(13, 13, 13, 0.06);
}

.ghe-card-nome {
  font-size: 16px;
  font-weight: 700;
}

.ghe-card-descricao {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.ghe-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Faixas de nível de risco do PGR (matriz 5x5: probabilidade x severidade).
   Cores em degradê do verde (trivial) ao vermelho (intolerável), distintas
   entre si para evitar rótulos repetidos/ambíguos na matriz. */
.risco-pgr-trivial {
  background: #e9f2dc;
  color: #547814;
}

.risco-pgr-toleravel {
  background: #eef2c3;
  color: #7a7a14;
}

.risco-pgr-moderado {
  background: #fbf1d8;
  color: #9a7b1f;
}

.risco-pgr-substancial {
  background: #fbe4d5;
  color: #b0561f;
}

.risco-pgr-intoleravel {
  background: #f8dcda;
  color: #a3352c;
}

.matriz-pgr-wrap {
  overflow-x: auto;
}

.matriz-pgr {
  border-collapse: collapse;
  margin: 0 auto;
}

.matriz-pgr th, .matriz-pgr td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
  font-size: 13px;
}

.matriz-pgr th {
  background: #fafbfc;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.matriz-pgr td.matriz-celula {
  font-weight: 700;
  min-width: 64px;
}

.matriz-pgr .matriz-eixo-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #fafbfc;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 14px;
  margin: 6px 0 0;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
}

.checklist-item input {
  margin-top: 3px;
}

.plano-acao-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.plano-acao-frente {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.plano-acao-frente label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill-vazio {
  background: var(--bg);
  color: var(--text-muted);
}

.status-pill-a-fazer {
  background: #fbe4d5;
  color: #b0561f;
}

.status-pill-fazendo {
  background: #fbf1d8;
  color: #9a7b1f;
}

.status-pill-feito {
  background: #e9f2dc;
  color: #547814;
}

.ghe-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px 24px;
  margin-bottom: 20px;
}

.ghe-section h2 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--primary-dark);
}

.risco-pgr-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: var(--surface);
}

.risco-pgr-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.risco-pgr-card-titulo {
  font-size: 15px;
  font-weight: 700;
}

.risco-pgr-card-categoria {
  font-size: 12px;
  color: var(--text-muted);
}

.campo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 20px;
  margin-top: 10px;
  font-size: 13px;
}

.campo-grid dt {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  margin-top: 8px;
}

.campo-grid dd {
  margin: 2px 0 0;
  text-align: justify;
  text-justify: inter-word;
}

@media (max-width: 640px) {
  .ghe-grid {
    grid-template-columns: 1fr;
  }

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

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

@media print {
  .ghe-section,
  .risco-pgr-card {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .status-pill,
  .risco-badge,
  td.matriz-celula {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  .ghe-print-block {
    page-break-before: always;
  }

  .ghe-print-block:first-child {
    page-break-before: avoid;
  }
}

/* ---------- Impressão ---------- */
@media print {
  @page {
    size: A4;
    margin: 1.6cm;
  }

  body {
    background: #fff;
  }

  .topbar,
  .no-print,
  .filters,
  .module-nav {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .print-header {
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 12px;
    margin-bottom: 14px;
  }

  .print-logo {
    height: 40px;
    width: auto;
  }

  .print-header-info h1 {
    margin: 0 0 4px;
    font-size: 18px;
  }

  .print-header-info span {
    font-size: 12px;
    color: var(--text-muted);
  }

  .meta-bar,
  .flow-block,
  .risk-block,
  .pop-content {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .flow-block,
  .risk-block,
  .pop-content {
    padding: 14px 16px;
    margin-bottom: 14px;
  }

  .risk-table tr,
  .pop-table tr {
    page-break-inside: avoid;
  }

  .flow-block-canvas {
    overflow: visible;
  }

  .flowchart-svg {
    max-width: 100%;
  }

  .tag,
  .risco-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  a[href]::after {
    content: "";
  }
}

/* ---------- Combate a Incêndio — Extintores e Hidrantes ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
}

.stat-tile-rotulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.stat-tile-valor {
  font-size: 28px;
  font-weight: 700;
}

.stat-tile-total { border-left-color: var(--ink); }
.stat-tile-vencido { border-left-color: var(--danger); }
.stat-tile-vencido .stat-tile-valor { color: var(--danger); }
.stat-tile-a-vencer { border-left-color: var(--draft); }
.stat-tile-a-vencer .stat-tile-valor { color: var(--draft); }
.stat-tile-no-prazo { border-left-color: var(--published); }
.stat-tile-no-prazo .stat-tile-valor { color: var(--published); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px 18px;
}

.chart-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--primary-dark);
}

.chart-panel-wide {
  grid-column: 1 / -1;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.chart-donut {
  max-width: 180px;
  flex-shrink: 0;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.chart-legend-dot-vencido { background: var(--danger); }
.chart-legend-dot-a-vencer { background: var(--draft); }
.chart-legend-dot-no-prazo { background: var(--published); }

.chart-bar-primary { fill: var(--primary); }
.chart-axis-line { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 11px; fill: var(--text-muted); font-family: inherit; }
.chart-value-label { font-size: 12px; font-weight: 700; fill: var(--text); font-family: inherit; }

.chart-donut-vencido { fill: var(--danger); }
.chart-donut-a-vencer { fill: var(--draft); }
.chart-donut-no-prazo { fill: var(--published); }
.chart-donut-vazio { stroke: var(--border); }
.chart-donut-valor { font-size: 22px; font-weight: 700; fill: var(--text); font-family: inherit; }
.chart-donut-titulo { font-size: 10px; fill: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; font-family: inherit; }

.status-venc-vencido {
  background: #f8dcda;
  color: #a3352c;
}

.status-venc-a-vencer {
  background: #fbf1d8;
  color: #9a7b1f;
}

.status-venc-no-prazo {
  background: #e9f2dc;
  color: #547814;
}

.status-venc-sem-data {
  background: var(--bg);
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .chart-donut-wrap {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media print {
  .stat-tile,
  .chart-panel {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .stat-tile-vencido,
  .stat-tile-a-vencer,
  .stat-tile-no-prazo,
  .status-pill,
  .risco-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  .chart-donut-vencido,
  .chart-donut-a-vencer,
  .chart-donut-no-prazo,
  .chart-bar-primary {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }
}

/* ---------- Topbar: seletor de empresa/cliente + ícones de topo ---------- */

.topbar-spacer {
  flex: 1;
}

.empresa-switcher,
.usuario-atual {
  position: relative;
}

.empresa-switcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 7px 12px;
  color: #ffffff;
  cursor: pointer;
  font-family: inherit;
}

.empresa-switcher-btn:hover {
  border-color: var(--primary);
}

.empresa-switcher-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.empresa-switcher-eyebrow {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--silver);
  opacity: 0.7;
}

.empresa-switcher-nome {
  font-size: 13px;
  font-weight: 700;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empresa-switcher-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.8;
}

.empresa-switcher-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 270px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  padding: 10px;
  z-index: 50;
}

.empresa-switcher-renomear {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.empresa-switcher-renomear input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}

.empresa-switcher-renomear .btn {
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1;
}

.empresa-switcher-search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.empresa-switcher-lista {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.empresa-switcher-lista li form {
  margin: 0;
}

.empresa-switcher-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
}

.empresa-switcher-item:hover {
  background: var(--bg);
}

.empresa-switcher-item.is-atual {
  color: var(--primary-dark);
  font-weight: 700;
  background: var(--published-bg);
}

.empresa-switcher-nova {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.empresa-switcher-nova input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}

.empresa-switcher-nova .btn {
  padding: 7px 10px;
  font-size: 12.5px;
  white-space: nowrap;
  flex: 1;
  text-align: center;
}

.topbar-icons {
  display: flex;
  gap: 6px;
}

.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  cursor: default;
}

.topbar-icon-btn svg {
  width: 17px;
  height: 17px;
}

@media (max-width: 720px) {
  .empresa-switcher-nome { max-width: 110px; }
}

/* ---------- Tela inicial: painel (sidebar de módulos + dashboard) ---------- */

body.home-page .container {
  /* A tela inicial (sidebar de módulos + dashboard) se beneficia ainda mais
     de espaço extra, pois os cards/widgets usam grids que se reorganizam
     sozinhos (auto-fit) para preencher a largura disponível. */
  max-width: min(1680px, 96vw);
}

.dash-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.dash-sidebar-title {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--primary-dark);
  font-weight: 800;
  margin: 4px 0 12px 4px;
}

.dash-module-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Lista de Módulos com rolagem própria: assim dá pra descer pelos
     módulos sem empurrar o "Status" e a "Agenda" (que ficam ao lado, no
     desktop, ou logo abaixo, no celular) para fora da tela. A altura usa
     o espaço disponível até o fim da tela (100vh menos o cabeçalho, o
     título "Módulos" e uma margem), em vez de um valor fixo pequeno —
     para a barra de rolagem aproveitar o máximo de espaço possível.
     min-height evita que fique pequena demais em janelas bem baixas. */
  height: calc(100vh - 150px);
  min-height: 280px;
  overflow-y: auto;
  padding-right: 6px;
}

.dash-module-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ink);
  border-radius: 12px;
  text-decoration: none;
  color: #ffffff;
  border: 1px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.dash-module-item:hover {
  border-color: var(--primary);
  transform: translateX(2px);
  background: var(--ink-soft);
}

.dash-module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(var(--primary-rgb), 0.18);
  color: var(--primary);
  flex-shrink: 0;
}

.dash-module-icon svg {
  width: 19px;
  height: 19px;
}

.dash-module-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.dash-module-name {
  font-size: 14px;
  font-weight: 700;
}

.dash-module-desc {
  font-size: 11.5px;
  color: var(--silver);
  opacity: 0.8;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-module-chevron {
  flex-shrink: 0;
  opacity: 0.6;
}

.dash-welcome h1 {
  margin: 4px 0 4px;
  font-size: 21px;
  color: var(--ink);
}

.dash-welcome .dash-sub {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.dash-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.dash-widget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 16px;
}

.dash-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.dash-widget-header h3 {
  margin: 0;
  font-size: 14.5px;
}

.dash-widget-header a {
  font-size: 12.5px;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.dash-widget-header a:hover {
  text-decoration: underline;
}

.dash-widget-body {
  display: flex;
  gap: 10px;
}

.dash-widget-stat {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  border-radius: 10px;
}

.dash-widget-stat .n {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.dash-widget-stat .l {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-widget-stat.vencido { background: var(--draft-bg); }
.dash-widget-stat.vencido .n { color: var(--danger); }
.dash-widget-stat.a-vencer { background: #fbf1d8; }
.dash-widget-stat.a-vencer .n { color: var(--draft); }
.dash-widget-stat.no-prazo { background: var(--published-bg); }
.dash-widget-stat.no-prazo .n { color: var(--published); }

.dash-events-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 6px;
}

.dash-events-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.dash-events-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.dash-events-list li:last-child {
  border-bottom: none;
}

.dash-event-title {
  font-weight: 700;
  font-size: 13.5px;
  flex: 1;
  min-width: 120px;
}

.dash-event-datas {
  font-size: 12.5px;
  color: var(--text-muted);
}

.dash-events-empty {
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 16px 0;
}

.dash-events-empty a {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 860px) {
  .dash-grid { grid-template-columns: 1fr; }

  /* No celular/tablet o dash-grid vira 1 coluna só, e a sidebar (com a
     lista de Módulos) passa a ficar ACIMA do dashboard (Status/Agenda) no
     HTML. Sem este ajuste, a lista de Módulos ocupava quase a tela toda
     (calc(100vh - 150px), pensado para ficar ao LADO do dashboard no
     desktop) e criava uma rolagem "presa" antes da pessoa conseguir ver o
     resto da tela inicial. Aqui ela vira uma altura limitada e razoável,
     com rolagem própria só dentro da lista quando necessário. */
  .dash-module-list {
    height: auto;
    max-height: 46vh;
    min-height: 0;
  }
}

/* ---------- Agenda: status dos compromissos ---------- */

.evento-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.evento-status-agendado { background: #e5eefb; color: #2a5ba0; }
.evento-status-em-andamento { background: var(--draft-bg); color: var(--draft); }
.evento-status-concluido { background: var(--published-bg); color: var(--published); }
.evento-status-cancelado { background: #f1e3e1; color: var(--danger); }

@media print {
  .empresa-switcher,
  .topbar-icons,
  .dash-sidebar {
    display: none !important;
  }
}
