/* ── 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;
}
.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 Sticky Background Badge ────────────────────────── */

.fm-ai-analyse-sticky {
    position: fixed;
    bottom: 24px; right: 24px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 100500;
    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-sticky--running {
    background: #1565c0; color: #fff;
}
.fm-ai-analyse-sticky--done {
    background: #2e7d32; color: #fff;
    cursor: pointer;
}
.fm-ai-analyse-sticky--done:hover { background: #1b5e20; }
.fm-ai-analyse-sticky--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]) ───────────────────────────────── */

.midas-kb-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.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; }

.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; }
.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;
}

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

/* KB Document List (Admin-Panel) */
.midas-kb-toolbar { display: flex; 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 {
    padding: 6px 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; }
.midas-kb-load-more-wrap { text-align: center; margin-top: 12px; }

/* View Toggle (Flat / Grouped) */
.midas-kb-header-controls { display: flex; align-items: center; gap: 8px; }
.midas-kb-view-toggle { display: flex; gap: 2px; }
.midas-kb-view-btn {
    padding: 4px 6px; border: 1px solid #ccc; background: #fff; cursor: pointer;
    border-radius: 3px; color: #888; line-height: 1;
}
.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; }

/* Tag-Group (grouped view) */
.midas-kb-tag-group { margin-bottom: 4px; border: 1px solid #e8e8e8; border-radius: 6px; overflow: hidden; }
.midas-kb-tag-group-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: #f9f9f9; cursor: pointer;
    font-size: 13px; user-select: none;
}
.midas-kb-tag-group-header:hover { background: #f0f4f8; }
.midas-kb-group-arrow { font-size: 14px; width: 14px; height: 14px; color: #888; transition: transform .2s; }
.midas-kb-group-collapsed .midas-kb-group-arrow { transform: rotate(-90deg); }
.midas-kb-group-collapsed .midas-kb-tag-group-body { display: none; }
.midas-kb-group-chip { font-size: 13px !important; padding: 2px 10px !important; }
.midas-kb-group-count { color: #999; font-size: 12px; }
.midas-kb-group-notag { color: #999; font-style: italic; }
.midas-kb-doctable-grouped { border-top: 1px solid #e8e8e8; }
.midas-kb-doctable-grouped td:first-child { padding-left: 16px; }
.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;
}
