/* ── AI Enrichment Upload Dialog ────────────────────────────────── */

.fm-ai-enrich-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100100;
    display: flex; align-items: center; justify-content: center;
}
.fm-ai-enrich-dialog {
    background: #fff;
    border-radius: 8px;
    width: 520px; max-width: 95vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    overflow: hidden;
}

/* AI Research Agent (ADR-010) — Antworten sind Fliesstext/Markdown (Überschriften,
   Listen, Tabellen), nicht der kompakte Upload-Dialog, für den .fm-ai-enrich-dialog
   ursprünglich gebaut wurde. Ohne diese Regel wächst der Dialog unbegrenzt in der
   Höhe — bei langen Antworten liegen die ersten Zeilen dann oberhalb des Viewports
   und sind nicht erreichbar, weil der Overlay selbst nicht scrollt. Breiter +
   Höhe aufs Viewport begrenzt + nur der Body scrollt (Header/Footer bleiben fix). */
.fm-ai-agent-dialog {
    width: min(900px, 92vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.fm-ai-agent-dialog .fm-ai-enrich-body {
    flex: 1 1 auto;
    overflow-y: auto;
}
/* Portfolio-Matrix (ADR-013): eine Spalte je Arbeitsgruppe — bei fünf Betrieben
   wird die Tabelle breiter als der Dialog, deshalb seitlich scrollbar statt
   umbrechend. Die Kriterien-Spalte bleibt dabei stehen. */
.fm-ai-agent-matrix-wrap { overflow-x: auto; margin-bottom: 14px; }
.fm-ai-agent-matrix td, .fm-ai-agent-matrix th { vertical-align: top; }
.fm-ai-agent-matrix tbody th {
    position: sticky; left: 0; background: #fff; text-align: left;
    text-transform: none; letter-spacing: 0; font-size: 13px;
}
.fm-ai-agent-matrix-missing { color: #999; }
.fm-ai-agent-group-report, .fm-ai-agent-plan { margin: 8px 0; }
.fm-ai-agent-group-report > summary, .fm-ai-agent-plan > summary {
    cursor: pointer; font-weight: 600; padding: 6px 0;
}
.fm-ai-enrich-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}
.fm-ai-enrich-header h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.fm-ai-enrich-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #666; line-height: 1; }
.fm-ai-enrich-body { padding: 20px; }
.fm-ai-enrich-desc { margin: 0 0 12px; color: #555; font-style: italic; }

.fm-ai-enrich-dropzone {
    border: 2px dashed #bbb;
    border-radius: 8px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.fm-ai-enrich-dropzone:hover,
.fm-ai-enrich-dropzone.fm-ai-dragover {
    border-color: #0073aa;
    background: #f0f7fc;
}
.fm-ai-enrich-dropzone .dashicons { font-size: 36px; width: 36px; height: 36px; color: #999; }
.fm-ai-enrich-dropzone p { margin: 8px 0 4px; color: #555; }
.fm-ai-enrich-dropzone small { color: #999; }

.fm-ai-enrich-file-list { margin-top: 12px; }
.fm-ai-file-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
}
.fm-ai-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-ai-file-size { color: #888; font-size: 12px; }
.fm-ai-file-remove { background: none; border: none; color: #c00; cursor: pointer; font-size: 16px; }

.fm-ai-enrich-prompt-wrap { margin-top: 16px; }
.fm-ai-enrich-prompt-wrap label { display: block; margin-bottom: 4px; font-size: 13px; color: #555; }
.fm-ai-enrich-prompt { width: 100%; box-sizing: border-box; }

.fm-ai-enrich-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

/* Progress UI */
.fm-ai-enrich-progress { text-align: center; padding: 20px 0; }
.fm-ai-enrich-spinner .spinner { float: none; margin: 0 auto; }
.fm-ai-enrich-status-text { font-size: 15px; margin: 12px 0 4px; }
.fm-ai-enrich-elapsed { color: #666; }
.fm-ai-enrich-status-detail { color: #888; font-size: 13px; }
.fm-ai-enrich-hint { margin-top: 16px; padding: 10px; background: #f5f5f5; border-radius: 4px; }
.fm-ai-enrich-hint small { color: #666; }

/* Error UI */
.fm-ai-enrich-error { text-align: center; padding: 20px; color: #c00; }
.fm-ai-enrich-error .dashicons { font-size: 32px; width: 32px; height: 32px; }
.fm-ai-enrich-error p { margin-top: 8px; }


/* ── Proposal Reviewer Modal ──────────────────────────────────── */

.fm-proposal-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100200;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.fm-proposal-container {
    background: #fff;
    border-radius: 8px;
    width: 900px; max-width: 98vw;
    max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}

/* Header */
.fm-proposal-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}
.fm-proposal-header-top {
    display: flex; justify-content: space-between; align-items: center;
}
.fm-proposal-header h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.fm-proposal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #666; }
.fm-proposal-summary { margin-top: 8px; color: #555; font-size: 13px; }
.fm-proposal-stats { margin-top: 6px; display: flex; gap: 12px; }
.fm-proposal-stat { font-size: 13px; color: #444; font-weight: 500; }
.fm-proposal-stat-unmatched { color: #e65100; }

/* Stale banner */
.fm-proposal-stale-banner {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: 4px;
    color: #e65100;
    font-size: 13px;
    display: flex; align-items: center; gap: 6px;
}

/* Page tabs */
.fm-proposal-tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 20px;
    background: #fafafa;
    flex-shrink: 0;
    overflow-x: auto;
}
.fm-proposal-tab {
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.fm-proposal-tab:hover { color: #333; }
.fm-proposal-tab.active { color: #0073aa; border-bottom-color: #0073aa; font-weight: 500; }
.fm-proposal-tab-count { font-size: 11px; color: #999; }
.fm-proposal-tab.active .fm-proposal-tab-count { color: #0073aa; }

/* Body (scrollable) */
.fm-proposal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.fm-proposal-page { display: none; }
.fm-proposal-no-changes { color: #999; text-align: center; padding: 40px 0; }

/* ── Change Card ──────────────────────────────────────────────── */

.fm-proposal-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}
.fm-proposal-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.fm-proposal-decided.fm-proposal-accepted { border-color: #4caf50; background: #f1f8e9; }
.fm-proposal-decided.fm-proposal-rejected { border-color: #e0e0e0; background: #fafafa; opacity: 0.7; }
.fm-proposal-decided.fm-proposal-userEdit { border-color: #2196f3; background: #e3f2fd; }

.fm-proposal-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
}
.fm-proposal-field-label { font-weight: 600; font-size: 14px; }
.fm-proposal-action-type {
    font-size: 11px; padding: 2px 8px;
    background: #e0e0e0; border-radius: 3px; color: #555;
    text-transform: uppercase; font-weight: 500;
}

.fm-proposal-card-body { padding: 12px 14px; }

.fm-proposal-row {
    display: flex; gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.5;
}
.fm-proposal-label { font-weight: 500; color: #666; min-width: 100px; flex-shrink: 0; }
.fm-proposal-value { flex: 1; word-break: break-word; }
.fm-proposal-current { color: #555; }
.fm-proposal-proposed { color: #1565c0; font-weight: 500; }
.fm-proposal-edited-val { color: #2e7d32; font-weight: 500; }
.fm-proposal-empty { color: #bbb; }
.fm-proposal-expand-link,
.fm-proposal-collapse-link {
    font-size: 11px;
    color: #0073aa;
    text-decoration: none;
    cursor: pointer;
}
.fm-proposal-expand-link:hover,
.fm-proposal-collapse-link:hover { text-decoration: underline; }
.fm-proposal-number { color: #5d4037; }
.fm-proposal-array, .fm-proposal-object { color: #7b1fa2; cursor: pointer; }

.fm-proposal-json-preview {
    display: none;
    margin: 4px 0 0;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 11px;
    max-height: 150px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.fm-proposal-array:hover + .fm-proposal-json-preview,
.fm-proposal-object:hover + .fm-proposal-json-preview,
.fm-proposal-json-preview:hover { display: block; }

/* Metadata */
.fm-proposal-meta { font-size: 12px; color: #777; margin-top: 4px; }
.fm-proposal-meta-label { font-weight: 500; color: #555; }
.fm-proposal-evidence { font-style: italic; }
.fm-proposal-reasoning { margin-top: 4px; color: #666; }

/* Confidence bar */
.fm-proposal-confidence {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}
.fm-proposal-conf-bar {
    flex: 0 0 100px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}
.fm-proposal-conf-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .3s;
}
.fm-proposal-conf-high { background: #4caf50; }
.fm-proposal-conf-medium { background: #ffc107; }
.fm-proposal-conf-low { background: #bdbdbd; }
.fm-proposal-conf-value { font-weight: 500; color: #444; }

/* Array conflict */
.fm-proposal-array-conflict {
    margin-top: 8px;
    padding: 8px 10px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    font-size: 12px;
    color: #f57f17;
}
.fm-proposal-array-options { margin-top: 6px; }
.fm-proposal-array-options label { display: block; margin: 4px 0; color: #333; font-size: 12px; cursor: pointer; }

/* Inline editor */
.fm-proposal-editor {
    margin-top: 8px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
}
.fm-proposal-edit-input {
    width: 100%; box-sizing: border-box;
    font-family: monospace; font-size: 12px;
    margin-bottom: 4px;
}
.fm-proposal-edit-save,
.fm-proposal-edit-cancel {
    padding: 2px 10px;
    font-size: 11px;
    line-height: 1.5;
    min-height: 0;
    height: auto;
}

/* Decision buttons */
.fm-proposal-card-actions {
    display: flex; gap: 4px;
    padding: 6px 14px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
.fm-proposal-btn {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    line-height: 1.4;
    transition: background .15s, border-color .15s;
}
.fm-proposal-btn:hover { background: #f0f0f0; }
.fm-proposal-btn .dashicons { font-size: 14px; width: 14px; height: 14px; }

.fm-proposal-btn-accept.active { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.fm-proposal-btn-reject.active { background: #fce4ec; border-color: #e57373; color: #c62828; }
.fm-proposal-btn-edit.active { background: #e3f2fd; border-color: #42a5f5; color: #1565c0; }


/* ── Unmatched Section ────────────────────────────────────────── */

.fm-proposal-unmatched-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px solid #e0e0e0;
}
.fm-proposal-unmatched-section h4 {
    margin: 0 0 12px;
    font-size: 14px;
    display: flex; align-items: center; gap: 6px;
    color: #e65100;
}
.fm-proposal-unmatched-item {
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}
.fm-proposal-unmatched-desc { margin: 0 0 2px; }
.fm-proposal-unmatched-loc { color: #888; display: block; margin-bottom: 4px; }
.fm-proposal-copy-btn {
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.4;
    min-height: 0;
    height: auto;
    vertical-align: middle;
}
.fm-proposal-copy-btn .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
    vertical-align: middle;
    margin-right: 2px;
}


/* ── Footer (sticky) ─────────────────────────────────────────── */

.fm-proposal-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}
.fm-proposal-footer-counts { font-size: 12px; color: #555; }
.fm-proposal-footer-counts span { font-weight: 600; }
.fm-proposal-footer-actions { display: flex; gap: 6px; }
.fm-proposal-footer-actions .button {
    padding: 3px 12px;
    font-size: 12px;
    line-height: 1.5;
    min-height: 0;
    height: auto;
}


/* ── Notification Toast ──────────────────────────────────────── */

.fm-proposal-notification {
    position: fixed;
    bottom: 20px; right: 20px;
    padding: 12px 20px;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    z-index: 100300;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
}


/* ── Orphan Discovery Badge ──────────────────────────────────── */

.fm-ai-proposal-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    margin: 6px 0 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.fm-ai-badge-ready {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    color: #2e7d32;
}
.fm-ai-badge-running {
    background: #e3f2fd;
    border: 1px solid #42a5f5;
    color: #1565c0;
}
.fm-ai-badge-failed {
    background: #fce4ec;
    border: 1px solid #e57373;
    color: #c62828;
}
.fm-ai-proposal-badge .dashicons { font-size: 16px; width: 16px; height: 16px; }


/* ── AI Analyse Result Overlay ───────────────────────────────── */

.fm-ai-analyse-result-overlay {
    position: fixed; inset: 0;
    background: #fff;
    z-index: 100400;
    display: flex; flex-direction: column;
}
.fm-ai-analyse-result-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px;
    background: #1565c0;
    color: #fff;
    flex-shrink: 0;
}
.fm-ai-analyse-result-title {
    font-size: 15px; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.fm-ai-analyse-result-title .dashicons { font-size: 18px; width: 18px; height: 18px; }
.fm-ai-analyse-result-actions { display: flex; gap: 8px; align-items: center; }
.fm-ai-analyse-result-actions .button {
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
    padding: 4px 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.fm-ai-analyse-result-actions .button .dashicons {
    font-size: 15px; width: 15px; height: 15px;
    display: inline-flex; align-items: center;
}
/* All buttons on blue header: white outline style */
.fm-ai-analyse-result-actions .button {
    background: transparent;
    color: #fff;
    border-color: rgba(255,255,255,0.55);
}
.fm-ai-analyse-result-actions .button:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: rgba(255,255,255,0.9);
}
/* Primary (Magic Link, Print) — solid white */
.fm-ai-analyse-result-actions .button-primary {
    background: #fff; color: #1565c0; border-color: #fff;
}
.fm-ai-analyse-result-actions .button-primary:hover { background: #e3f2fd; color: #0d47a1; }
.fm-ai-analyse-result-actions .button.active {
    background: rgba(255,255,255,0.25); border-color: #fff; color: #fff;
}

/* Inline notice bar below the header */
.fm-ai-overlay-notice {
    flex-shrink: 0;
}
.fm-ai-overlay-notice .dashicons {
    font-size: 16px; width: 16px; height: 16px;
    vertical-align: middle;
}
.fm-ai-analyse-edit-hint {
    background: #e3f2fd;
    border-bottom: 1px solid #90caf9;
    padding: 6px 20px;
    font-size: 12px;
    color: #1565c0;
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.fm-ai-analyse-result-body { flex: 1; overflow: hidden; }

/* ── Analyse Status Panel (multi-job, survives backgrounding) ───────── */
/* Replaces the old single ".fm-ai-analyse-sticky" badge, which silently
 * overwrote itself when a second job finished before the first was opened. */

.fm-ai-analyse-panel {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 100500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}
.fm-ai-analyse-row {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex; align-items: center;
    animation: fm-sticky-slide-in .25s ease;
}
@keyframes fm-sticky-slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.fm-ai-analyse-row--running {
    background: #1565c0; color: #fff;
}
.fm-ai-analyse-row--done {
    background: #2e7d32; color: #fff;
    cursor: pointer;
}
.fm-ai-analyse-row--done:hover { background: #1b5e20; }
.fm-ai-analyse-row--error {
    background: #c62828; color: #fff;
}

/* Warning in analyse prompt modal */
.fm-ai-enrich-warn {
    padding: 8px 12px;
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: 4px;
    color: #e65100;
    font-size: 13px;
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}

/* ── Knowledge-Base RAG ([midas_kb]) ───────────────────────────────── */

/* Block, nicht flex: der Wrap enthält Toolbar UND Dokumentenliste untereinander.
   Als Zeilen-Flex standen beide nebeneinander und `align-items: stretch` zog die
   Toolbar auf Tabellenhöhe — sichtbar sobald die Liste schmal genug war, um nicht
   mehr umzubrechen (z.B. „Keine Treffer"). Die Knopfreihe macht .midas-kb-toolbar. */
.midas-kb-wrap { display: block; }
.midas-kb-error { color: #c00; }

.fm-kb-query-dialog.fm-ai-enrich-dialog {
    width: 860px !important;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.fm-kb-query-dialog .fm-ai-enrich-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Tag-Chip-Eingabe (geteilt zwischen Upload- und Query-Dialog) */
.fm-kb-tag-field { margin-top: 16px; position: relative; }
.fm-kb-tag-field label { display: block; margin-bottom: 4px; font-size: 13px; color: #555; }
.fm-kb-tag-input-wrap {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    border: 1px solid #ccc; border-radius: 4px;
    padding: 6px 8px;
    background: #fff;
}
.fm-kb-tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fm-kb-tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #e3f2fd; color: #0d47a1;
    border-radius: 12px;
    padding: 2px 8px 2px 10px;
    font-size: 12px;
}
.fm-kb-tag-remove {
    background: none; border: none; cursor: pointer;
    color: #0d47a1; font-size: 14px; line-height: 1; padding: 0;
}
.fm-kb-tag-text {
    flex: 1; min-width: 120px;
    border: none; outline: none;
    font-size: 13px; padding: 4px 2px;
}
.fm-kb-tag-suggestions {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #ccc; border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 10;
    max-height: 160px; overflow-y: auto;
}
.fm-kb-tag-suggestion { padding: 6px 10px; font-size: 13px; cursor: pointer; }
.fm-kb-tag-suggestion:hover { background: #f0f7fc; }

.fm-kb-skip-answer-label {
    display: block; margin-top: 14px;
    font-size: 12px; color: #666;
    display: flex; align-items: flex-start; gap: 6px;
}

/* Ergebnis-Panel */
.fm-kb-result { margin-top: 18px; border-top: 1px solid #e0e0e0; padding-top: 14px; }
.fm-kb-answer-toolbar {
    display: flex; gap: 6px; margin-bottom: 10px;
}
.fm-kb-answer-toolbar .button { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.fm-kb-answer-toolbar .dashicons { font-size: 14px; width: 14px; height: 14px; }
/* KB Answer — self-contained typography (same approach as clause-library-v2) */
.fm-kb-answer {
    font-family: Arial, sans-serif !important;
    font-size: 10pt !important;
    line-height: 1.6 !important;
    color: #222 !important;
}
.fm-kb-answer h1 { font-size: 14pt !important; font-weight: 700 !important; margin: 14pt 0 6pt !important; }
.fm-kb-answer h2 { font-size: 12pt !important; font-weight: 700 !important; margin: 12pt 0 5pt !important; }
.fm-kb-answer h3 { font-size: 11pt !important; font-weight: 600 !important; margin: 10pt 0 4pt !important; }
.fm-kb-answer h4 { font-size: 10pt !important; font-weight: 600 !important; margin: 8pt 0 4pt !important; }
.fm-kb-answer p { margin: 0 0 6pt !important; }
.fm-kb-answer ul, .fm-kb-answer ol { margin: 6pt 0 !important; padding-left: 20pt !important; }
.fm-kb-answer li { margin: 3pt 0 !important; }
.fm-kb-answer strong, .fm-kb-answer b { font-weight: 700 !important; }
.fm-kb-answer table { width: 100%; border-collapse: collapse; margin: 8pt 0; }
.fm-kb-answer th, .fm-kb-answer td { border: 1px solid #ccc; padding: 4pt 8pt; text-align: left; font-size: 9pt; }
.fm-kb-answer th { background: #f5f5f5; font-weight: 600; }
.fm-kb-answer blockquote { border-left: 3px solid #ccc; margin: 8pt 0; padding: 2pt 12pt; color: #555; }
.fm-kb-answer code { background: #f4f4f4; padding: 1px 4px; border-radius: 3px; font-size: 0.9em; font-family: 'SFMono-Regular', Consolas, monospace; }
.fm-kb-answer pre { background: #f8f9fa; padding: 10pt; border-radius: 4px; overflow-x: auto; }
.fm-kb-answer pre code { background: none; padding: 0; }
.fm-kb-no-answer { color: #666; }
.fm-kb-citation {
    display: inline-block;
    background: #e3f2fd; color: #0d47a1;
    border-radius: 3px; padding: 0 4px;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
}
.fm-kb-citation:hover { background: #bbdefb; }

/* Agent-Zitat auf einen sources[].locator ("[notes.docx#150]") — trägt Dateiname
   statt nur einer Nummer, deshalb schmalere Schrift, damit es im Fliesstext nicht
   dominiert. */
.fm-kb-citation-locator {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 11px; font-weight: 500;
}
/* [S#] in einer Agent-Antwort: bewusst KEIN Sprungziel (Nummer wird pro Suchlauf
   neu vergeben) — darf also auch nicht klickbar aussehen. Tooltip erklärt es. */
.fm-kb-citation-inert {
    background: #f0f0f0; color: #777;
    cursor: help; font-weight: 500;
}
.fm-kb-citation-inert:hover { background: #f0f0f0; }

.fm-ai-agent-artifacts { margin-top: 16px; }
.fm-ai-agent-artifact-block { margin-bottom: 10px; }
.fm-ai-agent-artifact-toggle { font-size: 13px; font-weight: 600; }
.fm-ai-agent-artifact-body { margin-top: 8px; }
.fm-ai-agent-artifact-card {
    border: 1px solid #e0e0e0; border-radius: 6px;
    padding: 10px 12px; margin-bottom: 8px;
    background: #fafafa;
}
.fm-ai-agent-artifact-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fm-ai-agent-artifact-type { font-size: 11px; color: #666; background: #eee; border-radius: 3px; padding: 1px 6px; }
.fm-ai-agent-artifact-pre {
    background: #f8f9fa; padding: 8px; border-radius: 4px;
    overflow-x: auto; font-size: 11px; margin: 0;
}

.fm-kb-sources { margin-top: 16px; }
.fm-kb-sources h4 { margin: 0 0 8px; font-size: 13px; color: #555; text-transform: uppercase; letter-spacing: .03em; }

/* Belege vs. bloss Geprüftes (90V). examinedCount steht bewusst unbetont
   neben der Überschrift — es ist eine Aufwandszahl, keine Belegzahl. */
.fm-kb-sources-examined { text-transform: none; letter-spacing: 0; color: #767676; font-weight: 400; }
.fm-kb-sources-none { margin: 0 0 8px; color: #767676; font-style: italic; font-size: 12px; }
.fm-kb-sources-rest { margin-top: 10px; }
.fm-kb-sources-rest > summary {
    cursor: pointer;
    font-size: 12px;
    color: #555;
    padding: 6px 8px;
    background: #f3f4f5;
    border-radius: 4px;
    user-select: none;
}
.fm-kb-sources-rest > summary:hover { background: #e9eaec; }
.fm-kb-sources-rest[open] > summary { margin-bottom: 8px; }

/* ── Bewertung einer Agent-Antwort (AP2, 90V) ─────────────── */
.fm-ai-feedback {
    margin-top: 16px;
    padding: 10px 12px;
    background: #f7f7f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
}
.fm-ai-feedback-label { color: #555; margin-right: 8px; }
.fm-ai-feedback-stars { display: inline-block; vertical-align: middle; }
.fm-ai-feedback-star {
    background: none;
    border: none;
    padding: 0 2px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #c9ccd0;
}
.fm-ai-feedback-star.is-on { color: #f0a318; }
.fm-ai-feedback-star:focus { outline: 1px dotted #1565c0; }
.fm-ai-feedback-status { margin-left: 10px; color: #2e7d32; font-size: 12px; }
.fm-ai-feedback-status.is-error { color: #c62828; }
.fm-ai-feedback-comment { margin-top: 8px; }
.fm-ai-feedback-text {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 6px;
    font-size: 13px;
}

/* Im Ausdruck ist die Bewertungs-Zeile ein Bedienelement ohne Aussage. */
@media print {
    .fm-ai-feedback { display: none; }
}
.fm-kb-source-card {
    border: 1px solid #e0e0e0; border-radius: 6px;
    padding: 10px 12px; margin-bottom: 8px;
    background: #fafafa;
    transition: background .3s, border-color .3s;
}
.fm-kb-source-highlight { background: #fff8e1; border-color: #ffb74d; }
.fm-kb-source-head { font-size: 13px; color: #222; }
.fm-kb-source-meta { color: #888; font-weight: 400; }
.fm-kb-source-snippet {
    margin-top: 6px; font-size: 12px; color: #555;
    white-space: pre-wrap;
}
.fm-kb-source-tags {
    margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px;
}

/* Etikett auf der Quellenkarte, identisch zum Zitat im Antworttext — damit man
   Zitat und Karte auch ohne Klick von Auge zusammenbringt. */
.fm-kb-source-locator {
    background: #e3f2fd; color: #0d47a1;
    border-radius: 3px; padding: 0 4px;
    font-size: 11px; font-family: 'SFMono-Regular', Consolas, monospace;
}

.fm-kb-source-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.fm-kb-source-actions .button { font-size: 11px; display: inline-flex; align-items: center; gap: 3px; }
.fm-kb-source-actions .button .dashicons { font-size: 14px; width: 14px; height: 14px; }

/* Belegte Stelle im Volltext: bewusst scrollbar statt gekürzt — der Chunk ist die
   Passage, auf die sich der Agent beruft, inklusive Einschränkungen im Wortlaut. */
.fm-kb-source-passage {
    margin-top: 8px; padding: 10px 12px;
    background: #fff; border: 1px solid #d6d6d6; border-left: 3px solid #0d47a1;
    border-radius: 4px;
}
.fm-kb-source-passage-hint {
    font-size: 11px; color: #777; font-style: italic; margin-bottom: 6px;
}
.fm-kb-source-passage-hint:last-child { margin-bottom: 0; margin-top: 6px; }
.fm-kb-source-passage-text {
    font-size: 12.5px; line-height: 1.65; color: #222;
    white-space: pre-wrap; word-break: break-word;
    max-height: 340px; overflow-y: auto;
}
.fm-kb-source-passage-loading { font-size: 12px; color: #777; }
.fm-kb-source-passage-error { font-size: 12px; color: #b32d2e; }

.fm-kb-meta { margin-top: 12px; font-size: 11px; color: #999; text-align: right; }

/* KB Document List (Admin-Panel) */
/* align-items: center, nicht der Default stretch — sonst wächst ein Knopf auf die
   Höhe des höchsten Nachbarn, sobald einer dazukommt. */
.midas-kb-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.midas-kb-doclist { margin-top: 4px; }
.midas-kb-doclist-loading { color: #666; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.midas-kb-doclist-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.midas-kb-doclist-header h4 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 6px; color: #333; }
.midas-kb-search {
    height: 34px; box-sizing: border-box;
    padding: 0 10px; border: 1px solid #ccc; border-radius: 4px;
    font-size: 13px; width: 260px; max-width: 100%;
}
.midas-kb-empty { color: #888; font-style: italic; }
.midas-kb-doctable {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.midas-kb-doctable th {
    text-align: left; padding: 8px 10px; background: #f5f5f5;
    border-bottom: 2px solid #ddd; font-weight: 600; color: #444;
    font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
.midas-kb-doctable td {
    padding: 8px 10px; border-bottom: 1px solid #eee; vertical-align: middle;
}
.midas-kb-doctable tr:hover { background: #f9fbfd; }
.midas-kb-doc-title { cursor: pointer; color: #0073aa; }
.midas-kb-doc-title:hover { text-decoration: underline; }
.midas-kb-doc-tags { max-width: 200px; }
.midas-kb-no-tags { color: #ccc; }
.midas-kb-doctable .button { padding: 2px 6px; min-height: 28px; }
.midas-kb-doctable .dashicons { font-size: 16px; width: 16px; height: 16px; vertical-align: middle; }
.midas-kb-doc-delete .dashicons { color: #c00; }
.midas-kb-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.midas-kb-sortable:hover { background: #eee; }
.midas-kb-sort-icon { font-size: 10px; color: #aaa; }
.midas-kb-sort-active { color: #0073aa; }
/* Suchzeile: Feld, Lupe, „Suche zurücksetzen" und Ansichts-Umschalter teilen eine
   Zeilenhöhe. Jedes Element bekommt sie explizit statt über `align-items: stretch`,
   damit ein Umbruch auf schmalen Fenstern nicht in gestreckte Knöpfe umkippt.
   Frontend-Themes stylen `button` gross, deshalb Höhe und Innenabstand mit
   Vorrang — ohne das ist „Suche zurücksetzen" doppelt so hoch wie die Lupe. */
.midas-kb-header-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.midas-kb-search-go,
.midas-kb-search-clear,
.midas-kb-view-btn {
    height: 34px !important; min-height: 0 !important;
    box-sizing: border-box; line-height: 1 !important;
    display: inline-flex; align-items: center;
}
.midas-kb-search-go { padding: 0 10px !important; }
.midas-kb-search-go .dashicons { font-size: 16px; width: 16px; height: 16px; }
.midas-kb-search-clear {
    padding: 0 8px !important; border: none !important; background: none !important;
    box-shadow: none !important; color: #0073aa; font-size: 12px !important;
    cursor: pointer; text-decoration: underline;
}

/* View Toggle (Liste / Tag-Navigation) */
.midas-kb-view-toggle { display: flex; gap: 2px; }
.midas-kb-view-btn {
    padding: 0 8px !important; border: 1px solid #ccc; background: #fff; cursor: pointer;
    border-radius: 3px; color: #888;
}
.midas-kb-view-btn .dashicons { font-size: 16px; width: 16px; height: 16px; }
.midas-kb-view-btn:hover { background: #f0f7fc; color: #0073aa; }
.midas-kb-view-active { background: #0073aa !important; color: #fff !important; border-color: #0073aa; }

/* Als Link gestaltete Knöpfe — `.button-link` ist ausserhalb von wp-admin
   unstyled, das Theme macht daraus sonst einen vollen Knopf. */
.midas-kb-filter-clear,
.midas-kb-tagpanel-more,
.midas-kb-select-none,
.midas-kb-last-report {
    padding: 0 !important; border: none !important; background: none !important;
    box-shadow: none !important; min-height: 0 !important; height: auto !important;
    color: #0073aa; cursor: pointer; text-decoration: underline;
}

/* Ein Nachladen läuft: Tabelle bleibt stehen, wird aber als veraltet markiert */
.midas-kb-doclist-busy { opacity: .5; pointer-events: none; }

/* Aktive Eingrenzung */
.midas-kb-filterbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    margin-bottom: 10px; padding: 8px 10px;
    background: #f0f7fc; border: 1px solid #cde3f0; border-radius: 4px;
}
.midas-kb-filterbar-label { font-size: 12px; color: #555; text-transform: uppercase; letter-spacing: .03em; }
.midas-kb-filter-chip { font-size: 13px !important; }
.midas-kb-filter-clear { margin-left: auto; font-size: 12px; }

/* Tag-Navigation */
.midas-kb-tagpanel {
    margin-bottom: 12px; padding: 10px 12px;
    border: 1px solid #e8e8e8; border-radius: 6px; background: #fcfcfc;
}
.midas-kb-tagpanel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.midas-kb-tagquery {
    padding: 5px 9px; border: 1px solid #ccc; border-radius: 4px;
    font-size: 13px; width: 200px;
}
.midas-kb-tagpanel-meta { font-size: 12px; color: #888; }
.midas-kb-tagpanel-items { display: flex; flex-wrap: wrap; gap: 6px; }
.midas-kb-tagpanel-tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border: 1px solid #cde3f0; border-radius: 12px;
    background: #fff; cursor: pointer; font-size: 13px; color: #0073aa;
}
.midas-kb-tagpanel-tag:hover { background: #0073aa; color: #fff; border-color: #0073aa; }
.midas-kb-tagpanel-tag:hover .midas-kb-tagpanel-count { background: rgba(255,255,255,.25); color: #fff; }
.midas-kb-tagpanel-count {
    padding: 0 6px; border-radius: 8px; background: #eef4f8;
    font-size: 11px; color: #666;
}
.midas-kb-tagpanel-selected { opacity: .45; cursor: default; }
.midas-kb-tagpanel-more { margin-top: 8px; font-size: 12px; }
.midas-kb-tagpanel-truncated { margin: 8px 0 0; font-size: 12px; color: #999; }

/* Blättern */
.midas-kb-pager {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-top: 12px;
}
.midas-kb-pager-info { font-size: 12px; color: #666; }

/* ── Löschen in Grossmengen ─────────────────────────────────────────── */

.midas-kb-doc-select { width: 28px; text-align: center; }
.midas-kb-doc-select input { margin: 0; }

.midas-kb-selectbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    margin-bottom: 8px; padding: 8px 12px;
    background: #f6f7f7; border: 1px solid #dcdcde; border-radius: 4px;
}
.midas-kb-selectbar-count { font-size: 13px; color: #50575e; }
/* Löschen ist der gefährliche Knopf im Balken und muss sich vom Rest abheben,
   ohne die Farbe eines primary-Buttons zu bekommen. */
.midas-kb-selectbar .midas-kb-delete-selected,
.midas-kb-selectbar .midas-kb-delete-all-matching {
    color: #b32d2e; border-color: #b32d2e;
}
.midas-kb-selectbar .midas-kb-delete-all-matching { margin-left: auto; }

.midas-kb-danger p { font-size: 14px; line-height: 1.5; }
.midas-kb-danger-what {
    padding: 8px 12px; background: #fcf0f1; border-left: 3px solid #b32d2e;
    font-size: 13px; color: #50575e;
}
.midas-kb-danger label { display: block; margin-top: 14px; font-size: 13px; }
.midas-kb-confirm-count { width: 120px; margin-top: 4px; }

.midas-kb-report { font-size: 13px; }
.midas-kb-report-summary { font-size: 14px; margin-bottom: 12px; }
.midas-kb-report-note { color: #8a6d3b; font-size: 12px; margin: 6px 0; }
.midas-kb-report-context { color: #50575e; font-size: 13px; margin: -6px 0 12px 0; }
.midas-kb-report-head { margin: 14px 0 6px 0; font-size: 13px; }
.midas-kb-report-details { margin-top: 8px; }
.midas-kb-report-details summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
.midas-kb-report-details ul {
    max-height: 240px; overflow-y: auto; margin: 4px 0 0 0; padding-left: 18px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}

.midas-kb-zip-intro { font-size: 13px; line-height: 1.5; color: #50575e; }
.midas-kb-zip-include {
    display: block; margin-top: 14px; padding: 10px 12px;
    background: #fff3e0; border: 1px solid #ffb74d; border-radius: 4px;
    font-size: 13px; line-height: 1.5;
}
.midas-kb-error { color: #b32d2e; font-size: 13px; }
.fm-kb-duplicate-warning {
    margin-top: 12px; padding: 10px 14px;
    background: #fff3e0; border: 1px solid #ffb74d; border-radius: 4px;
    font-size: 13px; color: #e65100;
}
.fm-kb-duplicate-warning .dashicons { vertical-align: middle; margin-right: 4px; }
.fm-kb-dup-badge {
    display: inline-block; background: #fff3e0; color: #e65100;
    border-radius: 3px; padding: 0 5px; font-size: 10px; font-weight: 600;
    margin-left: 6px;
}
.fm-kb-bulk-job-list { text-align: left; margin-top: 12px; font-size: 13px; }
.fm-kb-bulk-job-row { padding: 3px 0; }

.midas-kb-sticky {
    position: fixed; bottom: 20px; right: 20px; z-index: 100200;
    padding: 12px 20px; border-radius: 8px;
    font-size: 14px; font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    animation: fm-ai-sticky-in 0.3s ease;
}
.midas-kb-sticky--running { background: #1565c0; color: #fff; }
.midas-kb-sticky--done { background: #2e7d32; color: #fff; cursor: pointer; }
.midas-kb-sticky--done:hover { background: #1b5e20; }

/* KB Document Viewer Modal */
.fm-kb-viewer-dialog {
    width: 800px; max-width: 95vw;
    max-height: 90vh;
    display: flex; flex-direction: column;
}
.fm-kb-viewer-body {
    overflow-y: auto; max-height: 70vh;
    padding: 20px !important;
}
.fm-kb-viewer-loading { color: #666; display: flex; align-items: center; gap: 6px; }
.fm-kb-viewer-content { font-size: 13px; line-height: 1.7; color: #333; }
.fm-kb-viewer-pre {
    white-space: pre-wrap; word-wrap: break-word;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px; background: #f8f9fa; padding: 16px; border-radius: 4px;
    border: 1px solid #e9ecef; max-height: none;
}
.fm-kb-viewer-meta { font-size: 11px; color: #888; flex: 1; }

/* Options row (skipAnswer + deepAnalysis toggles) */
.fm-kb-options { margin-top: 14px; }
.fm-kb-option-label {
    display: flex; align-items: flex-start; gap: 6px;
    font-size: 12px; color: #666; margin-bottom: 6px;
}

/* Deep-Analysis: Doc-Karten + [D]-Zitate */
.fm-kb-analyzed-docs { margin-top: 16px; }
.fm-kb-analyzed-docs h4 { margin: 0 0 8px; font-size: 13px; color: #555; text-transform: uppercase; letter-spacing: .03em; }
.fm-kb-doc-card { border-left: 3px solid #1565c0; }
.fm-kb-citation-doc { background: #e8eaf6; color: #283593; }
.fm-kb-citation-doc:hover { background: #c5cae9; }
.fm-kb-truncated-badge {
    display: inline-block;
    background: #fff3e0; color: #e65100;
    border-radius: 3px; padding: 0 5px;
    font-size: 10px; font-weight: 600;
    vertical-align: middle; margin-left: 4px;
}
