.cap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.cap {
  min-height: 130px;
  padding: 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cap b { font-size: 17px; }
.cap span { color: var(--muted); font-size: 13px; }
.cap.planned { border-style: dashed; background: #fafbf7; }

@media (max-width: 900px) {
  .cap-grid { grid-template-columns: 1fr; }
}

.agent-row {
  grid-template-columns: minmax(260px, 2fr) .55fr .8fr .45fr 1.15fr;
}

.agent-summary { min-width: 0; }
.agent-summary small {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.55;
  margin-top: 5px;
}

.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.small-action {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.small-action.primary-action { background: var(--ink); color: white; border-color: var(--ink); }
.small-action.publish-action { background: #e8f5e4; color: var(--green); border-color: #bdd8b6; }
.small-action.disable-action { color: #8b2d22; border-color: #e4bdb7; }
.action-notice {
  margin-bottom: 12px;
  padding: 12px 15px;
  border: 1px solid #cee2c4;
  border-radius: 11px;
  background: #edf6e8;
  color: var(--green);
  font-weight: 700;
}
.action-notice.error { background: #fff0ed; border-color: #f1c1b9; color: #8b2d22; }

.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
/* The grouped tool catalogue is a directory, not a two-column card tile. */
#toolCatalog > .tool-catalog-groups { grid-column: 1 / -1; width: 100%; min-width: 0; }
.tool-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.tool-card.unavailable { background: #fafbf7; border-style: dashed; }
.tool-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tool-card h3 { margin: 16px 0 6px; }
.tool-card > code { color: var(--green); font-size: 12px; }
.tool-card > p { color: var(--muted); line-height: 1.55; min-height: 48px; }
.tool-risk { border-radius: 999px; padding: 6px 9px; font-size: 12px; font-weight: 800; background: #fff3df; color: #8b5a12; }
.tool-risk.read { background: #e8f5e4; color: var(--green); }
.tool-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.tool-meta span, .tool-agent-tags span { border-radius: 999px; background: #eef1ed; padding: 6px 9px; color: var(--muted); font-size: 12px; }
.tool-assignment { border-top: 1px solid var(--line); padding-top: 15px; }
.tool-assignment > strong { display: block; margin-bottom: 10px; }
.tool-agent-list { display: grid; gap: 8px; }
.tool-agent-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; cursor: pointer; }
.tool-agent-option input { width: auto; margin-top: 3px; }
.tool-agent-option span { display: grid; gap: 2px; }
.tool-agent-option small, .tool-assignment > small { color: var(--muted); }
.tool-agent-option.locked { cursor: not-allowed; opacity: .65; }
.tool-unavailable { border-radius: 11px; padding: 11px 12px; background: #fff3df; color: #8b5a12; font-size: 13px; line-height: 1.5; }
.tool-agent-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tool-connection-action { margin: 14px 0 -2px; }
.tool-catalog-groups { display: grid; gap: 22px; }
.tool-category { display: grid; gap: 10px; }
.tool-category > header { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 0 3px; }
.tool-category > header > div { display: grid; gap: 4px; }
.tool-category > header strong { font-size: 17px; }
.tool-category > header small, .tool-category > header > span { color: var(--muted); font-size: 12px; }
.tool-category > header > span { white-space: nowrap; }
.tool-directory { background: white; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.tool-directory-row { display: grid; grid-template-columns: minmax(280px, 1fr) 68px 88px 112px; align-items: center; gap: 16px; padding: 17px 20px; border-top: 1px solid var(--line); }
.tool-directory-row:first-child { border-top: 0; }
.tool-directory-row > span:first-child { display: grid; gap: 5px; min-width: 0; }
.tool-directory-row small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-directory-row em { color: var(--green); font-size: 12px; font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-directory-head { background: #f3f5f1; color: var(--muted); font-size: 12px; font-weight: 800; }
.tool-directory-assigned { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-detail-dialog { min-width: min(620px, 90vw); }
.tool-detail-dialog > div > p { color: var(--muted); line-height: 1.6; }
.tool-directory .tool-risk, .tool-directory .status-badge { white-space: nowrap; }
@media (max-width: 1200px) { .tool-directory-row { grid-template-columns: minmax(220px, 1fr) 68px 88px 104px; gap: 12px; padding: 15px 16px; } }
@media (max-width: 900px) { .tool-directory-row { grid-template-columns: 1fr auto; gap: 10px; } .tool-directory-head { display: none; } .tool-directory-row > span:nth-child(2), .tool-directory-row > span:nth-child(3) { display: none; } .tool-category > header { align-items: start; } }

.model-mapping-list { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.model-mapping-list > strong { font-size: 13px; }
.model-mapping-list > div { display: grid; gap: 7px; max-height: 180px; overflow: auto; }
.model-mapping-list > div > small { color: var(--muted); }
.model-mapping-item { display: grid; gap: 3px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8faf6; color: var(--ink); text-align: left; cursor: pointer; }
.model-mapping-item:hover { border-color: #bdd8b6; background: #edf6e8; }
.model-mapping-item small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.model-config {
  padding: 26px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.model-config-head { display: flex; justify-content: space-between; align-items: flex-start; }
.model-config-head h3 { margin: 5px 0; }
.model-config > p { color: var(--muted); }
.status-badge {
  display: inline-block;
  border-radius: 999px;
  background: #eef1ed;
  color: var(--muted);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
}
.status-badge.connected { background: #e8f5e4; color: var(--green); }
.status-badge.planned { background: #fff3df; color: #8b5a12; }

.test-result {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f8faf6;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.65;
  max-height: 360px;
  overflow: auto;
}
.test-result.error { background: #fff0ed; border-color: #f1c1b9; color: #8b2d22; }
.test-result strong { display: block; margin-bottom: 8px; }
.build-plan { display: grid; gap: 13px; }
.build-plan h4 { margin: 0; font-size: 16px; }
.build-plan p { margin: 4px 0 0; color: var(--muted); line-height: 1.55; }
.build-plan ol { margin: 6px 0 0 20px; padding: 0; color: var(--ink); line-height: 1.55; }
.build-plan-tools { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
.build-tool { display: inline-flex; gap: 5px; align-items: center; padding: 6px 9px; border-radius: 999px; background: #e8f5e4; color: var(--green); font-size: 12px; font-weight: 700; }
.build-tool.needs { background: #fff3df; color: #8b5a12; }
.build-tool.approval { background: #f3ecff; color: #60408b; }
.build-warning { padding: 10px 12px; border-radius: 10px; background: #fff8e9; color: #74501c; font-size: 12px; line-height: 1.5; }
.excel-upload {
  border: 1px dashed var(--line);
  border-radius: 13px;
  background: #f8faf6;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.excel-upload input { margin-top: 9px; padding: 9px; background: white; }
.excel-upload small { display: block; margin-top: 7px; color: var(--muted); font-weight: 400; }
.run-row { grid-template-columns: 1fr .65fr .55fr 2fr; }
.run-output { white-space: pre-wrap; line-height: 1.5; max-height: 130px; overflow: auto; }
.run-output small { display: block; }

@media (max-width: 900px) {
  .agent-row, .run-row { grid-template-columns: 1fr; }
  .agent-row > *, .run-row > * { display: block !important; }
  .row-actions { justify-content: flex-start; }
  .model-config .grid2 { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
}

.header-actions { display: flex; align-items: center; gap: 12px; }
.project-switcher { margin: 0; display: flex; align-items: center; gap: 8px; }
.project-switcher span { color: var(--muted); font-size: 12px; font-weight: 700; }
.project-switcher select { min-width: 220px; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: white; color: var(--ink); }

@media (max-width: 900px) {
  .project-switcher span { display: none; }
  .project-switcher select { min-width: 150px; max-width: 180px; }
}
