:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --text: #17191c;
  --muted: #737980;
  --muted-2: #9aa0a6;
  --line: #e4e6e8;
  --line-strong: #d4d7da;
  --primary: #1f5c4d;
  --primary-hover: #184b3f;
  --primary-soft: #edf5f2;
  --danger: #b42318;
  --warning-bg: #fff8e8;
  --warning-line: #f1dfb4;
  --warning-text: #725311;
  --success-bg: #eef8f3;
  --success-line: #cee7da;
  --success-text: #225d48;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.topbar {
  height: 64px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.topbar-inner {
  width: min(980px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.brand strong {
  font-size: 14px;
  letter-spacing: -.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c7c9cc;
  display: inline-block;
}
.status-dot.ok { background: #3b8d6d; }

.icon-link {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #5b6168;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.icon-link:hover { background: #f1f2f3; color: var(--text); }
.icon-link svg { width: 18px; height: 18px; fill: currentColor; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.back-link:hover { color: var(--text); }
.back-link svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page,
.settings-page {
  width: min(880px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 72px;
}
.settings-page { width: min(680px, calc(100% - 40px)); }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-heading h1 {
  margin: 2px 0 0;
  font-size: clamp(30px, 4.6vw, 42px);
  line-height: 1.05;
  letter-spacing: -.045em;
  font-weight: 650;
}
.overline {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
}

.workspace-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 8px 30px rgba(20, 24, 28, .035);
}
.workspace-card + .workspace-card { margin-top: 18px; }

.section-heading { margin-bottom: 16px; }
.section-heading h2,
.result-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -.015em;
  font-weight: 650;
}

.dropzone {
  min-height: 182px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: #fbfbfc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 18px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
  border-color: #7d9f94;
  background: #f7faf9;
}
.upload-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #fff;
  margin-bottom: 12px;
  color: #5d656c;
}
.upload-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dropzone strong { font-size: 14px; font-weight: 650; }
.dropzone span { margin-top: 4px; color: var(--primary); font-size: 13px; font-weight: 600; }
.dropzone small { margin-top: 10px; color: var(--muted-2); font-size: 11px; }

.file-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}
.file-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 238px 32px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.file-name { min-width: 0; }
.file-name strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
}
.file-name small {
  display: block;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 11px;
}

.file-classification {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.auto-classification {
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.manual-classification-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  color: #596168;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}
.manual-classification-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

select,
input[type="text"],
input[type="password"],
input[type="url"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.file-row select {
  height: 36px;
  font-size: 12px;
  color: #4f565d;
  background-color: #fafafa;
}
select:focus,
input:focus {
  border-color: #769b8f;
  box-shadow: 0 0 0 3px rgba(31,92,77,.08);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.btn-icon:hover { background: #f3f4f5; color: var(--text); }

.template-row {
  min-height: 58px;
  margin-top: 14px;
  padding: 11px 2px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.template-copy { min-width: 0; }
.template-copy > span {
  display: block;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.template-copy strong {
  display: inline;
  font-size: 12px;
  font-weight: 600;
}
.template-copy small {
  color: var(--muted-2);
  font-size: 11px;
  margin-left: 6px;
}

.workspace-footer,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.btn {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: #42484f; border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: #f7f7f8; }

.text-button {
  border: 0;
  background: transparent;
  padding: 4px 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.text-button:hover { text-decoration: underline; }
.danger-text { color: var(--danger); margin-left: auto; }

.progress-wrap { display: none; margin-top: 16px; }
.progress-wrap.visible { display: block; }
.progress-track {
  height: 4px;
  border-radius: 999px;
  background: #eceeef;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width .3s ease;
}
.progress-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.result-card { display: none; }
.result-card.visible { display: block; }
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.result-header .overline { margin-bottom: 4px; }

.notice {
  border: 1px solid var(--warning-line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 12px;
  line-height: 1.45;
}
.notice.success {
  border-color: var(--success-line);
  background: var(--success-bg);
  color: var(--success-text);
}
.notice.danger {
  border-color: #f0c9c5;
  background: #fff4f3;
  color: #8f2118;
}

.summary-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.summary-item {
  min-height: 88px;
  padding: 14px;
  background: #fff;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.summary-item:nth-child(2n) { border-right: 0; }
.summary-item:nth-last-child(-n+2) { border-bottom: 0; }
.summary-item span {
  display: block;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .055em;
}
.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 550;
}

.warnings {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.warnings li {
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 11.5px;
  line-height: 1.45;
}
.result-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.settings-heading { margin-bottom: 24px; }
.settings-card { padding: 26px; }
.field { margin-bottom: 20px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 650;
}
.settings-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  width: fit-content;
  cursor: pointer;
}
.settings-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--primary);
}
.hint {
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 11px;
}
.input-action { position: relative; }
.input-action input { padding-right: 72px; }
.input-button {
  position: absolute;
  right: 6px;
  top: 6px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.input-button:hover { background: #f3f4f5; color: var(--text); }

.advanced-settings {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 4px 0 20px;
  padding: 0;
}
.advanced-settings summary {
  padding: 14px 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  list-style: none;
}
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary::after { content: '+'; float: right; color: var(--muted-2); font-size: 16px; font-weight: 400; }
.advanced-settings[open] summary::after { content: '−'; }
.advanced-content { padding: 2px 0 2px; }
.advanced-content .field:last-child { margin-bottom: 18px; }

.connection-result { display: none; margin-top: 4px; }
.connection-result.visible { display: block; }

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.42);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary .spinner { border-color: #d9dcdf; border-top-color: #666c72; }
@keyframes spin { to { transform: rotate(360deg); } }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 680px) {
  .topbar-inner,
  .page,
  .settings-page { width: min(100% - 24px, 880px); }
  .page,
  .settings-page { padding-top: 34px; padding-bottom: 48px; }
  .workspace-card,
  .settings-card { padding: 18px; }
  .file-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .file-classification { grid-column: 1 / -1; grid-row: 2; }
  .file-row select { grid-column: auto; grid-row: auto; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-item,
  .summary-item:nth-child(2n),
  .summary-item:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
  .result-header { align-items: flex-start; }
  .result-header .btn { min-width: 112px; }
  .settings-actions { flex-wrap: wrap; justify-content: flex-start; }
  .danger-text { margin-left: 0; width: 100%; text-align: left; }
}

/* revisão e edição incremental */
.review-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.review-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.review-title-row h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.review-count {
  color: var(--muted-2);
  font-size: 11px;
}
.review-empty {
  padding: 12px 0 2px;
  color: var(--success-text);
  font-size: 12px;
}
.issue-list {
  display: grid;
  gap: 7px;
}
.issue-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.issue-badge {
  height: 22px;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f2f3f4;
  color: #666d74;
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.issue-item[data-severity="erro"] .issue-badge {
  background: #fff0ef;
  color: #9d271e;
}
.issue-item[data-severity="divergencia"] .issue-badge,
.issue-item[data-severity="faltante"] .issue-badge {
  background: var(--warning-bg);
  color: var(--warning-text);
}
.issue-copy strong {
  display: block;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}
.issue-copy p {
  margin: 3px 0 0;
  color: #60676e;
  font-size: 11.5px;
  line-height: 1.48;
}
.issue-evidence {
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.45;
}
.adjust-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.adjust-block > label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 650;
}
.adjust-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.adjust-row input { height: 42px; }
.adjust-status {
  min-height: 18px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}
.adjust-status.error { color: var(--danger); }
.adjust-status.success { color: var(--success-text); }

@media (max-width: 680px) {
  .adjust-row { grid-template-columns: 1fr; }
  .adjust-row .btn { width: 100%; }
}

/* tipos de minuta e regras internas */
textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea:focus {
  border-color: #769b8f;
  box-shadow: 0 0 0 3px rgba(31,92,77,.08);
}
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-label-row label { margin-bottom: 7px; }
.char-count {
  margin-bottom: 7px;
  color: var(--muted-2);
  font-size: 10px;
}

.document-type-field {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.document-type-field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
.document-type-field select {
  height: 44px;
  font-weight: 600;
}
.document-type-field small {
  display: block;
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 10.5px;
}
.documents-heading { margin-bottom: 14px; }

.compact-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 12px;
}
.compact-heading .overline { margin-bottom: 4px; }
.settings-template-list {
  display: grid;
  gap: 0;
}
.settings-template-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.settings-template-copy {
  min-width: 0;
}
.settings-template-copy strong,
.settings-template-copy small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.settings-template-copy strong {
  font-size: 12.5px;
  font-weight: 650;
}
.settings-template-copy small {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 10.5px;
}
.template-chip {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f1f3f3;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.template-delete {
  flex: 0 0 auto;
  margin-left: 0;
}
.template-add {
  margin-top: 18px;
}
.template-add > input[type="text"] {
  margin-bottom: 9px;
}
.template-add-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-picker {
  flex: 0 0 auto;
}
.picked-file {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted-2);
  font-size: 10.5px;
}
.template-message {
  min-height: 17px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}
.template-message.success { color: var(--success-text); }
.template-message.error { color: var(--danger); }

.summary-grid {
  border: 0;
  border-radius: 0;
  overflow: visible;
  gap: 8px;
}
.summary-item,
.summary-item:nth-child(2n),
.summary-item:nth-last-child(-n+2) {
  border: 1px solid var(--line);
  border-radius: 10px;
}

@media (max-width: 680px) {
  .template-add-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }
  .picked-file {
    order: 3;
    flex-basis: 100%;
  }
  .template-add-actions .btn {
    flex: 1 1 auto;
  }
  .summary-item,
  .summary-item:nth-child(2n),
  .summary-item:nth-last-child(-n+2),
  .summary-item:last-child {
    border: 1px solid var(--line);
  }
}

/* rastreabilidade e regras por minuta */
.settings-template-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-template-actions .danger-text { margin-left: 0; }
.template-rules-button { color: #59616a; }
.template-rules-button:hover { color: var(--primary); }

.template-rules-editor {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfb;
}
.template-rules-editor[hidden] { display: none; }
.template-rules-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.template-rules-editor-head span,
.template-rules-editor-head strong { display: block; }
.template-rules-editor-head span {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .055em;
}
.template-rules-editor-head strong {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 650;
}
.template-rules-editor .field-label-row label {
  margin: 0 0 7px;
  font-size: 12px;
  font-weight: 650;
}
.template-rules-editor textarea {
  min-height: 92px;
  background: #fff;
}
.template-rules-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.evidence-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.evidence-block[hidden] { display: none; }
.evidence-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.evidence-block > summary::-webkit-details-marker { display: none; }
.evidence-block > summary::after {
  content: '+';
  margin-left: 8px;
  color: var(--muted-2);
  font-size: 16px;
  font-weight: 400;
}
.evidence-block[open] > summary::after { content: '−'; }
.evidence-block > summary .review-count {
  margin-left: auto;
  font-weight: 500;
}
.evidence-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.evidence-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.evidence-field-head {
  display: grid;
  grid-template-columns: minmax(120px, .42fr) minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}
.evidence-field-head strong {
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
}
.evidence-field-head span {
  min-width: 0;
  color: #5f666d;
  font-size: 11px;
  line-height: 1.45;
}
.evidence-sources {
  display: grid;
  gap: 6px;
  margin-top: 9px;
}
.evidence-source {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: #f6f7f7;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.evidence-source:hover { background: #f0f3f2; }
.evidence-source span,
.evidence-source small { display: block; }
.evidence-source span {
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 650;
}
.evidence-source small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

@media (max-width: 680px) {
  .settings-template-row { align-items: flex-start; }
  .settings-template-actions { gap: 9px; }
  .evidence-field-head { grid-template-columns: 1fr; gap: 4px; }
  .template-rules-actions .btn { width: 100%; }
}

/* base de conhecimento */
.settings-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.settings-link-row h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.settings-link-copy {
  margin: 6px 0 0;
  max-width: 460px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.knowledge-page { width: min(760px, calc(100% - 40px)); }
.knowledge-upload-card { margin-bottom: 14px; }
.knowledge-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.knowledge-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.knowledge-status {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 10.5px;
  white-space: nowrap;
}
.knowledge-status.success { color: var(--success-text); }
.knowledge-status.error { color: var(--danger); }
.knowledge-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.knowledge-queue { display: grid; gap: 6px; margin-top: 12px; }
.knowledge-queue:empty { display: none; }
.knowledge-queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
.knowledge-queue-row span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11.5px;
  font-weight: 600;
}
.knowledge-queue-row small { flex: 0 0 auto; color: var(--muted-2); font-size: 10px; }
.knowledge-queue-row[data-state="success"] small { color: var(--success-text); }
.knowledge-queue-row[data-state="error"] small { color: var(--danger); max-width: 48%; text-align: right; white-space: normal; }
.knowledge-text-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.knowledge-text-form > input { margin-bottom: 8px; }
.knowledge-text-form textarea { min-height: 150px; }
.knowledge-text-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 9px;
}
.knowledge-library-card { padding-top: 22px; }
.knowledge-library-heading { margin-bottom: 4px; }
.knowledge-list { display: grid; }
.knowledge-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.knowledge-row:last-child { border-bottom: 0; }
.knowledge-row-copy { min-width: 0; }
.knowledge-row-copy strong,
.knowledge-row-copy small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.knowledge-row-copy strong { font-size: 12.5px; font-weight: 650; }
.knowledge-row-copy small { margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.knowledge-row-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.knowledge-ready {
  padding: 4px 7px;
  border-radius: 999px;
  background: #edf5f1;
  color: var(--success-text);
  font-size: 9px;
  font-weight: 700;
}
.knowledge-delete { margin-left: 0; }
.knowledge-empty {
  padding: 18px 0 4px;
  color: var(--muted-2);
  font-size: 11.5px;
}

@media (max-width: 680px) {
  .settings-link-row,
  .knowledge-intro { align-items: flex-start; flex-direction: column; }
  .settings-link-row .btn { width: 100%; }
  .knowledge-actions { align-items: stretch; flex-direction: column; }
  .knowledge-actions .btn { width: 100%; }
  .knowledge-status { white-space: normal; }
  .knowledge-row { align-items: flex-start; }
  .knowledge-row-actions { flex-direction: column; align-items: flex-end; gap: 6px; }
}
.knowledge-text-form[hidden],
.knowledge-empty[hidden] { display: none; }


.performance-summary {
  margin: 10px 0 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
