/* AI agent studio */
.agent-screen #agent-section{padding:0;max-width:1240px}
#agent-section .panel{padding:18px 20px;margin-bottom:14px}
.studio-bar{display:flex;align-items:end;gap:14px;flex-wrap:wrap}
.studio-bar label{margin:0;flex:1 1 240px;max-width:420px}
.studio-bar select{margin-top:4px}
.studio-bar #add-agent{margin-left:auto}
.agent-tenant-name{align-self:center;color:var(--muted)}
.studio-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:10px;margin:0 0 14px}
.studio-card{display:flex;align-items:center;gap:10px;padding:10px 12px;background:#0d1e2d!important;color:var(--text);border:1px solid #21384c;border-radius:10px;text-align:start;font-weight:500;min-width:0}
.studio-card:hover{border-color:#2f5c55}
.studio-card.active{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent);background:#0b2a26!important}
.studio-card .avatar{width:30px;height:30px;font-size:15px;flex:none}
.studio-card-text{display:flex;flex-direction:column;flex:1;min-width:0}
.studio-card-text strong,.studio-card-text small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.studio-card-text small{color:var(--muted);font-size:12px}
.studio-card .badge{font-size:11px;padding:2px 7px}
.studio-card.add{justify-content:center;color:var(--accent);border-style:dashed}
.studio-title{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.studio-title h2{margin:0;font-size:19px;overflow-wrap:anywhere}
.dirty{color:#f0c674;font-size:13px}
#agent-section .agent-tabs{margin:12px 0 16px;overflow-x:auto;scrollbar-width:thin}
#agent-section .agent-tabs button{white-space:nowrap;font-size:15px}
.studio-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 20px}
.studio-grid.four{grid-template-columns:repeat(4,minmax(0,1fr))}
.studio-grid .wide{grid-column:1/-1}
.studio-grid label{margin-bottom:10px;min-width:0}
#agent-section h3{font-size:15px;margin:16px 0 8px;color:#cfe0f2}
#agent-section label small.hint{display:block;margin-top:4px;font-size:12.5px;line-height:1.4}
#agent-form textarea{min-height:0;max-height:none}
#agent-form .check{margin:6px 0 10px}
.segmented{display:inline-flex;background:#0a1824;border:1px solid var(--edge);border-radius:9px;padding:3px;gap:2px;margin-bottom:14px;flex-wrap:wrap}
.segmented button,#agent-section .segmented button{background:transparent!important;box-shadow:none;color:var(--muted);padding:7px 14px;font-size:14px;border-radius:7px}
.segmented button[aria-pressed=true],#agent-section .segmented button[aria-pressed=true]{background:#123a2f!important;color:var(--accent)}
.choice-cards{border:0;padding:0;margin:0 0 12px;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.choice-cards legend{color:#b8c7da;font-size:15px;margin-bottom:8px}
.choice-cards label{display:flex;gap:10px;align-items:flex-start;margin:0;padding:12px;border:1px solid #21384c;border-radius:10px;background:#0b1a27;cursor:pointer}
.choice-cards label:has(input:checked){border-color:var(--accent);background:#0b2a26}
.choice-cards input{width:auto;margin:3px 0 0;accent-color:var(--accent)}
.choice-cards strong{display:block;font-size:14px;color:var(--text)}
.choice-cards small{display:block;color:var(--muted);font-size:12.5px;line-height:1.35;margin-top:3px}
.warn-line{border-inline-start:3px solid #f0c674;padding:6px 10px;background:#1f1d14;border-radius:4px;font-size:13px}
.prompt-status{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:8px;color:#cfe0f2;font-size:14px}
.badge.draft{background:#3a3214;color:#f0c674}
#prompt-editor{font:14px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;min-height:260px;resize:vertical}
.prompt-meta{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:4px 0 10px}
.row-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
button.small,.small{padding:5px 10px;font-size:13px}
#prompt-history{margin-top:14px}
#prompt-history summary{cursor:pointer;color:var(--accent);font-size:14px}
#prompt-history td,#prompt-history th{padding:8px 6px;font-size:13px}
#prompt-version-view,.preview-box pre,.msg pre{white-space:pre-wrap;overflow-wrap:anywhere;background:#08131d;border:1px solid var(--edge);border-radius:8px;padding:10px;font-size:12.5px;max-height:260px;overflow:auto;color:#cfe0f2}
.kb-toolbar{display:flex;gap:10px;align-items:center;margin-bottom:10px}
.kb-toolbar input{margin:0;flex:1}
.kb-editor{border:1px solid #2f5c55;background:#0b1f1c;border-radius:10px;padding:14px;margin-bottom:12px}
.kb-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px}
.kb-item{border:1px solid #21384c;background:#0b1a27;border-radius:10px;padding:12px;display:flex;flex-direction:column;gap:6px;min-width:0}
.kb-item.inactive{opacity:.6}
.kb-item p{margin:0;font-size:13.5px;color:#b8c7da;overflow-wrap:anywhere}
.kb-head{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}
.kb-head strong{overflow-wrap:anywhere}
.kb-tags{display:flex;gap:4px;flex-wrap:wrap;justify-content:flex-end}
.tag{font-size:11px;padding:2px 7px;border-radius:999px;background:#18304a;color:#b8c7da}
.readonly-limits{display:flex;gap:6px 18px;flex-wrap:wrap;align-items:center;background:#0a1824;border:1px dashed #2a4258;border-radius:9px;padding:10px 12px;font-size:13.5px;color:#b8c7da;margin:4px 0 6px}
.readonly-limits:empty{display:none}
.readonly-limits strong{color:var(--text);width:100%}
.test-toolbar{display:flex;gap:10px;align-items:end;flex-wrap:wrap}
.test-toolbar label{margin:0;min-width:220px}
.test-layout{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);gap:16px;margin-top:6px}
.test-chat{display:flex;flex-direction:column;border:1px solid var(--edge);border-radius:10px;background:#08131d;min-height:420px}
.transcript{flex:1;overflow:auto;padding:12px;display:flex;flex-direction:column;gap:8px;max-height:520px}
.msg{max-width:88%;padding:8px 11px;border-radius:10px;background:#11253a;align-self:flex-start}
.msg small{display:block;font-size:11px;color:var(--muted);margin-bottom:2px}
.msg p{margin:0;color:var(--text);white-space:pre-wrap;overflow-wrap:anywhere}
.msg.user{align-self:flex-end;background:#123a2f}
.msg.tool{background:#1b2236;max-width:100%;align-self:stretch}
.msg.tool code{font-size:12.5px;color:#9fc3ff;overflow-wrap:anywhere}
.msg.system{background:transparent;border:1px dashed #2a4258;align-self:stretch;max-width:100%}
.msg.error{background:#2c1c26;color:#ffc5c5}
.msg.error p{color:#ffc5c5}
.test-input{display:flex;gap:8px;padding:10px;border-top:1px solid var(--edge)}
.test-input input{margin:0}
.preview-box dl{display:grid;grid-template-columns:auto 1fr;gap:4px 12px;margin:0 0 8px;font-size:13.5px}
.preview-box dt{color:var(--muted)}
.preview-box dd{margin:0;overflow-wrap:anywhere}
.preview-box summary{cursor:pointer;color:var(--accent);font-size:13.5px;margin-top:6px}
.test-side h3{margin-top:16px}
.test-side td{padding:8px 6px;font-size:13px}
#agent-section .agent-footer{position:sticky;bottom:0;background:linear-gradient(180deg,rgba(11,23,35,.6),#0b1723 40%);margin:16px -20px -18px;padding:12px 20px;border-radius:0 0 12px 12px}
body.tenant-admin #agent-section .tech{display:none}
[dir=rtl] .studio-card,[dir=rtl] .msg{text-align:right}
@media(max-width:1000px){.studio-grid.four{grid-template-columns:repeat(2,minmax(0,1fr))}.test-layout{grid-template-columns:1fr}}
@media(max-width:700px){.studio-grid,.studio-grid.four,.choice-cards{grid-template-columns:1fr}.studio-bar #add-agent{margin-left:0;width:100%}.studio-cards{grid-template-columns:1fr}#agent-section .agent-footer{position:static}}

.learning-json { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
#learning-root .kb-editor input, #learning-root .kb-editor textarea { width: 100%; min-width: 0; }
#learning-root button { margin-block: .3rem; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.learning-compare { border-collapse: collapse; font-size: .9em; }
.learning-compare th, .learning-compare td { border: 1px solid #d0d5dd; padding: 4px 8px; text-align: start; white-space: nowrap; }
.learning-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.learning-kpi { border: 1px solid rgba(110, 231, 160, .25); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.learning-kpi strong { font-size: 1.6em; }
.learning-section { border-top: 1px solid rgba(255,255,255,.08); padding: 10px 0; }
.learning-section > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.learning-calls { display: flex; flex-wrap: wrap; gap: 6px; max-height: 320px; overflow-y: auto; }
.learning-rule { border-inline-start: 3px solid #6ee7a0; padding: 6px 12px; margin: 8px 0; }

/* AI provider status */
.provider-status{display:grid;grid-template-columns:fit-content(45%) minmax(0,1fr);gap:6px 16px;margin:12px 0}
.provider-status dt{color:var(--muted)}
.provider-status dd{margin:0;overflow-wrap:anywhere}
#provider-section .form-actions{margin-top:8px}
#kbf-viewer{margin-top:10px}
#kbf-view-text{white-space:pre-wrap;overflow-wrap:anywhere;max-height:360px;overflow:auto;margin:6px 0 0;font:13.5px/1.55 system-ui,sans-serif;color:#b8c7da}
#kbf-list{margin-top:6px}
#kbf-list,#rag-results{grid-template-columns:repeat(auto-fill,minmax(min(300px,100%),1fr))}
