.knowledge-page {
  background: var(--bg);
}

.knowledge-shell {
  margin: 0 auto;
  max-width: 1380px;
  min-height: 100vh;
  padding: 24px;
}

.knowledge-topbar,
.knowledge-nav,
.knowledge-command-band,
.knowledge-command-actions,
.knowledge-document-header,
.knowledge-filter-form,
.knowledge-dialog-header {
  align-items: center;
  display: flex;
  gap: 10px;
}

.knowledge-topbar,
.knowledge-command-band,
.knowledge-document-header,
.knowledge-dialog-header {
  justify-content: space-between;
}

.knowledge-topbar {
  margin-bottom: 16px;
}

.knowledge-status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 16px;
}

.knowledge-status-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 88px;
  padding: 14px;
}

.knowledge-status-grid span,
.knowledge-status-grid strong {
  display: block;
}

.knowledge-status-grid span,
.knowledge-command-band p,
.knowledge-form label > span,
.knowledge-filter-form label > span,
.knowledge-dialog label > span {
  color: var(--muted);
  font-size: 12px;
}

.knowledge-status-grid strong {
  font-size: 20px;
  margin-top: 9px;
  overflow-wrap: anywhere;
}

.knowledge-command-band {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-bottom: 16px;
  min-height: 72px;
  padding: 12px 16px;
}

.knowledge-command-band strong {
  display: block;
  font-size: 14px;
}

.knowledge-command-band p {
  margin-top: 4px;
  min-height: 18px;
}

.knowledge-work-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  margin-bottom: 16px;
}

.knowledge-form {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.knowledge-form label,
.knowledge-filter-form label,
.knowledge-dialog label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

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

.knowledge-form textarea {
  min-height: 144px;
  resize: vertical;
}

.compact-form textarea {
  min-height: auto;
}

.knowledge-search-results,
.knowledge-document-list,
.knowledge-evaluation-results {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 14px 18px 18px;
}

.knowledge-search-result,
.knowledge-document-row,
.knowledge-evaluation-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
}

.knowledge-search-result header,
.knowledge-document-row header,
.knowledge-document-actions,
.knowledge-document-meta,
.knowledge-evaluation-result header {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.knowledge-search-result strong,
.knowledge-document-row strong,
.knowledge-evaluation-result strong {
  font-size: 14px;
  line-height: 1.45;
}

.knowledge-search-result p,
.knowledge-document-row p {
  color: #2d3d4c;
  font-size: 13px;
  line-height: 1.6;
  margin-top: 8px;
}

.knowledge-search-result small,
.knowledge-document-row small,
.knowledge-evaluation-result small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.knowledge-document-meta {
  justify-content: flex-start;
  margin-top: 8px;
}

.knowledge-document-actions {
  flex: none;
  justify-content: flex-end;
}

.knowledge-document-actions button {
  min-height: 32px;
  padding: 6px 9px;
}

.knowledge-status-badge {
  background: #fff7ed;
  border-radius: 999px;
  color: var(--amber);
  flex: none;
  font-size: 12px;
  padding: 4px 8px;
}

.knowledge-status-badge.approved,
.knowledge-result-badge.passed {
  background: #e8f5ec;
  color: var(--green);
}

.knowledge-status-badge.invalidated,
.knowledge-result-badge.failed {
  background: #faeaea;
  color: var(--red);
}

.knowledge-document-header {
  align-items: end;
}

.knowledge-filter-form {
  align-items: end;
}

.knowledge-filter-form input,
.knowledge-filter-form select {
  min-width: 132px;
}

.knowledge-evaluation-panel {
  margin-top: 16px;
}

.knowledge-result-badge {
  background: var(--surface-soft);
  border-radius: 999px;
  color: var(--muted);
  flex: none;
  font-size: 12px;
  padding: 4px 8px;
}

.knowledge-dialog {
  background: transparent;
  border: 0;
  max-height: 90vh;
  max-width: 820px;
  padding: 0;
  width: calc(100% - 28px);
}

.knowledge-dialog::backdrop {
  background: rgb(15 23 42 / 46%);
}

.knowledge-dialog-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
}

.knowledge-dialog-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.knowledge-version-list,
.knowledge-audit-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.knowledge-version-list li,
.knowledge-audit-list li {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.55;
  padding: 10px;
}

.compact-dialog {
  max-width: 520px;
}

.danger-command {
  background: var(--red);
  justify-self: end;
}

@media (max-width: 980px) {
  .knowledge-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .knowledge-work-grid {
    grid-template-columns: 1fr;
  }

  .knowledge-document-header {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .knowledge-shell {
    padding: 14px;
  }

  .knowledge-topbar,
  .knowledge-command-band,
  .knowledge-dialog-header {
    align-items: stretch;
    flex-direction: column;
  }

  .knowledge-nav,
  .knowledge-command-actions,
  .knowledge-filter-form,
  .knowledge-form-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

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

  .knowledge-filter-form input,
  .knowledge-filter-form select {
    min-width: 0;
    width: 100%;
  }

  .knowledge-document-row header,
  .knowledge-document-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .knowledge-document-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
}
