#knowledge .panel > p {color:#64748b;margin:12px 0 20px}
#knowledge [hidden] {display:none!important}
.kb-tools {display:flex;align-items:end;gap:12px;margin:20px 0}.kb-tools label{flex:1;font-weight:600}
#knowledge input:not([type=file]),#knowledge textarea,#knowledge select{display:block;width:100%;box-sizing:border-box;padding:12px;border:1px solid #cbd5e1;border-radius:8px;font:inherit;background:#fff;color:#0f172a;margin-top:6px}
#knowledge button:not(.btn-new-ticket){font:inherit;border:1px solid #cbd5e1;background:#fff;color:#334155;border-radius:8px;padding:9px 13px;cursor:pointer}
#knowledge button:disabled{opacity:.6;cursor:wait}#knowledge :focus-visible{outline:3px solid #3b82f6;outline-offset:3px}

/* Lista em uma única coluna. O conteúdo completo fica no modal de visualização. */
.kb-list{display:flex;flex-direction:column;gap:10px;width:100%}
.kb-row{border:1px solid #e2e8f0;border-radius:12px;background:#fff;min-width:0;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease,transform .2s ease}
.kb-row:hover{border-color:#93c5fd;box-shadow:0 8px 24px rgba(15,23,42,.08);transform:translateY(-1px)}
#knowledge .kb-title-button{width:100%;min-height:72px;border:0;border-radius:0;padding:14px 16px;display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;align-items:center;gap:14px;text-align:left;background:#fff;color:#0f172a}
#knowledge .kb-title-button:hover{background:#f8fafc}
.kb-row-icon{display:grid;place-items:center;width:42px;height:42px;border-radius:10px;background:#eff6ff;font-size:1.25rem}
.kb-row-main{display:flex;flex-direction:column;gap:6px;min-width:0}.kb-row-main strong{font-size:1rem;line-height:1.35;overflow-wrap:anywhere}.kb-row-main small{color:#64748b;font-size:.84rem;line-height:1.35;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.kb-department-badge{display:inline-flex;align-items:center;width:max-content;max-width:100%;padding:3px 8px;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:.76rem;font-weight:700;line-height:1.35;overflow-wrap:anywhere}.kb-department-badge-large{font-size:.9rem;padding:6px 11px}.kb-department-help{margin-top:7px!important;margin-bottom:0!important}
.kb-row-count{color:#475569;font-size:.84rem;white-space:nowrap}.kb-row-arrow{font-size:1.7rem;line-height:1;color:#94a3b8}

.kb-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px;margin-top:20px}
.kb-dialog{border:0;border-radius:16px;width:min(640px,calc(100vw - 32px));max-height:90vh;padding:24px;color:#0f172a;background:#fff;box-sizing:border-box;box-shadow:0 24px 80px #0f172a40}
.kb-dialog::backdrop{background:#0f172a99}.kb-dialog fieldset{border:0;margin:0;padding:0;min-width:0}.kb-dialog-header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:20px}.kb-dialog-header h2{margin:0;font-size:1.35rem}.kb-dialog label{display:block;font-weight:600;margin-top:16px}.kb-dialog input[type=file]{max-width:100%;margin-top:10px;font:inherit}.kb-help{font-size:.875rem;color:#64748b;line-height:1.5}.kb-kept{display:flex;gap:12px;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #e2e8f0}.kb-kept span{overflow-wrap:anywhere;min-width:0}#kbFormStatus{line-height:1.5;color:#334155}#kbStatus{line-height:1.5}

/* Modal de consulta do conhecimento. */
.kb-view-dialog{width:min(900px,calc(100vw - 32px))}
.kb-view-content{display:grid;gap:22px}
.kb-view-section{border-top:1px solid #e2e8f0;padding-top:18px}.kb-view-section:first-child{border-top:0;padding-top:0}
.kb-view-section h3{margin:0 0 10px;font-size:.95rem;color:#475569;text-transform:uppercase;letter-spacing:.03em}
.kb-view-description{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.65;color:#1e293b}
.kb-view-link{display:inline-flex;max-width:100%;overflow-wrap:anywhere;word-break:break-word;color:#1d4ed8;font-weight:650;text-decoration:none}.kb-view-link:hover{text-decoration:underline}
.kb-view-attachments{display:grid;gap:14px}.kb-empty-attachments{margin:0;color:#64748b}
.kb-view-file{border:1px solid #e2e8f0;border-radius:12px;overflow:hidden;background:#f8fafc}
.kb-view-file-header{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:13px 14px;background:#fff;border-bottom:1px solid #e2e8f0}.kb-view-file-header>div{min-width:0;display:flex;flex-direction:column;gap:3px}.kb-view-file-header strong{overflow-wrap:anywhere}.kb-view-file-header small{color:#64748b}
.kb-open-file{flex:0 0 auto;color:#1d4ed8;font-weight:600;text-decoration:none;font-size:.9rem}.kb-open-file:hover{text-decoration:underline}
.kb-file-loading{margin:0;padding:18px;color:#64748b}
.kb-image-preview{display:block;max-width:100%;width:auto;max-height:560px;margin:0 auto;object-fit:contain;background:#fff}
.kb-pdf-preview{display:block;width:100%;height:min(65vh,620px);border:0;background:#fff}
#knowledge .kb-danger{color:#b91c1c;border-color:#fecaca;background:#fff7f7}#knowledge .kb-danger:hover{background:#fee2e2}

/* Isola os controles da base das regras globais de largura/margem do DinaDesk. */
#knowledge button {
    width: auto;
    margin: 0;
    flex: 0 0 auto;
    min-height: 44px;
    white-space: normal;
}
#knowledge .kb-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 260px) auto;
    align-items: end;
}
#knowledge .kb-tools label { min-width: 0; margin: 0; }
#knowledge .kb-filter-label select { min-height:46px; }
#knowledge #kbReload { min-width: 110px; height: 46px; }
#knowledge .kb-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(720px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    overscroll-behavior: contain;
}
#knowledge .kb-view-dialog { width: min(900px, calc(100vw - 32px)); }
#knowledge .kb-dialog-header h2 { flex: 1; min-width: 0; overflow-wrap:anywhere; }
#knowledge #kbClose,#knowledge #kbViewClose {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    flex: 0 0 44px;
}
#knowledge .kb-dialog textarea { resize: vertical; min-height: 110px; }
#knowledge .kb-dialog input[type=file] { width: 100%; min-width: 0; }
#knowledge .kb-dialog .kb-actions {
    position: sticky;
    bottom: -24px;
    z-index: 2;
    padding: 16px 0 24px;
    margin-top: 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}
#knowledge .kb-actions button { justify-content: center; }
#knowledge #kbStatus:empty, #knowledge #kbFormStatus:empty { display: none; }

@media(max-width:600px){
    #knowledge .panel-header{align-items:stretch;flex-direction:column;gap:12px}
    #knowledge .kb-tools{grid-template-columns:minmax(0,1fr);align-items:stretch}
    #knowledge #kbReload{justify-self:end}
    #knowledge .kb-title-button{grid-template-columns:auto minmax(0,1fr) auto;gap:10px;padding:12px}
    .kb-row-count{display:none}.kb-row-icon{width:38px;height:38px}.kb-row-arrow{font-size:1.5rem}
    #knowledge .kb-dialog{padding:18px}
    #knowledge .kb-dialog .kb-actions{bottom:-18px;padding-bottom:18px}
    #knowledge .kb-dialog .kb-actions button{flex:1 1 140px}
    #knowledge .kb-dialog-header{gap:10px}.kb-dialog-header h2{font-size:1.2rem}
    .kb-view-file-header{align-items:flex-start;flex-direction:column}.kb-open-file{width:100%}
    .kb-pdf-preview{height:55vh}
}
