/*
 * Agents, approvals, knowledge sources and systems. Card, template and tile styles follow the demo's
 * Agent OS ("ag-"); the approvals queue uses "ap-". Everything reads at 375 px without sideways scrolling.
 */

/* ---------- tiles and template cards (from the demo) ---------- */
.ag-c-ic {
	width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center;
	color: #fff; background: var(--lc, var(--accent));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 14px -8px var(--lc, var(--accent));
}
.ag-c-ic .ic { color: #fff; }
.ag-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; align-items: stretch; }
.ag-tpl { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px; }
.ag-tpl[hidden], .ag-tnone[hidden] { display: none !important; }
.ag-tpl.ag-blank { border-style: dashed; }
.ag-c-top { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.ag-c-top > .pill, .ag-c-top > .sev { flex: none; }
.ag-c-name { flex: 1 1 auto; min-width: 0; }
.ag-c-name b { display: block; font-size: 14.5px; line-height: 1.25; overflow-wrap: anywhere; }
.ag-c-name span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ag-c-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: auto; min-width: 0; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--stroke); }
.ag-tpl-d { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.ag-tpl .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ag-cats { flex-wrap: wrap; }

/* Callouts with the icon beside the text, as in the demo */
.callout.ag-call { display: flex; gap: 10px; align-items: flex-start; }
.callout.ag-call > .ic { flex: none; margin-top: 2px; }
.callout.ag-call.ag-gap { margin-top: 12px; }
.ag-risk-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ---------- one agent ---------- */
.ag-tabs .tabs { margin-top: 4px; }
.ag-pane[hidden] { display: none !important; }
.ph-sub .row-wrap .tag { height: 24px; }

/* Risk tab: eight factor rows and the live preview beside them */
.ag-risk { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.ag-preview-col { position: sticky; top: 84px; min-width: 0; }
.ag-f { padding: 14px 0; border-bottom: 1px solid var(--stroke); }
.ag-f:last-of-type { border-bottom: 0; }
.ag-f-h { display: flex; align-items: baseline; gap: 8px; }
.ag-f-h b { font-size: 14px; }
.ag-f-h .faint { font: 500 11.5px/1 var(--f-mono); margin-left: auto; }
.ag-f-hint { font-size: 12.8px; color: var(--muted); margin: 3px 0 9px; }
.ag-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ag-scale button {
	position: relative; height: 36px; border-radius: 10px; border: 1px solid var(--stroke-2); background: var(--glass);
	font: 700 13.5px/1 var(--f-mono); color: var(--text-2); transition: background .18s, border-color .18s, color .18s;
}
.ag-scale button:hover:not([disabled]) { background: var(--glass-2); border-color: var(--text-2); }
.ag-scale button.on { background: var(--accent); border-color: #C63C1E; color: var(--accent-ink); }
.ag-scale button.saved:not(.on)::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--faint); }
.ag-scale button[disabled] { cursor: default; opacity: .75; }
.ag-scale button[disabled].on { opacity: 1; }
.ag-f-ends { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 11.8px; color: var(--faint); }
.ag-f-ends span { max-width: 48%; }
.ag-f-ends span:last-child { text-align: right; }
.ag-cf { margin-top: 6px; border-top: 1px solid var(--stroke); border-bottom: 0; padding-top: 14px; }
.ag-cf .li-t, .ag-cf .li-s { white-space: normal; }
.ag-score { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ag-score b { font: 800 40px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.ag-score b small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.ag-req { display: flex; flex-wrap: wrap; gap: 5px; }
.ag-req .tag { white-space: normal; height: auto; min-height: 22px; padding: 4px 8px; line-height: 1.3; font: 500 12px/1.35 var(--f-ui, inherit); }
.ag-req .tag.ag-new { color: var(--t-high); border-color: rgba(224, 106, 44, .4); background: rgba(224, 106, 44, .1); }
.ag-req .tag.ag-drop { text-decoration: line-through; opacity: .7; }

/* Controls tab and approval history: rows whose text wraps */
.ag-ctl, .ag-ap { align-items: flex-start; }
.ag-ctl .li-t, .ag-ctl .li-s, .ag-ap .li-t, .ag-wrap { white-space: normal; overflow: visible; }
.ag-ctl .li-r { flex-wrap: wrap; justify-content: flex-end; }
.ag-ev { font-size: 13px; color: var(--text-2); margin: 6px 0 4px; padding: 8px 10px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--stroke); }

/* Lifecycle tab */
.ag-blockers { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.3px; }
.ag-blockers li::marker { color: var(--t-high); }
.ag-decide { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--stroke); }
.ag-decide b { overflow-wrap: anywhere; }

/* ---------- approvals queue ---------- */
.ap-pane[hidden] { display: none !important; }
.ap-list { display: grid; gap: var(--gap); }
.ap-item { border-left: 3px solid var(--lc, var(--accent)); }
.ap-top { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.ap-main { flex: 1 1 auto; min-width: 0; }
.ap-main h3 { font-size: 16px; margin-top: 6px; overflow-wrap: anywhere; }
.ap-who { font-size: 12.5px; margin-top: 3px; }
.ap-detail { font-size: 13.3px; color: var(--text-2); margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--stroke); }
.ap-why { margin-top: 12px; display: flex; gap: 8px; align-items: flex-start; }
.ap-why .ic { flex: none; margin-top: 2px; }
.ap-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ap-note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.ap-item .tag .ic, .ag-tpl .tag .ic { width: 13px; height: 13px; }

@media (max-width: 900px) {
	.ag-risk { grid-template-columns: minmax(0, 1fr); }
	.ag-preview-col { position: static; }
}
@media (max-width: 720px) {
	.ag-ctl, .ag-ap { flex-wrap: wrap; }
	.ag-ctl .li-main { flex: 1 1 calc(100% - 50px); }
	.ag-ctl .li-r { flex: 1 1 100%; justify-content: flex-start; padding-left: 48px; box-sizing: border-box; }
	.ag-ctl .li-r .btn { flex: none; }
	.ag-f-ends { flex-direction: column; gap: 2px; }
	.ag-f-ends span { max-width: 100%; }
	.ag-f-ends span:last-child { text-align: left; }
	.ag-scale button { height: 42px; }
	.ap-foot .btn { flex: 1 1 auto; justify-content: center; }
	.ap-foot .grow { display: none; }
	.ap-foot .link { flex: 1 1 100%; }
	.ag-score b { font-size: 34px; }
}
