.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; }
.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 { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 4px; }
.tool-connection-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tool-connection-head strong { font-size: 14px; }
.tool-connection p { min-height: 0; margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.tool-connect-button { border: 1px solid #bdd8b6; background: #edf6e8; color: var(--green); border-radius: 9px; padding: 8px 11px; font-weight: 800; cursor: pointer; }
.tool-connect-button:hover { background: #dff0d7; }
.configured-tool { border-style: solid !important; }
.secret-note { display: grid; gap: 4px; margin-top: 17px; padding: 12px 14px; border-radius: 11px; background: #f2f5ed; color: var(--muted); font-size: 12px; line-height: 1.5; }
.secret-note strong { color: var(--ink); }
.connection-result { margin-top: 16px; padding: 14px; border: 1px solid #cee2c4; border-radius: 11px; background: #edf6e8; color: var(--green); line-height: 1.55; }
.connection-result.error { background: #fff0ed; border-color: #f1c1b9; color: #8b2d22; }
.connection-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.connection-fields span { padding: 5px 8px; border-radius: 999px; background: white; color: var(--muted); font-size: 11px; }

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

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

.approval-list { display: grid; gap: 16px; }
.approval-card { background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; }
.approval-card.write-blocked { border-color: #e5bd6f; }
.approval-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.approval-card-head h3 { margin: 11px 0 0; }
.approval-card-head > small { color: var(--muted); }
.approval-facts { display: grid; grid-template-columns: 1.5fr .7fr .7fr 1fr; gap: 12px; margin: 18px 0; }
.approval-facts span { min-width: 0; padding: 11px 12px; border-radius: 11px; background: #f4f6f1; overflow-wrap: anywhere; }
.approval-facts b { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.approval-card details { border-top: 1px solid var(--line); padding-top: 13px; }
.approval-card summary { cursor: pointer; font-weight: 700; }
.approval-codes { color: var(--muted); line-height: 1.65; overflow-wrap: anywhere; }
.approval-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.approval-result { margin-top: 14px; padding: 11px 13px; border-radius: 10px; background: #eef4e9; color: var(--green); font-weight: 700; }
.approval-expiry { display: block; margin-top: 14px; color: var(--muted); }
.approval-batches { margin-top: 10px; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.approval-batches p { margin: 10px 0; overflow-wrap: anywhere; }
.approval-safety-block, .approval-confirmation { display: flex; justify-content: space-between; gap: 14px; margin: 14px 0; padding: 12px 14px; border-radius: 11px; line-height: 1.5; }
.approval-safety-block { background: #fff3df; color: #8b5a12; }
.approval-confirmation { background: #f2f5ed; color: var(--muted); }
.approval-safety-block span, .approval-confirmation span { overflow-wrap: anywhere; }
.approval-locked-label { align-self: center; color: #8b5a12; font-size: 13px; font-weight: 800; }
.approval-recovery { margin-top: 14px; padding: 15px; border: 1px solid #e5bd6f; border-radius: 12px; background: #fff9ec; }
.approval-recovery > p { margin: 7px 0 13px; color: #74551f; line-height: 1.55; }
.recovery-batch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid #ead8b4; }
.recovery-batch > span:first-child { min-width: 0; }
.recovery-batch b, .recovery-batch small { display: block; overflow-wrap: anywhere; }
.recovery-batch small { margin-top: 4px; color: var(--muted); }
.recovery-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }

@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; }
  .approval-facts { grid-template-columns: 1fr; }
  .recovery-batch { align-items: flex-start; flex-direction: column; }
  .recovery-actions { justify-content: flex-start; }
}

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