:root {
  /* Paleta principal */
  --green: #107c41;
  --green-dark: #0b5f32;
  --green-soft: #edf7f1;
  --mint: #e8f5ee;
  --amber: #c77700;
  --red: #b42318;
  --white: #ffffff;
  /* Texto */
  --text: #1f2933;
  --ink: #1f2933;
  --muted: #5f6b7a;
  /* Backgrounds */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --surface-panel: #ffffff;
  /* Bordas */
  --line: #d9e2ec;
  --border-ui: #dbe3ec;
  --border-control: #cfd8e3;
  --border-muted: #e2e8f0;
  /* Tabelas */
  --row-border: #e5eaf0;
  --row-hover: #f5f9fc;
  /* Menu */
  --nav-active-bg: #eef7f2;
  --nav-hover-bg: #f3f6f9;
  /* Alertas */
  --attention-bg: #fff7ed;
  --attention-border: #fed7aa;
  --danger-soft: #fff1f2;
  --danger-border: #fecdd3;
  /* Interação */
  --focus: rgba(16, 124, 65, 0.14);
  --shadow-sm: 0 1px 2px rgba(31, 41, 51, 0.06);
  --shadow-md: 0 12px 28px rgba(31, 41, 51, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f7fbf9 0%, var(--bg) 220px);
  font-family: Arial, Helvetica, sans-serif;
  display: grid;
  grid-template-columns: 280px 1fr;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: var(--green);
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

button:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

button.secondary {
  background: white;
  color: var(--green-dark);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.danger {
  background: #fee4e2;
  color: var(--red);
  border: 1px solid #fecdca;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.login-screen {
  background:
    linear-gradient(135deg, rgba(0, 140, 80, 0.12), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, #f8fcfa 0%, var(--bg) 100%);
  display: grid;
  inset: 0;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  position: fixed;
  z-index: 100;
}

.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 14px;
  max-width: 440px;
  padding: 28px;
  width: 100%;
}

.login-card h1 {
  font-size: 28px;
}

.login-card small {
  color: var(--muted);
  text-align: center;
}

.login-brand {
  border-bottom: 1px solid var(--line);
  padding: 0 0 16px;
}

.login-heading {
  display: grid;
  gap: 4px;
}

.login-heading span {
  color: var(--muted);
}

.login-card #loginButton {
  margin-top: 4px;
  min-height: 44px;
}

.user-badge {
  background: var(--mint);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
}

.sidebar {
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  box-shadow: 8px 0 24px rgba(29, 43, 38, 0.04);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 24px;
}

.brand span,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 0;
}

nav {
  display: grid;
  gap: 2px;
}

.menu-group {
  display: grid;
  gap: 2px;
  margin: 10px 0 4px;
}

.menu-group:first-child {
  margin-top: 0;
}

.menu-group-title {
  align-items: center;
  background: transparent;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  padding: 7px 14px 3px;
  width: 100%;
}

.menu-group-title:hover {
  background: transparent;
  color: var(--green-dark);
}

.menu-group-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Chevron via CSS — substitui o <strong>+/-</strong> gerado pelo JS */
.menu-group-title::after {
  content: "▾";
  color: var(--muted);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.menu-group-title[aria-expanded="false"]::after {
  content: "▸";
}

.menu-group-items {
  display: grid;
  gap: 2px;
}

nav button {
  width: 100%;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border-radius: 8px;
  font-weight: 600;
  padding: 9px 14px;
  box-shadow: none;
}

nav button.active,
nav button:hover {
  background: var(--mint);
  color: var(--green-dark);
}

.app-shell {
  padding: 26px 28px;
  min-width: 0;
}

.topbar {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar,
.section-head,
.filters,
.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.section-head {
  justify-content: space-between;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: white;
  color: var(--green-dark);
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(29, 43, 38, 0.15);
}

.toast.error {
  border-left-color: var(--red);
  color: var(--red);
}

.section-head {
  margin-top: 6px;
}

.section-head h2 {
  font-size: 22px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 19px;
}

.filters {
  margin: 20px 0;
}

.filters input {
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  box-shadow: inset 0 1px 1px rgba(29, 43, 38, 0.03);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 140, 80, 0.12);
  outline: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.dashboard-groups {
  display: grid;
  gap: 18px;
}

.attention-panel {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.attention-panel h2 {
  font-size: 20px;
  margin: 2px 0 0;
}

.attention-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.attention-item {
  background: #fff7f7;
  border: 1px solid #fecdca;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  padding: 9px 10px;
}

.attention-item.warn {
  background: #fffaf0;
  border-color: #f6d59a;
}

.attention-item span {
  color: var(--muted);
}

.attention-item strong {
  color: var(--red);
}

.attention-item.warn strong {
  color: var(--amber);
}

.attention-ok {
  background: var(--green-soft);
  border-radius: 8px;
  color: var(--green-dark);
  padding: 10px 12px;
}

.dashboard-group {
  min-width: 0;
}

.dashboard-group h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
}

.dashboard-group .cards {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.card,
.split section,
.answer,
dialog {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.card {
  padding: 18px;
}

.card span {
  color: var(--muted);
  font-size: 13px;
}

.card strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.orientation-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.orientation-box p {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
}

.orientation-box strong,
.orientation-box span {
  display: block;
}

.orientation-box strong {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.card.clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.card.clickable:hover,
.card.clickable:focus {
  border-color: var(--green);
  box-shadow: 0 4px 12px rgba(29, 43, 38, 0.08);
  outline: none;
  transform: translateY(-1px);
}

.card.warn {
  border-color: #f6d59a;
  background: #fffaf0;
}

.card.warn strong {
  color: var(--amber);
}

.card.danger {
  border-color: #fecdca;
  background: #fff7f7;
}

.card.danger strong {
  color: var(--red);
}

.card.muted-card {
  background: #fbfdfc;
  border-color: #e3ebe7;
  box-shadow: none;
}

.card.muted-card span,
.card.muted-card strong {
  color: #7a8983;
}

.card.muted-card strong {
  font-size: 26px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.split section {
  padding: 16px;
}

.bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

.bar-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

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

.bar-fill {
  height: 100%;
  background: var(--green);
}

.table-wrap {
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
}

.table-wrap:has(.action-menu[open]) {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fbfa;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f9fcfa;
}

tr.equipment-group-start td {
  border-top: 3px solid var(--green);
  background: #f8fcfa;
}

tr.missing-action-plan td {
  background: #fffaf0;
}

tr.missing-action-plan td:first-child {
  border-left: 4px solid var(--amber);
}

.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.status.warn {
  background: #fff5df;
  color: var(--amber);
}

.status.danger {
  background: #fee4e2;
  color: var(--red);
}

.status.success {
  background: var(--green-soft);
  color: var(--green-dark);
}

.evidence-group {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

button.small {
  padding: 7px 10px;
  font-size: 12px;
}

.row-actions,
.linked-evidence-actions,
.attachment-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions {
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  position: relative;
  white-space: nowrap;
}

.action-menu {
  position: relative;
}

.action-menu summary {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--green-dark);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  line-height: 1;
  list-style: none;
  min-width: 64px;
  padding: 0 10px;
}

.row-primary-action {
  min-width: 86px;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu[open] summary {
  background: var(--mint);
  border-color: #bddfcc;
}

.action-menu-list {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 4px;
  min-width: 168px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: 38px;
  z-index: 20;
}

.action-menu-list button {
  box-shadow: none;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
}

.records-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.daily-progress {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 10px;
  padding: 11px 13px;
  box-shadow: var(--shadow-sm);
}

.daily-progress span {
  color: var(--muted);
  font-weight: 700;
}

.table-empty {
  padding: 16px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pagination div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.assistant-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin: 14px 0;
}

.search-examples {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.search-examples span {
  margin-right: 2px;
}

.answer {
  padding: 16px;
  min-height: 120px;
}

.search-section-row td {
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
}

.search-result-cards {
  display: grid;
  gap: 10px;
}

.search-result-card {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  padding: 14px 16px;
}

.search-result-card h3 {
  font-size: 17px;
  margin: 4px 0;
}

.search-result-card p {
  color: var(--muted);
  margin: 0 0 8px;
}

.search-result-module {
  background: var(--green-soft);
  border: 1px solid #c8eadd;
  border-radius: 999px;
  color: var(--green-dark);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
  padding: 4px 8px;
}

.search-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-result-meta span,
.search-section-card {
  background: var(--mint);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 12px;
  padding: 5px 8px;
}

.search-section-card {
  border-radius: 8px;
  font-weight: 800;
}

.search-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.bulk-equipment-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 14px 0 8px;
}

.bulk-equipment-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0;
  max-height: 280px;
  overflow: auto;
}

.bulk-equipment-option {
  align-items: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
}

.bulk-equipment-option:last-child {
  border-bottom: 0;
}

.bulk-equipment-option small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

dialog {
  width: min(840px, calc(100vw - 24px));
  padding: 20px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.25);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.form-section-title {
  border-bottom: 1px solid var(--border-ui, var(--line));
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
  grid-column: 1 / -1;
  letter-spacing: 0.04em;
  margin: 16px 0 0;
  padding: 8px 0 6px;
  text-transform: uppercase;
}

/* Primeira seção do formulário não precisa de margem extra no topo */
.form-grid > .form-section-title:first-child {
  margin-top: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label.required-field {
  color: var(--ink);
  font-weight: 700;
}

/* Asterisco vermelho inline após o texto do label (via .label-name injetado pelo JS) */
label.required-field .label-name::after {
  content: " *";
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

label.required-field input,
label.required-field select,
label.required-field textarea {
  border-color: #a9cdb8;
  box-shadow: inset 3px 0 0 rgba(16, 124, 65, 0.45);
}

label.required-field input:invalid,
label.required-field select:invalid,
label.required-field textarea:invalid {
  border-color: #f2a9a9;
  box-shadow: inset 3px 0 0 rgba(180, 35, 24, 0.45);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.checkbox-field input {
  width: auto;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
}

.dropzone {
  border: 1px dashed var(--green);
  padding: 18px;
  border-radius: 8px;
  grid-column: 1 / -1;
}

.upload-record-picker {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.upload-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.upload-picker-head span {
  color: var(--green-dark);
  font-weight: 700;
}

.upload-record-results {
  display: grid;
  gap: 8px;
  max-height: 250px;
  overflow: auto;
}

.upload-record-option {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.upload-record-option:hover {
  background: var(--mint);
  color: var(--green-dark);
}

.upload-record-option small {
  color: var(--muted);
  font-weight: 400;
}

.inline-form,
.link-evidence-form,
.status-editor,
.norm-detail-head,
.norm-badges,
.linked-evidence {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-form {
  flex: 1;
  justify-content: flex-end;
}

.inline-form input[type="file"] {
  max-width: 260px;
}

.compact-cards {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  margin-bottom: 14px;
}

.compact-cards .card strong {
  font-size: 24px;
}

.norm-tree,
.norm-results,
.norm-detail {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}

.norm-tree,
.norm-results {
  max-height: 680px;
  overflow: auto;
}

.tree-chapter {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.tree-chapter summary {
  cursor: pointer;
  font-weight: 700;
}

.tree-chapter summary span {
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}

.tree-chapter button,
.requirement-row {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
}

.tree-chapter button {
  padding: 7px 8px;
  font-weight: 600;
}

.tree-chapter button:hover,
.requirement-row:hover {
  background: var(--mint);
}

.requirement-list {
  display: grid;
  gap: 8px;
}

.requirement-row {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  padding: 10px;
}

.requirement-row span,
.requirement-row small,
.linked-evidence span,
.linked-evidence small {
  color: var(--muted);
}

.requirement-row em {
  justify-self: start;
  font-style: normal;
}

.norm-detail h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.norm-detail p {
  line-height: 1.5;
}

.norm-detail-head {
  justify-content: space-between;
  align-items: flex-start;
}

.norm-badges {
  flex-wrap: wrap;
  margin: 10px 0;
}

.norm-badges span {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.status-editor,
.link-evidence-form {
  align-items: stretch;
}

.link-evidence-form input,
.link-evidence-form select,
.status-editor select {
  min-width: 0;
}

.linked-evidence {
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  background: #fbfdfc;
}

.attachment-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.record-attachment-panel {
  margin-top: 8px;
}

.quick-attachments {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.quick-attachments-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.quick-attachments h3 {
  margin: 0;
  font-size: 16px;
}

.quick-upload {
  cursor: pointer;
}

.quick-upload input {
  display: none;
}

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

.attachment-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.attachment-row div:first-child {
  display: grid;
  gap: 4px;
}

.attachment-row small {
  color: var(--muted);
}

.palc-evidence-body {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.palc-evidence-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.palc-evidence-summary article,
.palc-evidence-requirement,
.palc-evidence-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.palc-evidence-summary span {
  color: var(--muted);
  font-size: 12px;
}

.palc-evidence-summary strong {
  display: block;
  font-size: 24px;
  margin-top: 5px;
}

.palc-evidence-requirement h3,
.palc-evidence-group h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.palc-evidence-requirement p {
  margin: 8px 0 0;
  line-height: 1.45;
}

.linked-evidence div {
  display: grid;
  gap: 4px;
}

.linked-evidence a {
  color: var(--green-dark);
  font-weight: 700;
  text-decoration: none;
}

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

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .cards,
  .split,
  .palc-evidence-summary {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .filters,
  .section-head,
  .records-toolbar,
  .assistant-box,
  .inline-form,
  .link-evidence-form,
  .status-editor,
  .norm-detail-head,
  .linked-evidence,
  .attachment-row {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .cards,
  .split,
  .form-grid,
  .compact-cards,
  .palc-evidence-summary {
    grid-template-columns: 1fr;
  }

  nav {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}

body {
  background:
    linear-gradient(180deg, #fbfdfc 0%, #f4f8f6 260px),
    var(--bg);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
.button-link {
  border-radius: 7px;
}

button {
  box-shadow: 0 1px 2px rgba(0, 95, 67, 0.16);
}

button:hover {
  transform: translateY(-1px);
}

button.secondary,
.button-link {
  background: var(--surface);
  border-color: #cfddd6;
}

input,
select,
textarea {
  border-color: #cfddd6;
  border-radius: 7px;
  min-height: 40px;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px var(--focus);
}

.sidebar {
  background: rgba(255, 255, 255, 0.98);
  padding: 18px 14px;
}

.brand-mark {
  border-radius: 9px;
  box-shadow: 0 8px 20px rgba(0, 143, 90, 0.18);
}

.menu-group-title {
  margin-top: 4px;
}

nav button {
  border-left: 3px solid transparent;
}

nav button.active {
  background: var(--green-soft);
  border-left-color: var(--green);
}

.app-shell {
  padding: 28px 34px;
}

.topbar {
  align-items: flex-start;
}

.topbar h1 {
  line-height: 1.1;
}

.filters,
.records-toolbar,
.daily-progress,
.attention-panel,
.dashboard-group .cards,
.split section,
.table-wrap,
.answer,
dialog {
  border-color: #d5e2dc;
}

.attention-panel,
.records-toolbar,
.daily-progress,
.table-wrap,
.split section,
.answer {
  box-shadow: var(--shadow-sm);
}

.card,
.split section,
.answer,
dialog,
.table-wrap,
.records-toolbar,
.daily-progress,
.attention-panel,
.evidence-group,
.attachment-row,
.search-result-card {
  border-radius: 8px;
}

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
  min-height: 112px;
}

.card strong {
  line-height: 1;
}

.attention-item {
  align-items: center;
  min-height: 42px;
}

th {
  background: #f6faf8;
  color: #52645d;
  font-size: 11px;
}

td {
  color: #1b2a25;
}

tbody tr:hover {
  background: #f7fbf9;
}

.row-actions {
  gap: 6px;
}

.status {
  border: 1px solid transparent;
}

.status.warn {
  border-color: #f3d38e;
}

.status.danger {
  border-color: #fecaca;
}

.status.success {
  border-color: #bbebd2;
}

.toast {
  border-radius: 8px;
}

.topbar {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #dbe7e1;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  padding: 14px 16px;
}

.topbar .eyebrow {
  margin-top: 0;
}

.topbar h1 {
  font-size: 26px;
}

.top-actions {
  align-items: center;
}

.user-badge {
  border: 1px solid #c8eadd;
}

.sidebar {
  border-right-color: #d3e1da;
}

.sidebar .brand {
  background: #f8fbfa;
  border: 1px solid #dbe7e1;
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 10px;
}

.menu-group {
  margin-top: 12px;
}

.menu-group-title {
  padding: 8px 10px 5px;
}

.menu-group-title span {
  color: #5a6a63;
  font-size: 10px;
}

nav button {
  min-height: 36px;
  padding: 8px 10px;
}

nav button:hover {
  background: #f1f8f5;
}

nav button.active {
  box-shadow: inset 0 0 0 1px #c8eadd;
}

.table-wrap {
  border-radius: 8px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 10px 12px;
}

tbody tr:nth-child(even):not(.missing-action-plan):not(.equipment-group-start) td {
  background: #fcfefd;
}

th {
  border-bottom: 1px solid #cfddd6;
  letter-spacing: 0;
}

td {
  line-height: 1.25;
}

.row-actions {
  min-width: 170px;
}

button.small {
  min-height: 30px;
  padding: 6px 9px;
}

body {
  background: #f6f8fb;
  color: var(--ink);
}

.sidebar {
  background: var(--surface-panel);
  border-right: 1px solid var(--border-ui);
  box-shadow: none;
}

.sidebar .brand {
  background: var(--surface-panel);
  border-color: var(--border-muted);
  box-shadow: none;
}

.brand-mark {
  background: linear-gradient(180deg, #128c4b 0%, #0b6b3a 100%);
  border-radius: 10px;
  box-shadow: none;
}

.menu-group-title span {
  color: #697586;
  font-weight: 800;
}

nav button {
  color: #263241;
  font-size: 14px;
  font-weight: 600;
}

nav button.active {
  background: var(--nav-active-bg);
  border-left-color: var(--green);
  color: var(--green-dark);
  box-shadow: none;
}

nav button:hover {
  background: var(--nav-hover-bg);
  color: #111827;
}

.app-shell {
  padding: 22px 28px;
}

.topbar {
  background: var(--surface-panel);
  border-color: var(--border-ui);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.topbar h1 {
  color: #111827;
  font-size: 25px;
  font-weight: 800;
}

.eyebrow {
  color: #697586;
  font-size: 11px;
  font-weight: 700;
}

.filters,
.records-toolbar,
.daily-progress,
.attention-panel,
.table-wrap,
.split section,
.answer,
.card,
dialog {
  background: var(--surface-panel);
  border: 1px solid var(--border-ui);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.filters {
  margin: 14px 0 16px;
  padding: 10px;
}

input,
select,
textarea {
  background: var(--surface-panel);
  border-color: var(--border-control);
  color: #111827;
}

button {
  background: #107c41;
  border: 1px solid #107c41;
  box-shadow: none;
}

button.secondary,
.button-link {
  background: var(--surface-panel);
  border-color: var(--border-control);
  color: #0f6a39;
}

button:hover,
.button-link:hover {
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08);
}

.user-badge {
  background: #edf7f1;
  border-color: #cde9d7;
}

.attention-panel {
  padding: 12px 14px;
}

.attention-item {
  background: var(--attention-bg);
  border-color: var(--attention-border);
  border-radius: 8px;
}

.attention-item.danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.card {
  background: var(--surface-panel);
  min-height: 100px;
  padding: 16px;
}

.card strong {
  color: #111827;
  font-size: 28px;
}

.card span {
  color: #697586;
}

.dashboard-group h2 {
  color: #526071;
  font-size: 12px;
  letter-spacing: 0;
}

.table-wrap {
  overflow: auto;
}

th {
  background: #f8fafc;
  color: #526071;
  font-size: 11px;
  font-weight: 800;
}

td {
  border-bottom-color: var(--row-border);
}

tbody tr:nth-child(even):not(.missing-action-plan):not(.equipment-group-start) td {
  background: #fbfcfe;
}

tbody tr:hover td {
  background: var(--row-hover);
}

.status {
  border-radius: 999px;
  font-size: 11px;
}

.search-result-card {
  border-color: var(--border-ui);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.search-summary {
  align-items: flex-start;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  color: #243746;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

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

.search-module-chip {
  border-radius: 999px;
  border-width: 1px;
  border-style: solid;
  font-size: 12px;
  padding: 4px 10px;
}

.search-group {
  margin-bottom: 20px;
}

.search-group-title {
  align-items: center;
  display: flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  margin-bottom: 8px;
}

.search-group-count {
  color: #7a8a99;
  font-size: 12px;
  font-weight: 400;
}

.search-best-match {
  background: #fff6df;
  border: 1px solid #f3c66b;
  border-radius: 999px;
  color: #8a5a00;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
  padding: 4px 8px;
}

.search-module-quality {
  background: #e8f4ee;
  border-color: #bddfcc;
}

.search-module-docs {
  background: #eaf2ff;
  border-color: #c9dcfa;
  color: #1d4f91;
}

.search-module-equipment {
  background: #fff7e8;
  border-color: #f0d19a;
  color: #7a4d00;
}

.search-module-risk {
  background: #fff0f0;
  border-color: #f5c4c4;
  color: #9b1c1c;
}

.search-empty {
  background: #ffffff;
  border: 1px dashed #cbd5df;
  border-radius: 10px;
  color: #243746;
  padding: 16px;
}

.search-empty p {
  color: #526371;
  margin: 8px 0 12px;
}

.search-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar {
  padding: 14px 12px;
}

.sidebar .brand {
  margin-bottom: 8px;
}

.menu-group {
  border-top: 1px solid #e6edf3;
  gap: 1px;
  padding-top: 8px;
}

.menu-group-title {
  border: 0;
  min-height: 28px;
  padding: 4px 8px;
}

nav button {
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 6px;
  min-height: 32px;
  padding: 7px 9px;
}

nav button.active {
  background: #e8f4ee;
  box-shadow: none;
}

.dashboard-groups {
  gap: 14px;
}

.dashboard-group {
  display: grid;
  gap: 8px;
}

.dashboard-group h2 {
  border-left: 3px solid var(--green);
  color: #374151;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  padding-left: 8px;
  text-transform: uppercase;
}

.dashboard-group .cards {
  gap: 10px;
  /* Garantir altura uniforme entre cards do mesmo grupo */
  align-items: stretch;
}

.attention-panel {
  align-items: center;
  min-height: 56px;
}

.attention-panel h2 {
  font-size: 18px;
}

.attention-list {
  gap: 6px;
}

.attention-item {
  background: #ffffff;
  border-color: #f3c27c;
  color: #344054;
  min-height: 36px;
  padding: 7px 10px;
}

.attention-item strong {
  color: #b54708;
}

.attention-item.danger,
.card.danger {
  background: #fff5f6;
  border-color: #fda4af;
}

.card {
  min-height: 90px;
  padding: 14px;
}

.card strong {
  font-size: 26px;
  margin-top: 8px;
}

.card.warn {
  background: #fffbf3;
  border-color: #f4bd70;
}

.card.muted-card {
  background: #ffffff;
  border-color: #e4eaf0;
}

.filters {
  gap: 8px;
}

.filters select,
.filters input {
  min-height: 38px;
}

.dashboard-group .cards {
  align-items: stretch;
}

.dashboard-card {
  display: grid;
  gap: 10px;
  grid-template-rows: 1fr auto;
  min-height: 104px;
  padding: 16px;
}

.dashboard-card span {
  align-self: start;
  color: #697586;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.dashboard-card strong {
  align-self: end;
  color: #111827;
  font-size: 28px;
  line-height: 1;
  margin: 0;
}

.dashboard-card.warn strong {
  color: var(--amber);
}

.dashboard-card.danger strong {
  color: var(--red);
}

.dashboard-card.muted-card {
  background: #ffffff;
  border-color: var(--border-muted);
  box-shadow: var(--shadow-sm);
}

.dashboard-card.muted-card span,
.dashboard-card.muted-card strong {
  color: #8a95a3;
}

.dashboard-card.muted-card strong {
  font-size: 24px;
  font-weight: 700;
}

#recordDialog {
  max-height: min(86vh, 760px);
  padding: 0;
}

#recordForm {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(86vh, 760px);
}

#recordDialog h2 {
  background: var(--surface-panel, #ffffff);
  border-bottom: 1px solid var(--border-ui, var(--line));
  margin: 0;
  padding: 18px 20px 12px;
}

#recordDialog .form-grid {
  margin: 0;
  max-height: calc(min(86vh, 760px) - 132px);
  overflow: auto;
  padding: 16px 20px;
}

/* Títulos de seção ficam visíveis enquanto o usuário rola o formulário */
#recordDialog .form-section-title {
  background: var(--surface-panel, #fff);
  position: sticky;
  top: -16px; /* compensa o padding-top do form-grid */
  z-index: 1;
}

#recordDialog menu {
  background: var(--surface-panel, #ffffff);
  border-top: 1px solid var(--border-ui, var(--line));
  margin: 0;
  padding: 12px 20px 16px;
}

@media print {
  .sidebar,
  .topbar,
  .filters,
  .section-head button {
    display: none;
  }

  body {
    display: block;
    background: white;
  }

  .app-shell {
    padding: 0;
  }

  .view:not(.active) {
    display: none;
  }

  .card {
    break-inside: avoid;
  }
}

/* ── Inventory balance table ─────────────────────────────────────────────── */

.inventory-balance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.inventory-balance-table th,
.inventory-balance-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e6edf3;
  text-align: left;
}

.inventory-balance-table thead th {
  background: #f3f7fb;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.row-consumed td {
  color: #8fa3b1;
  font-style: italic;
}

.lot-balance-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: #1d6f3a;
  font-weight: 600;
  padding: 2px 8px;
  background: #e8f9ee;
  border-radius: 6px;
}

.history-body {
  min-width: 480px;
  max-height: 60vh;
  overflow-y: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.history-table th,
.history-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #e6edf3;
  text-align: left;
}

.history-table thead th {
  background: #f3f7fb;
  font-weight: 600;
}

.badge-entrada {
  background: #e8f9ee;
  color: #1d6f3a;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-saida {
  background: #ffeaea;
  color: #9b1c1c;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 0.8rem;
  font-weight: 600;
}

.form-error {
  color: #9b1c1c;
  background: #ffeaea;
  border: 1px solid #f5c4c4;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.88rem;
  margin-top: 4px;
}

/* ── Admin buttons in sidebar ────────────────────────────────────────────── */

.menu-divider {
  border: none;
  border-top: 1px solid #e6edf3;
  margin: 6px 0;
}

.menu-admin-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: #243746;
  cursor: pointer;
  margin-top: 2px;
}

.menu-admin-btn:hover {
  background: #f3f7fb;
}

.menu-admin-btn.warn {
  color: #7a4d00;
  border-color: #f0d19a;
  background: #fff7e8;
}

.menu-admin-btn.warn:hover {
  background: #ffeec8;
}

.inventory-alert-banner {
  background: #fff3cd;
  border: 1px solid #f0c36d;
  border-left: 4px solid #e07b00;
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #5a3e00;
}

/* ── Quality Indicators Panel ──────────────────────────────────────────────── */
.qi-view { padding: 0 24px 32px; }
.qi-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.qi-header h2 { margin: 0; }
.qi-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qi-alert-banner { background: #fff3cd; border: 1px solid #f0c36d; border-left: 4px solid #e07b00; border-radius: 6px; padding: 10px 16px; margin-bottom: 14px; font-size: 0.88rem; color: #5a3e00; }
.qi-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 28px; }
.qi-card { background: #fff; border-radius: 10px; border: 1px solid #e2e8f0; padding: 16px; cursor: pointer; transition: box-shadow 0.15s; }
.qi-card:hover { box-shadow: 0 4px 16px #0001; }
.qi-card.dentro { border-left: 4px solid #22c55e; }
.qi-card.fora { border-left: 4px solid #ef4444; }
.qi-card.sem_meta { border-left: 4px solid #94a3b8; }
.qi-card-name { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.qi-card-value { font-size: 1.6rem; font-weight: 700; margin: 4px 0; }
.qi-card-value.dentro { color: #16a34a; }
.qi-card-value.fora { color: #dc2626; }
.qi-card-meta { font-size: 0.78rem; color: #64748b; }
.qi-card-period { font-size: 0.75rem; color: #94a3b8; margin-top: 4px; }
.qi-card-warn { font-size: 0.75rem; color: #b45309; margin-top: 4px; font-weight: 600; }
.qi-card-no-data { font-size: 0.82rem; color: #94a3b8; padding: 8px 0; }
.qi-card-actions { display: flex; gap: 6px; margin-top: 10px; }
.qi-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; margin-bottom: 28px; }
.qi-chart-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 18px; }
.qi-chart-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.qi-chart-canvas { width: 100%; max-height: 220px; }
.qi-history-section { margin-top: 20px; }
.qi-history-section h3 { margin-bottom: 10px; }
.qi-detail-body { max-height: 60vh; overflow-y: auto; }
.qi-detail-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 0.87rem; }
.qi-detail-row strong { min-width: 140px; color: #475569; }
.qi-calc-preview { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; padding: 8px 12px; font-size: 0.85rem; color: #15803d; width: 100%; box-sizing: border-box; }
.qi-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.qi-badge.dentro { background: #dcfce7; color: #15803d; }
.qi-badge.fora { background: #fee2e2; color: #dc2626; }
.qi-badge.sem_meta { background: #f1f5f9; color: #64748b; }
.qi-inactive { opacity: 0.5; }

.backup-info {
  font-size: 0.82rem;
  color: #556;
  background: #f5f7fa;
  border-radius: 6px;
  padding: 6px 12px;
  margin-bottom: 10px;
}
