:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --border: #dbe3ee;
  --border-strong: #c7d2e1;

  --text: #1f2937;
  --muted: #64748b;
  --muted-2: #8b95a7;

  --primary: #0f2b5b;
  --primary-2: #173d7a;
  --primary-soft: #eaf1ff;

  --accent-blue: #2563eb;
  --accent-cyan: #0891b2;
  --accent-cyan-soft: #ecfeff;

  --success: #2e7d32;
  --success-soft: #e8f4ea;

  --warning: #c47f00;
  --warning-soft: #fff3d8;

  --danger: #c62828;
  --danger-soft: #fde9e9;

  --purple: #8e24aa;
  --purple-soft: #f5eafd;

  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 22px rgba(16, 24, 40, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* =========================
   SIDEBAR
   ========================= */

.sidebar {
  background: linear-gradient(180deg, #edf4ff 0%, #f8fafc 100%);
  border-right: 1px solid var(--border);
  padding: 18px 16px;
}

.brand {
  padding: 10px 6px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand.brand-text-only {
  display: block;
}

.brand.brand-text-only h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.12;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: -0.8px;
  white-space: nowrap;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 1px solid #d4deed;
  background: rgba(255, 255, 255, 0.78);
  color: #334155;
  text-align: left;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-item:hover {
  border-color: #b8c7db;
  background: #ffffff;
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(15, 43, 91, 0.18);
}

.sidebar-divider {
  height: 1px;
  background: #cfd8e6;
  margin: 16px 0 10px;
}

.sidebar-section-title {
  padding: 6px 12px 2px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =========================
   CONTENT
   ========================= */

.content {
  padding: 28px;
}

.view {
  display: block;
}

.header {
  margin-bottom: 20px;
}

.header .eyebrow {
  margin: 0 0 6px;
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header h2 {
  margin: 0;
  font-size: 29px;
  line-height: 1.15;
  color: #111827;
  font-weight: 800;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.subtitle.small {
  font-size: 13px;
}

/* =========================
   CARDS
   ========================= */

.card,
.resultado {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.card {
  padding: 22px;
}

.resultado {
  margin-top: 22px;
  padding: 22px;
  border-top: 4px solid var(--primary);
}

/* =========================
   FORM
   ========================= */

.form,
.estrutura-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.fields-grid {
  display: grid;
  gap: 16px;
}

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

.estrutura-nome-grid {
  grid-template-columns: minmax(0, 1fr);
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label > span {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 8px;
  padding: 12px 13px;
  font-size: 14px;
  color: #111827;
  outline: none;
  transition: 0.15s ease;
  font-family: Arial, Helvetica, sans-serif;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

/* =========================
   UPLOAD
   ========================= */

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

.upload-box {
  border: 1px dashed #aebee0;
  background: #f8fbff;
  border-radius: 12px;
  padding: 18px;
  transition: 0.15s ease;
}

.upload-box:hover {
  border-color: var(--accent-blue);
  background: #f4f8ff;
}

.upload-box:nth-child(2) {
  border-color: #a9dce5;
  background: #f5feff;
}

.upload-box:nth-child(2):hover {
  border-color: var(--accent-cyan);
  background: #ecfeff;
}

.upload-title {
  font-size: 14px;
  font-weight: 800;
  color: #111827;
}

.upload-description {
  font-size: 12px;
  color: var(--muted);
}

.upload-box input[type="file"] {
  margin-top: 8px;
  background: #fff;
  border-color: #d4deed;
}

.upload-box input[type="file"]::file-selector-button {
  border: 1px solid #ccd7ea;
  background: #ffffff;
  color: var(--primary);
  border-radius: 6px;
  padding: 8px 12px;
  margin-right: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.upload-box input[type="file"]::file-selector-button:hover {
  background: var(--primary-soft);
}

.upload-box strong {
  margin-top: 6px;
  font-size: 13px;
  color: var(--primary);
  word-break: break-word;
}

/* =========================
   BUTTONS
   ========================= */

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 11px 17px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.16s ease;
  box-shadow: 0 5px 12px rgba(15, 43, 91, 0.14);
}

button:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
  transform: translateY(-1px);
}

button.secondary {
  background: #fff;
  color: #374151;
  border-color: var(--border-strong);
  box-shadow: none;
}

button.secondary:hover {
  background: #f8fafc;
  border-color: #b5bdc8;
  transform: translateY(-1px);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.danger:hover {
  background: #a51f1f;
  border-color: #a51f1f;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-small {
  padding: 8px 10px;
  font-size: 12px;
}

/* =========================
   STATUS
   ========================= */

.status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* =========================
   RESULTADO
   ========================= */

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.result-header .eyebrow {
  margin: 0 0 6px;
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-header h2 {
  margin: 0;
  font-size: 24px;
  color: #111827;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #eef2f7;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #d1d9e6;
  text-transform: uppercase;
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
  border-color: #b9d8bc;
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efb1b1;
}

.analysis-info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.analysis-info > div {
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.analysis-info span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.analysis-info strong {
  display: block;
  font-size: 16px;
  color: #111827;
}

.message {
  margin: 0 0 18px;
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  background: #f8fbff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-blue);
  border-radius: 11px;
  padding: 14px 16px;
}

.summary-card > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.summary-card > strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  color: #111827;
}

.warning {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: 11px;
  border: 1px solid #efd7a1;
  background: var(--warning-soft);
}

.warning h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #7a5300;
}

.warning p {
  margin: 0 0 12px;
  font-size: 13px;
  color: #6b4d00;
  line-height: 1.5;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
}

.tables {
  display: grid;
  gap: 18px;
}

.resultado-section {
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px;
}

.resultado-section h3,
.resultado-section h4 {
  margin: 0 0 12px;
  color: #111827;
}

.resultado-section h3 {
  font-size: 17px;
}

.resultado-section h4 {
  font-size: 14px;
  margin-top: 12px;
  color: var(--primary);
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}

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

thead tr {
  background: #eef3f9;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #374151;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: #111827;
}

tbody tr:hover {
  background: #f7fbff;
}

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  padding: 16px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.result-actions {
  margin-top: 20px;
}


/* =========================
   ESTRUTURAS SEM NORMA
   ========================= */

#estruturasSemNormaBox {
  border-color: #efb1b1;
  border-top: 4px solid var(--danger);
  background: #fffafa;
}

#estruturasSemNormaBox h3 {
  color: var(--danger);
}

#estruturasSemNormaLista .empty {
  background: #ffffff;
  border-color: #efb1b1;
  color: #7f1d1d;
}

.estruturas-sem-norma-section {
  border-color: #efb1b1;
  background: #fffafa;
}

.estruturas-sem-norma-section h3 {
  color: var(--danger);
}

.estruturas-sem-norma-table {
  border-color: #efb1b1;
}

.estruturas-sem-norma-table table {
  min-width: 860px;
}

.estruturas-sem-norma-table thead tr {
  background: var(--danger-soft);
}

.estrutura-sem-norma-row {
  background: #fffafa;
}

.estrutura-sem-norma-row:hover {
  background: #fff1f1;
}

.estrutura-sem-norma-row td {
  border-bottom-color: #f4caca;
}

.estrutura-sem-norma-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  color: var(--danger);
  box-shadow: none;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.estrutura-sem-norma-link:hover {
  background: transparent;
  border-color: transparent;
  color: #991b1b;
  transform: none;
}

.estrutura-sem-norma-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-marcar-estrutura-nao-aplica {
  color: var(--danger);
  border-color: #efb1b1;
  background: #ffffff;
}

.btn-marcar-estrutura-nao-aplica:hover {
  color: #991b1b;
  border-color: #dc8a8a;
  background: #fff5f5;
}

.historico-modal-content .estruturas-sem-norma-table table {
  min-width: 760px;
}

.historico-modal-content .estrutura-sem-norma-actions {
  gap: 6px;
}

/* =========================
   IMPEDIMENTOS
   ========================= */

#impedimentosView .upload-grid {
  grid-template-columns: minmax(0, 1fr);
}

.impedimento-upload-box {
  min-height: 122px;
}

#impedimentoArquivosNome {
  display: block;
  max-width: 100%;
  line-height: 1.45;
}

#impedimentoResumoGrid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#impedimentoAchados .table-wrap {
  max-height: 620px;
}

#impedimentoAchados table {
  min-width: 1080px;
}

#impedimentoAchados th:nth-child(1),
#impedimentoAchados td:nth-child(1) {
  width: 52px;
  text-align: center;
}

#impedimentoAchados th:nth-child(2),
#impedimentoAchados td:nth-child(2) {
  width: 110px;
}

#impedimentoAchados th:nth-child(3),
#impedimentoAchados td:nth-child(3) {
  width: 150px;
}

#impedimentoAchados th:nth-child(4),
#impedimentoAchados td:nth-child(4) {
  width: 190px;
}

#impedimentoAchados th:nth-child(5),
#impedimentoAchados td:nth-child(5) {
  width: 70px;
  text-align: center;
}

.chip-toggle {
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  transition: 0.15s ease;
}

.chip-toggle:hover {
  border-color: #f0b36d;
  background: #fff8ed;
}

.chip-dispensado {
  background: var(--success-soft);
  border-color: #b9d8bc;
  color: var(--success);
  text-decoration: line-through;
}

.comentarios-card {
  margin-top: 18px;
  box-shadow: none;
}

.comentarios-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  color: #111827;
}

.comentarios-card textarea {
  min-height: 110px;
  resize: vertical;
  margin-top: 14px;
}

.comentarios-card .actions {
  margin-top: 12px;
}

#impedimentoSalvarStatus {
  margin-top: 8px;
}

#btnRevisarImpedimento {
  min-width: 150px;
}

#btnSalvarRevisao {
  min-width: 130px;
}

/* =========================
   HISTÓRICO DE IMPEDIMENTOS
   ========================= */

.impedimentos-historico-card {
  border-top: 4px solid var(--primary);
}

.impedimentos-historico-table table {
  min-width: 920px;
}

.historico-impedimento-row {
  cursor: pointer;
}

.historico-impedimento-row:hover {
  background: #eef6ff;
}

.historico-impedimento-row .badge {
  min-height: 26px;
  padding: 0 9px;
  font-size: 11px;
}

.historico-impedimento-detalhe-card {
  border-top: 0;
}

.impedimento-historico-info {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.impedimento-historico-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.historico-impedimento-detalhe-card .table-wrap table {
  min-width: 860px;
}

.historico-impedimento-detalhe-card .resultado-section {
  background: #ffffff;
}

.historico-impedimento-detalhe-card .message {
  margin-bottom: 0;
}

/* =========================
   BASE NORMATIVA
   ========================= */

.normativa-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.componentes-box,
.consulta-estrutura {
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 16px;
}

.componentes-header,
.consulta-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.componentes-header h3,
.consulta-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #111827;
}

.componentes-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.componente-row {
  display: grid;
  grid-template-columns: 1fr 2fr 0.8fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}

.consulta-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.estrutura-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.estrutura-pill {
  border: 1px solid #c7d1df;
  background: #fff;
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.estrutura-pill:hover {
  background: var(--primary-soft);
  border-color: #aebfdc;
}

.estrutura-itens {
  margin-top: 10px;
}

/* =========================
   HISTÓRICO
   ========================= */

.card .empty {
  background: #fafafa;
}

.historico-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.historico-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.historico-filtro {
  flex: 1;
  min-width: 260px;
}

.historico-toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.historico-lista {
  width: 100%;
}

.historico-detalhe {
  margin-top: 8px;
}

.historico-detalhe-card {
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 12px;
  background: #fff;
  padding: 20px;
}

.historico-section-gap {
  margin-top: 18px;
}

.historico-paginacao {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.historico-paginacao-info {
  color: var(--muted);
  font-size: 14px;
}

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

/* =========================
   RESPONSIVO
   ========================= */

@media (max-width: 1180px) {
  .normativa-card {
    grid-template-columns: 1fr;
  }

  .componente-row {
    grid-template-columns: 1fr;
  }

  .consulta-actions {
    max-width: none;
    flex-wrap: wrap;
  }

  #impedimentoResumoGrid,
  .impedimento-historico-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 18px;
  }

  .comissionamento-meta-grid,
  .upload-grid,
  .analysis-info,
  #impedimentoResumoGrid,
  .impedimento-historico-info,
  .impedimento-historico-summary {
    grid-template-columns: 1fr;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand.brand-text-only h1 {
    font-size: 22px;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 14px;
  }

  .card,
  .resultado {
    padding: 16px;
  }

  .header h2 {
    font-size: 24px;
  }

  .brand.brand-text-only h1 {
    font-size: 20px;
  }

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
