/* Approved KB_BRAND_VISUAL_FIX candidate; scoped to the existing single modal. */
html body #kb-modal[data-kb-unified] {
  z-index: 1000000 !important;
  background: rgba(17,17,17,.06) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
  padding: 24px !important;
  align-items: center !important;
  justify-content: center !important;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  color: #555555 !important;
}
/* Keep existing feedback layers above this modal, only while KB is open. */
html body:has(#kb-modal[data-kb-unified]:not(.hidden)) #overlay {
  z-index: 1000001 !important;
}
html body:has(#kb-modal[data-kb-unified]:not(.hidden)) :is(#toast, #success-toast) {
  z-index: 1000002 !important;
}
html body #kb-modal[data-kb-unified].hidden,
html body #kb-modal[data-kb-unified] .hidden { display: none !important; }
html body #kb-modal[data-kb-unified] .kb-modal-content {
  position: relative !important;
  width: min(720px,calc(100vw - 48px)) !important;
  max-width: 720px !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100dvh - 48px) !important;
  background: #FFFFFF !important;
  border: 1px solid #EBEBEB !important;
  border-radius: 16px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.05) !important;
  overflow: hidden !important;
  animation: none !important;
  color: #555555 !important;
}
html body #kb-modal[data-kb-unified][data-kb-mode="sop"] .kb-modal-content {
  width: min(1120px,calc(100vw - 48px)) !important;
  max-width: 1120px !important;
}
html body #kb-modal[data-kb-unified] :is(p,label,li,textarea) { color: #555555 !important; }
html body #kb-modal[data-kb-unified] .modal-header {
  flex: 0 0 auto;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  padding: 18px 24px !important;
  background: #FFFFFF !important;
  border-bottom: 1px solid #EBEBEB !important;
}
html body #kb-modal[data-kb-unified] #kb-modal-title {
  color: #111111 !important;
  font-size: 22px !important;
  line-height: 1.35 !important;
  font-weight: 700 !important;
  margin: 0 !important;
}
html body #kb-modal[data-kb-unified] #close-kb-modal {
  position: static !important;
  flex: 0 0 auto;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  border: 1px solid #EBEBEB !important;
  border-radius: 8px !important;
  color: #555555 !important;
  background: #FFFFFF !important;
  box-shadow: none !important;
}
html body #kb-modal[data-kb-unified] .modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  padding: 20px 24px 24px !important;
  background: #FFFFFF !important;
}
html body #kb-modal[data-kb-unified] #kb-file-list {
  width: 100%;
  max-height: min(440px,52dvh) !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  color: #555555 !important;
  font-size: 14px !important;
  line-height: 1.75 !important;
}
html body #kb-modal[data-kb-unified] .kb-file-card {
  display: grid !important;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center !important;
  gap: 12px !important;
  padding: 14px 0 !important;
  border-bottom: 1px solid #EBEBEB !important;
  min-width: 0;
}
html body #kb-modal[data-kb-unified] .kb-file-copy { min-width: 0 !important; }
html body #kb-modal[data-kb-unified] .kb-file-title-row {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px !important;
  flex-wrap: wrap !important;
  min-width: 0;
}
html body #kb-modal[data-kb-unified] .kb-file-name {
  width: 100%;
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  color: #111111 !important;
  font-size: 14px !important;
  line-height: 1.7 !important;
  font-weight: 600 !important;
  margin: 0 !important;
}
html body #kb-modal[data-kb-unified] .kb-file-status {
  max-width: 100%;
  min-width: 0;
  white-space: normal !important;
  overflow-wrap: anywhere;
  font-size: 12px !important;
  line-height: 1.7 !important;
  color: #555555 !important;
  align-items: baseline !important;
}
html body #kb-modal[data-kb-unified] .kb-file-status > span {
  background: #999999 !important;
  flex: 0 0 5px;
}
html body #kb-modal[data-kb-unified] .kb-file-status[data-status="self_hosted_ingesting"] > span,
html body #kb-modal[data-kb-unified] .kb-file-status[data-status="uploading"] > span,
html body #kb-modal[data-kb-unified] .kb-file-status[data-status="failed"] > span { background: #FF5A5F !important; }
html body #kb-modal[data-kb-unified] .kb-file-status[data-status="failed"] { color: #FF5A5F !important; }
html body #kb-modal[data-kb-unified] .kb-file-meta { color: #999999 !important; font-size: 12px !important; margin: 4px 0 0 !important; }
html body #kb-modal[data-kb-unified] .kb-file-copy > div:not(.kb-file-title-row) { color: #555555 !important; font-size: 12px !important; }
html body #kb-modal[data-kb-unified] .kb-file-actions { display: flex !important; gap: 8px !important; margin: 0 !important; }
html body #kb-modal[data-kb-unified] :is(.kb-download-btn,.kb-delete-btn) {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  padding: 0 !important;
  border: 1px solid #EBEBEB !important;
  border-radius: 8px !important;
  background: #FFFFFF !important;
  color: #555555 !important;
  box-shadow: none !important;
}
html body #kb-modal[data-kb-unified] :is(#kb-upload-btn,#kb-sop-converter-btn,#kb-sop-converter-save) {
  min-height: 40px !important;
  padding: 9px 18px !important;
  border: 1px solid #FF5A5F !important;
  border-radius: 8px !important;
  background: #FF5A5F !important;
  color: #FFFFFF !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  box-shadow: none !important;
}
html body #kb-modal[data-kb-unified] :is(#kb-upload-btn,#kb-sop-converter-btn,#kb-sop-converter-save) * { color: inherit !important; }
html body #kb-modal[data-kb-unified] :is(#kb-upload-btn,#kb-sop-converter-btn,#kb-sop-converter-save):hover:not(:disabled) { background: #CC3A3F !important; border-color: #CC3A3F !important; }
html body #kb-modal[data-kb-unified] #kb-upload-footer-hint { color: #999999 !important; font-size: 12px !important; }
html body #kb-modal[data-kb-unified] :is(#kb-download-sop-template-btn,#kb-sop-converter-restore,#kb-sop-converter-cancel,#kb-sop-quality-refresh) {
  border: 1px solid #EBEBEB !important;
  border-radius: 8px !important;
  min-height: 40px;
  padding: 8px 14px !important;
  background: #FFFFFF !important;
  color: #555555 !important;
  font-size: 12px !important;
  line-height: 1.6 !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}
html body #kb-modal[data-kb-unified]:has(#kb-sop-converter-editor:not(.hidden)) #kb-sop-converter-btn {
  background: #FFFFFF !important;
  border-color: #EBEBEB !important;
  color: #555555 !important;
}
html body #kb-modal[data-kb-unified] button:not(:disabled):hover { border-color: #FF5A5F !important; }
html body #kb-modal[data-kb-unified] button:disabled {
  background: #F7F8FA !important;
  border-color: #EBEBEB !important;
  color: #999999 !important;
  opacity: 1 !important;
  box-shadow: none !important;
}
html body #kb-modal[data-kb-unified] :is(button,textarea):focus-visible { outline: 2px solid #FF5A5F; outline-offset: 2px; }
html body #kb-modal[data-kb-unified] :is(#kb-sop-converter-card,#kb-sop-upload-card,#kb-sop-converter-editor) {
  background: #FFFFFF !important;
  border: 1px solid #EBEBEB !important;
  border-radius: 16px !important;
  padding: 18px 20px !important;
  margin-bottom: 16px !important;
}
html body #kb-modal[data-kb-unified] :is(#kb-sop-converter-card,#kb-sop-upload-card,#kb-sop-converter-editor) > p:first-child {
  color: #111111 !important; font-size: 14px !important; font-weight: 600 !important; line-height: 1.7 !important;
}
html body #kb-modal[data-kb-unified] :is(#kb-sop-converter-card,#kb-sop-upload-card) > p:not(:first-child) { color: #555555 !important; font-size: 12px !important; line-height: 1.7 !important; }
html body #kb-modal[data-kb-unified] #kb-sop-validation-result {
  color: #555555 !important; background: #F7F8FA !important; border: 1px solid #EBEBEB !important;
  font-size: 14px !important; line-height: 1.7 !important; font-weight: 500 !important; padding: 10px 12px !important; border-radius: 8px !important;
}
html body #kb-modal[data-kb-unified] .kb-sop-review-grid {
  display: grid !important; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); gap: 16px !important; align-items: stretch;
}
html body #kb-modal[data-kb-unified] :is(.kb-sop-source-pane,.kb-sop-quality-advisory):not(.hidden) {
  display: flex !important; flex-direction: column; min-width: 0; min-height: 0;
  height: clamp(280px,calc(100dvh - 600px),480px) !important;
  order: initial !important; padding: 0 !important; margin: 0 !important;
  background: #FFFFFF !important; border: 1px solid #EBEBEB !important; border-radius: 12px !important; overflow: hidden !important;
}
html body #kb-modal[data-kb-unified] :is(.kb-sop-pane-heading,.kb-sop-quality-advisory-head) {
  display: flex !important; align-items: center; flex: 0 0 auto; justify-content: space-between; gap: 10px;
  min-height: 64px !important; padding: 12px !important; border-bottom: 1px solid #EBEBEB !important; background: #FFFFFF !important;
}
html body #kb-modal[data-kb-unified] :is(.kb-sop-pane-heading strong,.kb-sop-quality-advisory-head strong) { color: #111111 !important; font-size: 14px !important; font-weight: 600 !important; }
html body #kb-modal[data-kb-unified] :is(.kb-sop-pane-heading span,.kb-sop-quality-advisory-head span) { display: block; color: #999999 !important; font-size: 12px !important; }
html body #kb-modal[data-kb-unified] .kb-sop-source-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px; }
html body #kb-modal[data-kb-unified] #kb-sop-converter-textarea {
  width: 100% !important; height: 100% !important; min-height: 100% !important; max-width: 100%; resize: none !important;
  padding: 10px 12px !important; border: 1px solid #EBEBEB !important; border-radius: 8px !important;
  background: #FFFFFF !important; color: #555555 !important; font-size: 14px !important; line-height: 1.75 !important; box-shadow: none !important;
}
html body #kb-modal[data-kb-unified] .kb-sop-quality-summary { padding: 10px 12px !important; margin: 0 !important; border-bottom: 1px solid #EBEBEB !important; color: #555555 !important; font-size: 12px !important; line-height: 1.7 !important; }
html body #kb-modal[data-kb-unified] .kb-sop-quality-list { min-height: 0; flex: 1 1 auto; overflow: auto; padding: 0 12px 12px !important; }
html body #kb-modal[data-kb-unified] .kb-sop-quality-item-title { font-size: 14px !important; font-weight: 600 !important; color: #111111 !important; }
html body #kb-modal[data-kb-unified] .kb-sop-quality-item-tag { background: #F7F8FA !important; color: #555555 !important; border: 1px solid #EBEBEB; border-radius: 999px; font-size: 12px !important; }
html body #kb-modal[data-kb-unified] .kb-sop-quality-item p { color: #555555 !important; font-size: 14px !important; font-weight: 400 !important; line-height: 1.75 !important; }
html body #kb-modal[data-kb-unified] .kb-sop-action-footer:not(.hidden) {
  position: relative !important; flex: 0 0 auto; display: flex !important; align-items: center; justify-content: flex-end; gap: 10px !important;
  padding: 14px 24px !important; background: #FFFFFF !important; border-top: 1px solid #EBEBEB !important; box-shadow: none !important;
}
@media(max-width:980px) {
  html body #kb-modal[data-kb-unified] .kb-sop-review-grid { display: flex !important; flex-direction: column; }
  html body #kb-modal[data-kb-unified] :is(.kb-sop-source-pane,.kb-sop-quality-advisory):not(.hidden) { height: auto !important; }
  html body #kb-modal[data-kb-unified] .kb-sop-source-pane { order: 1 !important; }
  html body #kb-modal[data-kb-unified] .kb-sop-quality-advisory { order: 2 !important; }
  html body #kb-modal[data-kb-unified] #kb-sop-converter-textarea { height: 260px !important; min-height: 260px !important; }
  html body #kb-modal[data-kb-unified] .kb-sop-quality-list { overflow: visible; }
}
@media(max-width:600px) {
  html body #kb-modal[data-kb-unified] { padding: 12px !important; }
  html body #kb-modal[data-kb-unified] .kb-modal-content,
  html body #kb-modal[data-kb-unified][data-kb-mode="sop"] .kb-modal-content {
    width: calc(100vw - 24px) !important; max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 24px) !important; height: auto !important; min-height: 0 !important; border-radius: 16px !important;
  }
  html body #kb-modal[data-kb-unified] .modal-header { padding: 14px 16px !important; }
  html body #kb-modal[data-kb-unified] #close-kb-modal { width: 44px !important; height: 44px !important; min-width: 44px !important; min-height: 44px !important; }
  html body #kb-modal[data-kb-unified] .modal-body { padding: 16px !important; }
  html body #kb-modal[data-kb-unified] #kb-file-list { max-height: 50dvh !important; }
  html body #kb-modal[data-kb-unified] .kb-file-card { gap: 10px !important; }
  html body #kb-modal[data-kb-unified] :is(.kb-download-btn,.kb-delete-btn) { width: 40px !important; height: 40px !important; min-width: 40px !important; min-height: 40px !important; }
  html body #kb-modal[data-kb-unified] :is(#kb-sop-converter-card,#kb-sop-upload-card,#kb-sop-converter-editor) { padding: 16px !important; }
  html body #kb-modal[data-kb-unified] .kb-sop-pane-heading { flex-direction: column; align-items: flex-start; gap: 4px; }
  html body #kb-modal[data-kb-unified] .kb-sop-pane-heading strong { white-space: nowrap; }
  html body #kb-modal[data-kb-unified] .kb-sop-action-footer:not(.hidden) { display: grid !important; grid-template-columns: minmax(0,1fr) minmax(0,1.5fr); gap: 8px !important; padding: 12px 16px !important; }
  html body #kb-modal[data-kb-unified] .kb-sop-action-footer button { width: 100%; min-width: 0; min-height: 44px !important; white-space: normal !important; }
  html body #kb-modal[data-kb-unified] #kb-sop-converter-restore { grid-column: 1 / -1; margin: 0 !important; }
}
