/* Canonical shared component layer. Page-specific layout lives in saas.css and static/pages/. */

/* Management workspace: table-first lists with focused modal editors. */
.management-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.management-section + .management-section {
  margin-top: 18px;
}

.management-section-spaced {
  margin-top: 18px;
}

.management-section-flush {
  padding: 0;
  border: 0;
}

.management-section-head,
.management-toolbar,
.management-summary-row,
.management-page-actions,
.management-toolbar-actions,
.management-filter-group,
.management-policy-bar,
.management-modal-head,
.management-modal-footer {
  display: flex;
  align-items: center;
}

.management-section-head,
.management-toolbar,
.management-policy-bar,
.management-modal-head {
  justify-content: space-between;
}

.management-section-head {
  gap: 16px;
}

.management-section-head h3,
.management-modal-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}

.management-section-head .hint {
  margin-top: 3px;
}

.management-toolbar {
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
}

.management-toolbar-actions,
.management-filter-group,
.management-page-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.management-filter-group {
  flex: 1 1 440px;
}

.management-filter-group > input {
  width: min(300px, 100%);
}

.management-filter-group > select {
  width: auto;
  min-width: 136px;
}

.management-compact-input {
  width: 190px;
}

.management-summary-row {
  width: 100%;
  min-height: 40px;
  align-self: start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line-subtle);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.management-summary-row > * {
  min-width: 0;
  margin: 0;
}

.management-summary-row > :last-child:not(:first-child) {
  text-align: right;
}

body.saas-app .body:has(.management-summary-row),
body.saas-app .management-section:has(> .management-summary-row),
body.saas-app .tab-panel:has(> .management-summary-row) {
  align-content: start;
  grid-auto-rows: max-content;
  gap: 12px;
}

body.saas-app .rbac-panel:has(> .management-summary-row) {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 12px;
}

body.saas-app .management-summary-row {
  min-height: 40px;
  padding: 8px 12px;
}

body.saas-app .management-summary-row > .status {
  min-height: 0;
}

.management-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.management-table-scroll {
  max-height: min(58vh, 620px);
  overflow: auto;
}

.model-capability-editor {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.model-capability-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 13px;
}

.model-capability-table th,
.model-capability-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.model-capability-table tr:last-child td {
  border-bottom: 0;
}

.model-capability-table th {
  white-space: nowrap;
}

.model-capability-table input[type="number"] {
  width: 180px;
}

.model-capability-table select[data-model-config="api_mode"] {
  min-width: 180px;
}

.model-capability-table select[data-model-config="reasoning_mode"] {
  min-width: 150px;
}

.model-capability-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.model-capability-empty {
  color: var(--muted);
  text-align: center !important;
}

.management-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  color: var(--text);
  font-size: 13px;
}

.management-table-cli,
.management-table-model-profiles,
.management-table-projects,
.management-table-scheduled-tasks,
.management-table-public-tool,
.management-table-public-mcp,
.management-table-public-skill {
  min-width: 860px;
  table-layout: fixed;
}

.management-table-model-profiles {
  min-width: 1080px;
}

.management-table-scheduled-tasks {
  min-width: 1100px;
}

.management-table-scheduled-tasks th:nth-child(1) {
  width: 180px;
}

.management-table-scheduled-tasks th:nth-child(2) {
  width: 160px;
}

.management-table-scheduled-tasks th:nth-child(3) {
  width: 110px;
}

.management-table-scheduled-tasks th:nth-child(4) {
  width: 88px;
}

.management-table-scheduled-tasks th:nth-child(5),
.management-table-scheduled-tasks th:nth-child(6) {
  width: 132px;
}

.management-table-scheduled-tasks th:nth-child(7) {
  width: 78px;
}

.management-table-scheduled-tasks .management-actions-column {
  width: 216px;
  min-width: 216px;
}

.management-table-projects th:nth-child(1) {
  width: 220px;
}

.management-table-projects th:nth-child(2) {
  width: 150px;
}

.management-table-projects th:nth-child(3) {
  width: 100px;
}

.management-table-projects th:nth-child(4) {
  width: 220px;
}

.management-table-projects th:nth-child(5) {
  width: 160px;
}

.management-table-public-tool th:nth-child(1),
.management-table-public-skill th:nth-child(1) {
  width: 220px;
}

.management-table-public-mcp th:nth-child(1) {
  width: 180px;
}

.management-table-public-tool th:nth-child(2),
.management-table-public-mcp th:nth-child(2),
.management-table-public-skill th:nth-child(2) {
  width: 140px;
}

.management-table-public-tool th:nth-child(3) {
  width: 145px;
}

.management-table-public-mcp th:nth-child(3) {
  width: 230px;
}

.management-table-public-skill th:nth-child(3) {
  width: 180px;
}

.management-table-public-tool th:nth-child(4),
.management-table-public-mcp th:nth-child(4) {
  width: 100px;
}

.management-table-public-skill th:nth-child(4) {
  width: 120px;
}

.management-table-public-tool th:nth-child(5),
.management-table-public-mcp th:nth-child(5),
.management-table-public-skill th:nth-child(5) {
  width: 100px;
}

.management-table-cli th:nth-child(1) {
  width: 190px;
}

.management-table-cli th:nth-child(2) {
  width: 145px;
}

.management-table-cli th:nth-child(3) {
  width: 190px;
}

.management-table-cli th:nth-child(4) {
  width: 95px;
}

.management-table-cli th:nth-child(5) {
  width: 80px;
}

.management-table-model-profiles th:nth-child(1) {
  width: 150px;
}

.management-table-model-profiles th:nth-child(2) {
  width: 115px;
}

.management-table-model-profiles th:nth-child(3) {
  width: 105px;
}

.management-table-model-profiles th:nth-child(4) {
  width: 90px;
}

.management-table-model-profiles th:nth-child(5) {
  width: 125px;
}

.management-table-model-profiles th:nth-child(6) {
  width: 170px;
}

.management-table-model-profiles th:nth-child(7) {
  width: 70px;
}

.management-table-model-profiles th:nth-child(8) {
  width: 100px;
}

.management-table-cli .management-cell-primary,
.management-table-cli .management-cell-secondary,
.management-table-cli .management-cell-code,
.management-table-model-profiles .management-cell-primary,
.management-table-model-profiles .management-cell-secondary,
.management-table-model-profiles .management-cell-code {
  max-width: 100%;
}

.management-table th,
.management-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-subtle);
  text-align: left;
  vertical-align: middle;
}

.management-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.management-table tbody tr:last-child > td {
  border-bottom: 0;
}

.management-table tbody > tr:not(.management-detail-row):hover > td {
  background: #f7fbff;
}

.management-actions-column {
  width: 168px;
  min-width: 168px;
  text-align: right !important;
}

.management-checkbox-column {
  width: 56px;
  text-align: center !important;
}

.management-checkbox-column input {
  width: 16px;
  height: 16px;
}

.management-cell-primary {
  display: block;
  max-width: 320px;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.management-cell-secondary {
  display: block;
  max-width: 380px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.management-cell-code {
  display: block;
  max-width: 260px;
  overflow: hidden;
  color: #475569;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.management-cell-description {
  display: -webkit-box;
  max-width: 440px;
  overflow: hidden;
  color: var(--text-secondary);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.management-table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

.management-text-action {
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
  color: var(--brand);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
}

.management-text-action:hover:not(:disabled) {
  border-color: var(--line-selected);
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: none;
}

.management-text-action.danger {
  border-color: var(--error-border);
  background: var(--surface-danger);
  color: var(--error-text);
}

.management-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.management-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  content: "";
}

.management-status.ok::before {
  background: var(--ok);
}

.management-status.warn::before {
  background: var(--warn);
}

.management-status.error::before {
  background: var(--error);
}

.management-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.management-badge.blue {
  border-color: var(--line-selected);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.management-badge.green {
  border-color: var(--ok-border);
  background: var(--surface-success);
  color: var(--ok-text);
}

.management-badge.gray {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: #595959;
}

.management-badge.red {
  border-color: var(--error-border);
  background: var(--surface-danger);
  color: var(--error-text);
}

.management-empty-cell {
  height: 104px;
  color: var(--text-tertiary);
  text-align: center !important;
}

.management-form-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.management-span-2 {
  grid-column: span 2;
}

.management-page-actions {
  margin-top: 18px;
}

.management-policy-bar {
  gap: 18px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--info-border);
  border-radius: 8px;
  background: #eff6ff;
}

.management-switch-label {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.management-switch-label input {
  width: 16px;
  height: 16px;
}

.management-detail-row > td {
  padding: 0 !important;
  background: #fafcff;
}

.management-detail-panel {
  padding: 14px 18px 18px 70px;
  border-bottom: 1px solid var(--line-subtle);
}

.management-detail-panel .management-table {
  min-width: 620px;
}

.management-detail-panel .management-table th {
  position: static;
}

.management-readonly-value,
.management-operation-preview {
  min-height: var(--control-height);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 13px;
}

.management-operation-preview {
  max-height: 260px;
  overflow: auto;
}

.management-operation-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(0, 1.4fr) minmax(120px, 0.6fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-subtle);
}

.management-operation-row:last-child {
  border-bottom: 0;
}

.management-code-editor {
  min-height: 300px;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 2;
}

.http-tool-builder {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.http-tool-grid {
  display: grid;
  align-items: start;
  grid-template-columns: 130px minmax(260px, 1fr) 170px 110px;
  gap: 12px;
  padding: 16px;
}

.http-tool-url-field {
  min-width: 0;
}

.http-tool-check,
.http-tool-table-check,
.http-tool-clear-secret {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.http-tool-check {
  padding: 0 16px 4px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.http-tool-check + .hint {
  padding: 0 16px 14px;
}

.http-tool-check input,
.http-tool-table-check input,
.http-tool-clear-secret input {
  width: 15px;
  height: 15px;
}

.http-tool-section {
  padding: 16px;
  border-top: 1px solid var(--line-subtle);
}

.http-tool-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.http-tool-table {
  min-width: 860px;
}

.http-tool-table th,
.http-tool-table td {
  padding: 8px;
}

.http-tool-table input:not([type="checkbox"]),
.http-tool-table select {
  width: 100%;
  min-width: 110px;
}

.http-tool-table td:first-child input {
  min-width: 150px;
}

.http-tool-clear-secret {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.management-badge.success {
  border-color: var(--ok-border);
  background: var(--surface-success);
  color: #237804;
}

.http-tool-body-grid {
  grid-template-columns: 220px minmax(0, 1fr);
  padding: 0;
}

.http-tool-body-editor {
  min-height: 140px;
}

.http-tool-date-variable-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.http-tool-date-variable-title {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.http-tool-date-variable-toolbar button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.http-tool-date-variable-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.http-tool-date-variable-group input[type="number"] {
  width: 76px;
}

.http-tool-date-variable-group input[type="date"] {
  width: 142px;
}

.http-tool-date-variable-group input {
  min-height: 30px;
  padding: 4px 7px;
}

.http-tool-date-variable-hint {
  margin: 0;
  line-height: 1.55;
}

.http-tool-test-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
}

.http-tool-test-grid .management-code-editor {
  min-height: 180px;
}

.http-tool-test-result {
  min-height: 180px;
  max-height: 320px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.management-code-editor-compact {
  min-height: 190px;
}

.tool-wrapper-section {
  margin-top: 20px;
}

.management-toolbar-compact {
  min-height: 36px;
  margin-bottom: 8px;
  padding: 0;
}

.management-table-compact {
  min-width: 680px;
}

.management-table-compact input {
  min-width: 180px;
  width: 100%;
}

#tool-wrapper-preview {
  min-height: 120px;
  max-height: 320px;
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ops-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin-bottom: 8px;
}

.management-code-editor-short {
  min-height: 130px;
}

.management-textarea-short {
  min-height: 72px;
}

.management-code-editor-tall {
  min-height: 480px;
}

.management-modal {
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: 0 18px 52px rgba(15, 23, 42, 0.24);
}

.management-modal-wide {
  width: min(920px, calc(100vw - 32px));
}

.management-modal-xl {
  width: min(1120px, calc(100vw - 32px));
}

/* Only shared model editors: retain the row/data-field contract used by probes
   and saving, without inheriting the general table's fixed control widths. */
.model-profile-editor-modal {
  width: min(1480px, calc(100vw - 48px));
}

.model-profile-editor-modal .management-form-grid > *,
.model-profile-editor-modal .model-api-capabilities fieldset {
  min-width: 0;
}

.model-profile-editor-modal .hint {
  overflow-wrap: anywhere;
}

.model-profile-editor-modal .model-capability-editor {
  margin-top: 8px;
}

.model-profile-editor-modal .model-capability-table {
  min-width: 0;
  table-layout: fixed;
}

.model-profile-editor-modal .model-capability-table th,
.model-profile-editor-modal .model-capability-table td {
  padding: 16px 12px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.model-profile-editor-modal .model-capability-table th {
  background: var(--surface-muted);
  white-space: normal;
  font-size: 12px;
}

.model-profile-editor-modal th:nth-child(1) { width: 15%; }
.model-profile-editor-modal th:nth-child(2) { width: 15%; }
.model-profile-editor-modal th:nth-child(3) { width: 10%; }
.model-profile-editor-modal th:nth-child(4) { width: 30%; }
.model-profile-editor-modal th:nth-child(5) { width: 9%; }
.model-profile-editor-modal th:nth-child(6) { width: 21%; }

.model-profile-editor-modal .model-capability-table select,
.model-profile-editor-modal .model-capability-table input[type="number"],
.model-profile-editor-modal .model-capability-json {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.model-profile-editor-modal .model-capability-json {
  min-height: 104px;
}

.model-profile-editor-modal .model-request-extensions fieldset {
  min-width: 0;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.model-profile-editor-modal .model-extension-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.model-profile-editor-modal .model-extension-actions select {
  flex: 1 1 150px;
  width: auto;
}

.model-profile-editor-modal [data-model-extension] {
  font-family: var(--font-mono, monospace);
  resize: vertical;
}

.model-profile-editor-modal .model-profile-identity .management-cell-code {
  display: block;
  margin-bottom: 10px;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 600;
  line-height: 1.5;
}

.model-profile-editor-modal [data-model-probe-row] {
  min-height: 32px;
  padding: 4px 12px;
  margin: 0 0 8px;
}

.model-profile-editor-modal [data-model-probe-summary] {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.65;
}

.model-profile-editor-modal [data-model-probe-summary]:empty {
  display: none;
}

.model-profile-editor-modal .model-api-capabilities {
  margin-top: 10px;
  min-width: 0;
  max-width: none;
}

.model-profile-editor-modal .model-capability-editor {
  border: 0;
  background: transparent;
}

.model-profile-editor-modal .model-capability-table,
.model-profile-editor-modal .model-capability-table tbody {
  display: block;
}

.model-profile-editor-modal .model-capability-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.model-profile-editor-modal .model-capability-table tr {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.model-profile-editor-modal .model-capability-table td {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
}

.model-profile-editor-modal td[data-label]::before {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  content: attr(data-label);
}

.model-profile-editor-modal .model-profile-identity,
.model-profile-editor-modal .model-profile-image-constraints,
.model-profile-editor-modal td[data-label="请求扩展参数（JSON）"],
.model-profile-editor-modal .model-capability-empty {
  grid-column: 1 / -1;
}

.model-profile-editor-modal .model-request-extensions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.model-profile-editor-modal .model-request-extensions > .hint {
  grid-column: 1 / -1;
  margin: 0;
}

.model-profile-editor-modal .model-capability-table .model-profile-identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.model-profile-editor-modal td.model-profile-identity::before {
  display: none;
}

.model-profile-editor-modal .model-profile-identity .management-cell-code,
.model-profile-editor-modal [data-model-probe-row] {
  margin: 0;
}

.model-profile-editor-modal [data-model-probe-summary] {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .model-profile-editor-modal .model-capability-table tr {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .model-profile-editor-modal select[data-model-config="api_mode"] {
    font-size: 12px;
  }
}

.management-modal::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(1px);
}

body.management-modal-open {
  overflow: hidden;
}

body.management-modal-open::before,
body.saas-app.management-modal-open::before {
  display: block;
  position: fixed;
  z-index: 999;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  content: "";
}

.management-modal.management-modal-fallback {
  position: fixed;
  z-index: 1000;
  inset: 0;
}

.management-modal-card {
  display: grid;
  max-height: calc(100vh - 40px);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.management-modal:not(.management-modal-xl) .management-modal-card {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.management-modal.management-modal-no-tabs .management-modal-card {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.management-modal-head {
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.management-modal-kicker {
  margin-bottom: 2px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.management-modal-close {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-tertiary);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.management-modal-close:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
  box-shadow: none;
}

.management-modal-body {
  min-height: 0;
  padding: 20px 22px;
  overflow: auto;
}

.management-modal-footer {
  min-height: 64px;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-muted);
}

.management-modal-spacer {
  flex: 1 1 auto;
}

.management-modal-status {
  flex: 0 1 360px;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.management-modal-tabs {
  display: flex;
  gap: 24px;
  padding: 0 22px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.management-modal-tab {
  min-height: 46px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  white-space: nowrap;
}

.management-modal-tab:hover:not(:disabled),
.management-modal-tab.active {
  border-bottom-color: var(--brand);
  background: transparent;
  box-shadow: none;
  color: var(--brand);
}

.management-modal-panel {
  display: none;
}

.management-modal-panel.active {
  display: block;
}

.subtle-danger {
  border-color: var(--error-border);
  background: #fff;
  color: var(--error-text);
}

@media (max-width: 760px) {
  .management-section {
    padding: 14px;
  }

  .management-section-head,
  .management-toolbar,
  .management-summary-row,
  .management-policy-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .management-summary-row {
    gap: 4px;
  }

  .management-summary-row > :last-child:not(:first-child) {
    text-align: left;
  }

  .management-toolbar-actions,
  .management-filter-group {
    flex: 0 0 auto;
  }

  .management-filter-group > input,
  .management-filter-group > select,
  .management-compact-input {
    width: 100%;
  }

  .management-form-grid {
    grid-template-columns: 1fr;
  }

  .management-span-2 {
    grid-column: span 1;
  }

  .http-tool-grid,
  .http-tool-body-grid,
  .http-tool-test-grid {
    grid-template-columns: 1fr;
  }

  .http-tool-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .http-tool-section-head > button {
    width: 100%;
  }

  .management-modal,
  .management-modal-wide,
  .management-modal-xl {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .management-modal-card {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
  }

  .management-modal-body {
    flex: 1 1 auto;
  }

  .management-modal-head,
  .management-modal-footer {
    flex: 0 0 auto;
  }

  .management-modal-footer {
    flex-wrap: wrap;
  }

  .management-modal-status {
    order: -1;
    flex-basis: 100%;
  }

  #project-modal .management-modal-footer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  #project-modal .management-modal-spacer {
    display: none;
  }

  #project-modal #project-status {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    grid-column: 1 / -1;
    order: -1;
    text-overflow: ellipsis;
    white-space: normal;
  }

  #project-modal .management-modal-footer > .secondary:not(.subtle-danger) {
    justify-self: end;
  }

  .management-detail-panel {
    padding-left: 18px;
  }
}

/* Canonical component overrides. */

body.saas-app .card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

body.saas-app .head {
  border-color: var(--line);
}

body.saas-app .link,
body.saas-app button,
body.saas-app .button {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  box-shadow: var(--shadow-sm);
  color: var(--text-inverse);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: 550;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color var(--motion-base) ease,
    background var(--motion-base) ease,
    box-shadow var(--motion-base) ease,
    color var(--motion-base) ease;
}

body.saas-app .link:hover,
body.saas-app button:hover:not(:disabled),
body.saas-app .button:hover {
  background: var(--brand-hover);
}

body.saas-app .link:active,
body.saas-app button:active:not(:disabled),
body.saas-app .button:active {
  background: var(--brand-active);
}

body.saas-app button.management-modal-tab {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

body.saas-app button.management-modal-tab:hover:not(:disabled) {
  border-bottom-color: var(--line-selected);
  background: transparent;
  color: var(--brand);
}

body.saas-app button.management-modal-tab.active {
  border-bottom-color: var(--brand);
  background: transparent;
  color: var(--brand);
  font-weight: 650;
}

body.saas-app button.management-modal-tab.active:hover:not(:disabled) {
  border-bottom-color: var(--brand);
  background: transparent;
  color: var(--brand);
}

body.saas-app button.management-modal-tab:focus-visible {
  outline: 2px solid var(--line-selected);
  outline-offset: -4px;
}

body.saas-app .link.secondary,
body.saas-app button.secondary,
body.saas-app .button.secondary {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--text-secondary);
  box-shadow: none;
}

body.saas-app .link.secondary:hover,
body.saas-app button.secondary:hover:not(:disabled),
body.saas-app .button.secondary:hover {
  border-color: var(--line-selected);
  background: var(--brand-soft);
  color: var(--brand);
}

body.saas-app button.danger {
  background: var(--error);
  color: var(--text-inverse);
}

body.saas-app button.danger:hover:not(:disabled) {
  background: var(--error-text);
}

body.saas-app button.small,
body.saas-app .button.small,
body.saas-app .link.small {
  min-height: var(--control-height-sm);
  padding: 5px 10px;
  font-size: var(--font-size-md);
}

body.saas-app button:disabled,
body.saas-app .button:disabled,
body.saas-app [aria-disabled="true"] {
  opacity: 0.48;
  box-shadow: none;
  cursor: not-allowed;
}

body.saas-app input,
body.saas-app textarea,
body.saas-app select {
  min-height: var(--control-height);
  padding: 7px 10px;
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  background-color: var(--panel);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.45;
}

body.saas-app select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%),
    linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 3px),
    calc(100% - 10px) calc(50% - 3px);
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  cursor: pointer;
}

body.saas-app .select-control {
  position: relative;
  display: block;
  min-width: 0;
}

body.saas-app .select-control > select {
  width: 100%;
  padding-right: 36px;
  background-image: none;
  cursor: pointer;
}

body.saas-app .select-control-icon {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  pointer-events: none;
  transform: translateY(-50%);
  transition: color var(--motion-fast) ease;
}

body.saas-app .select-control-icon svg {
  width: 16px;
  height: 16px;
}

body.saas-app .select-control:focus-within .select-control-icon,
body.saas-app .select-control:hover .select-control-icon {
  color: var(--brand);
}

body.saas-app .http-tool-date-variable-toolbar button,
body.saas-app .http-tool-date-variable-toolbar input {
  height: var(--control-height-sm);
  min-height: var(--control-height-sm);
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: var(--font-size-sm);
}

body.saas-app label.check {
  min-height: var(--control-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.4;
  text-transform: none;
}

body.saas-app label.check > input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  flex: 0 0 16px;
  margin: 0;
  padding: 0;
}

body.saas-app label.check > span {
  min-width: 0;
  line-height: 1.4;
}

body.saas-app input:hover,
body.saas-app textarea:hover,
body.saas-app select:hover {
  border-color: #818cf8;
}

body.saas-app input:focus-visible,
body.saas-app textarea:focus-visible,
body.saas-app select:focus-visible {
  border-color: var(--brand);
  outline: none;
  box-shadow: var(--focus-ring);
}

body.saas-app button:focus-visible,
body.saas-app .button:focus-visible,
body.saas-app .link:focus-visible,
body.saas-app summary:focus-visible,
body.saas-app [tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

body.saas-app input::placeholder,
body.saas-app textarea::placeholder {
  color: var(--text-disabled);
}

body.saas-app .tag,
body.saas-app .summary-pill,
body.saas-app .tool-badge,
body.saas-app .trace-tag,
body.saas-app .plan-status {
  min-height: 24px;
  border-color: #c7d2fe;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 550;
}

body.saas-app .agent[data-agent-href] {
  position: relative;
  cursor: pointer;
}

body.saas-app .agent[data-agent-href]:focus-visible {
  border-color: #818cf8;
  outline: 3px solid rgba(99, 102, 241, 0.2);
  outline-offset: 2px;
}

body.saas-app .agent-menu {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

body.saas-app button.agent-menu-trigger,
body.saas-app button.agent-menu-trigger:hover:not(:disabled) {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-tertiary);
  font-weight: 700;
  letter-spacing: 1px;
}

body.saas-app button.agent-menu-trigger:hover:not(:disabled),
body.saas-app button.agent-menu-trigger[aria-expanded="true"] {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

body.saas-app button.agent-menu-trigger svg,
body.saas-app .management-modal-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

body.saas-app button.agent-menu-trigger svg {
  fill: currentColor;
  stroke: none;
}

body.saas-app .agent-card-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  width: max-content;
  min-width: 136px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

body.saas-app button.agent-menu-delete,
body.saas-app button.agent-menu-delete:hover:not(:disabled) {
  width: 100%;
  min-height: 32px;
  justify-content: flex-start;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  font-weight: 500;
}

body.saas-app button.agent-menu-delete:hover:not(:disabled),
body.saas-app button.agent-menu-delete:focus-visible {
  background: var(--surface-danger);
  color: var(--error-text);
}

body.saas-app .management-table-wrap,
body.saas-app .management-section,
body.saas-app .management-readonly-value,
body.saas-app .management-operation-preview {
  border-color: var(--line);
}

body.saas-app .management-table th {
  background: var(--panel-soft);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 650;
  letter-spacing: 0.01em;
}

body.saas-app .management-table tbody > tr:not(.management-detail-row):hover > td {
  background: #f8f9ff;
}

body.saas-app .management-status.ok::before {
  background: var(--ok);
}

body.saas-app .management-status.warn::before {
  background: var(--warn);
}

body.saas-app .management-status.error::before {
  background: var(--error);
}

/* Shared typography and page hierarchy */
body.saas-app .head,
body.saas-app .management-section-head,
body.saas-app .platform-card-head,
body.saas-app .project-section-head,
body.saas-app .rbac-section-head {
  gap: var(--space-4);
}

body.saas-app .head {
  padding: 16px 20px;
  background: var(--panel);
}

body.saas-app .head h1,
body.saas-app .head h2,
body.saas-app .platform-page-header h1,
body.saas-app .platform-page-header h2 {
  font-size: var(--font-size-xl);
  line-height: 1.35;
}

body.saas-app .head h3,
body.saas-app .management-section-head h3,
body.saas-app .platform-card-head h3 {
  font-size: var(--font-size-lg);
  line-height: 1.4;
}

body.saas-app .hint,
body.saas-app .sub,
body.saas-app .management-cell-secondary {
  color: var(--text-tertiary);
}

body.saas-app .body,
body.saas-app .resource-panels,
body.saas-app .tab-panels {
  padding: 20px;
}

/* Status and badge contract */
body.saas-app .status,
body.saas-app .management-status,
body.saas-app .agent-enabled-status,
body.saas-app .run-status-chip,
body.saas-app .execution-step-status {
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

body.saas-app .status.ok,
body.saas-app .management-status.ok,
body.saas-app .platform-health-list strong.ok,
body.saas-app .agent-enabled-status,
body.saas-app .run-status-chip.completed,
body.saas-app .execution-step.completed .execution-step-status,
body.saas-app .execution-state.completed {
  color: var(--ok-text);
}

body.saas-app .status.warn,
body.saas-app .management-status.warn,
body.saas-app .execution-step.running .execution-step-status {
  color: var(--warn-text);
}

body.saas-app .status.error,
body.saas-app .management-status.error,
body.saas-app .execution-step.failed .execution-step-status {
  color: var(--error-text);
}

body.saas-app .management-badge.green,
body.saas-app .run-status-chip.completed,
body.saas-app .agent-enabled-status {
  border-color: var(--ok-border);
  background: var(--surface-success);
  color: var(--ok-text);
}

body.saas-app .management-badge.red,
body.saas-app .run-status-chip.stopped {
  border-color: var(--error-border);
  background: var(--surface-danger);
  color: var(--error-text);
}

body.saas-app .management-badge,
body.saas-app .resource-type-badge,
body.saas-app .run-status-chip,
body.saas-app .agent-enabled-status {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  line-height: 1.2;
}

body.saas-app .resource-type-badge {
  color: var(--brand-strong);
}

body.saas-app.saas-route-index #resource-tabs {
  flex-wrap: nowrap;
}

body.saas-app.saas-route-index #resource-tabs button {
  flex: 0 0 auto;
}

/* Table contract: action columns stay available at laptop widths. */
body.saas-app .management-table-wrap {
  max-width: 100%;
  border-radius: var(--radius-md);
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

body.saas-app .management-table {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
}

body.saas-app .management-table th,
body.saas-app .management-table td {
  padding: 10px 12px;
}

body.saas-app .management-table-projects {
  min-width: 880px;
}

body.saas-app .management-table-projects th:nth-child(1) {
  width: 190px;
}

body.saas-app .management-table-projects th:nth-child(2) {
  width: 130px;
}

body.saas-app .management-table-projects th:nth-child(3) {
  width: 84px;
}

body.saas-app .management-table-projects th:nth-child(4) {
  width: 188px;
}

body.saas-app .management-table-projects th:nth-child(5) {
  width: 140px;
}

body.saas-app .unified-resource-table {
  min-width: 900px;
  table-layout: fixed;
}

body.saas-app .management-table-projects .management-actions-column,
body.saas-app .unified-resource-table .management-actions-column {
  width: 148px;
  min-width: 148px;
}

body.saas-app .management-table-projects th:last-child,
body.saas-app .management-table-projects td:last-child,
body.saas-app .management-table-scheduled-tasks .management-actions-column,
body.saas-app .management-table-scheduled-tasks .management-actions-cell,
body.saas-app .unified-resource-table th:last-child,
body.saas-app .unified-resource-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: -8px 0 12px -12px rgba(15, 23, 42, 0.35);
}

body.saas-app .management-table-projects th:last-child,
body.saas-app .management-table-scheduled-tasks .management-actions-column,
body.saas-app .unified-resource-table th:last-child {
  z-index: 4;
  background: var(--panel-soft);
}

body.saas-app .management-table-projects tbody > tr:hover > td:last-child,
body.saas-app .management-table-scheduled-tasks tbody > tr:hover > .management-actions-cell,
body.saas-app .unified-resource-table tbody > tr:hover > td:last-child {
  background: #f8f9ff;
}

body.saas-app .management-table:has(.management-actions-column) th:last-child,
body.saas-app .management-table:has(.management-actions-column) td:last-child:not([colspan]) {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: -8px 0 12px -12px rgba(15, 23, 42, 0.35);
}

body.saas-app .management-table:has(.management-actions-column) th:last-child {
  z-index: 4;
  background: var(--panel-soft);
}

body.saas-app .management-table:has(.management-actions-column) tbody > tr:hover > td:last-child:not([colspan]) {
  background: #f8f9ff;
}

body.saas-app .management-table-actions {
  gap: var(--space-1);
}

body.saas-app .management-text-action {
  min-width: 28px;
  min-height: 28px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--brand);
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  font-weight: 550;
  line-height: 20px;
}

body.saas-app .management-text-action:hover:not(:disabled) {
  border-color: var(--line-selected);
  background: var(--brand-soft);
  color: var(--brand-hover);
}

body.saas-app button.management-text-action.danger,
body.saas-app .management-text-action.danger {
  border-color: var(--error-border);
  background: var(--surface-danger);
  color: var(--error-text);
  box-shadow: none;
}

body.saas-app button.management-text-action.danger:hover:not(:disabled),
body.saas-app .management-text-action.danger:hover:not(:disabled) {
  border-color: var(--error);
  background: var(--surface-danger);
  color: var(--error);
}

body.saas-app .management-table-scheduled-tasks .management-actions-cell {
  width: 216px;
  min-width: 216px;
  white-space: nowrap;
  text-align: right;
}

body.saas-app .management-table-scheduled-tasks .management-actions-cell > button + button {
  margin-left: var(--space-1);
}

/* Modal and form contract */
body.saas-app button.management-modal-close,
body.saas-app button.management-modal-close:hover:not(:disabled),
body.saas-app button.management-modal-close:active:not(:disabled) {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  box-shadow: none;
}

body.saas-app button.management-modal-close:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
}

body.saas-app button.management-modal-close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  background: var(--panel);
  color: var(--text);
  box-shadow: none;
}

body.saas-app .management-modal-card {
  border-color: var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

body.saas-app .management-modal-head,
body.saas-app .management-modal-footer {
  padding-right: 20px;
  padding-left: 20px;
}

body.saas-app .management-modal-body {
  padding: 20px;
}

body.saas-app .field {
  gap: 6px;
}

body.saas-app .field > label {
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  font-weight: 600;
}

body.saas-app textarea {
  resize: vertical;
}

/* Agent-scoped style libraries: shared by the current-user and external-user views. */
body.saas-app .user-reference-grid,
body.saas-app .external-style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  min-width: 0;
}

body.saas-app .user-reference-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 148px auto;
  align-items: end;
  gap: 12px;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

body.saas-app .user-reference-card-image,
body.saas-app .external-style-preview {
  width: 100%;
  height: 148px;
  grid-column: 1 / -1;
  display: block;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  object-fit: cover;
}

body.saas-app .external-style-preview {
  overflow: hidden;
}

body.saas-app .external-style-preview .user-reference-card-image {
  height: 100%;
  border-radius: inherit;
}

body.saas-app .user-reference-card-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

body.saas-app .user-reference-card-body strong,
body.saas-app .user-reference-card-body span,
body.saas-app .user-reference-card-body time {
  overflow-wrap: anywhere;
}

body.saas-app .user-reference-card-body span,
body.saas-app .user-reference-card-body time {
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

body.saas-app .user-reference-empty {
  grid-column: 1 / -1;
  padding: 32px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
}

/* Empty-state and runtime-detail contract */
body.saas-app .empty,
body.saas-app .platform-empty,
body.saas-app .management-empty-cell,
body.saas-app .execution-empty,
body.saas-app .run-record-detail-empty {
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
}

body.saas-app .trace-preview-text {
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  font-weight: 500;
  line-height: 1.6;
}

body.saas-app .trace-preview-text.trace-empty {
  color: var(--text-tertiary);
  font-style: normal;
}

body.saas-app .permission-request {
  border-color: var(--warn-border);
  background: var(--surface-warning);
  color: var(--text);
}

/* Authentication uses the same tokens without the application shell. */
body.auth-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

body.auth-page input,
body.auth-page select,
body.auth-page textarea {
  min-height: var(--control-height-lg);
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-sans);
}

body.auth-page button {
  min-height: var(--control-height-lg);
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--text-inverse);
  font-family: var(--font-sans);
  font-weight: 600;
}

body.auth-page button:hover:not(:disabled) {
  background: var(--brand-hover);
}

body.auth-page input:focus-visible,
body.auth-page button:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

@media (max-width: 1320px) {
  body.saas-app .management-table-projects {
    min-width: 840px;
  }

  body.saas-app .management-table-projects th:nth-child(1) {
    width: 176px;
  }

  body.saas-app .management-table-projects th:nth-child(4) {
    width: 168px;
  }

  body.saas-app .unified-resource-table {
    min-width: 860px;
  }
}

@media (max-width: 860px) {
  body.saas-app .head,
  body.saas-app .body,
  body.saas-app .resource-panels,
  body.saas-app .tab-panels {
    padding-right: 16px;
    padding-left: 16px;
  }

  body.saas-app .management-toolbar,
  body.saas-app .management-section-head,
  body.saas-app .management-summary-row {
    align-items: flex-start;
    flex-direction: column;
  }

  body.saas-app .management-summary-row {
    gap: 4px;
  }

  body.saas-app .management-summary-row > :last-child:not(:first-child) {
    text-align: left;
  }

  body.saas-app .management-filter-group,
  body.saas-app .management-toolbar-actions {
    width: 100%;
  }

  body.saas-app .management-filter-group > input,
  body.saas-app .management-filter-group > select {
    width: 100%;
    max-width: none;
  }

  body.saas-app .management-table-projects .management-actions-column,
  body.saas-app .unified-resource-table .management-actions-column {
    width: 136px;
    min-width: 136px;
  }

  body.saas-app .management-table .management-empty-cell {
    text-align: left !important;
  }
}

@media (max-width: 560px) {
  body.saas-app.saas-route-index #resource-tabs {
    gap: 18px;
    padding-right: 16px;
    padding-left: 16px;
  }

  body.saas-app .management-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.saas-app .management-span-2 {
    grid-column: auto;
  }

  body.saas-app .management-modal-card {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  body.saas-app .user-reference-grid,
  body.saas-app .external-style-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.saas-app .user-reference-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 180px auto auto;
    align-items: stretch;
  }

  body.saas-app .user-reference-card-image,
  body.saas-app .external-style-preview {
    height: 180px;
  }

  body.saas-app .user-reference-card > button {
    width: 100%;
  }
}

/* Required tool completion configuration, scoped to its own component. */
.required-tools-form td, .required-tools-progress { overflow-wrap: anywhere; }
.required-tools-form [data-required-summary] { margin-bottom: var(--space-3, 12px); }
.required-tools-dialog .required-tools-limit { margin: 16px 0; max-width: 240px; }
.required-tools-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, .4fr); gap: 12px; margin: 12px 0; }
.required-tools-choices { display: grid; align-content: start; gap: 8px; max-height: 38vh; min-height: 100px; overflow-y: scroll; overscroll-behavior: contain; scrollbar-gutter: stable; padding-right: 4px; }
.required-tools-group { position: sticky; top: 0; z-index: 1; padding: 8px; background: var(--surface, #f8fafc); font-weight: 600; border-bottom: 1px solid var(--border, #dde3ec); }
.required-tools-choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--border, #dde3ec); border-radius: 8px; }
.required-tools-choice input { flex: 0 0 auto; width: auto; margin-top: 4px; }
.required-tools-choice span { min-width: 0; overflow-wrap: anywhere; }
.required-tools-choice strong, .required-tools-choice .hint { display: block; }
.required-tools-progress { padding: 8px 0; }
.model-api-capabilities { margin-top: 8px; min-width: 190px; max-width: 290px; }
.model-api-capabilities summary { cursor: pointer; color: var(--color-text-secondary, #555); font-size: 12px; }
.model-api-capabilities fieldset { border: 1px solid var(--color-border, #ddd); border-radius: 8px; margin: 8px 0; padding: 8px; }
.model-api-capabilities legend, .model-api-capabilities label { font-size: 12px; }
.model-api-capabilities label { display: block; margin: 6px 0; }
.model-api-capabilities select { display: block; width: 100%; margin-top: 4px; }
tr:has(.model-api-capabilities) > td { vertical-align: top; }
@media (max-width: 600px) {
  .required-tools-filters { grid-template-columns: 1fr; }
  .required-tools-choices { max-height: 32vh; }
  .required-tools-form .management-section-head { align-items: flex-start; flex-direction: column; }
  .required-tools-dialog .management-modal-footer { flex-wrap: wrap; }
}
.model-probe-dialog {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  background: var(--panel);
  color: var(--text);
  line-height: 1.6;
}
.model-probe-dialog::backdrop { background: rgb(15 23 42 / 45%); }
.model-probe-dialog select { width: 100%; margin: 8px 0; }
.model-probe-dialog [data-probe-result] { border-block: 1px solid var(--line); margin: 12px 0; }
.model-probe-dialog [data-probe-result] p { margin: 8px 0; overflow-wrap: anywhere; }
.model-probe-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.model-probe-dialog .model-probe-consent { display: flex; gap: 10px; align-items: flex-start; }
.model-probe-dialog input[data-probe-consent] { width: 18px; height: 18px; min-height: 18px; flex: 0 0 18px; margin: 3px 0 0; padding: 0; }
.management-table-actions:has([data-model-probe-profile]) { flex-wrap: wrap; gap: 6px 10px; }

.skill-invocation-editor { border: 1px solid var(--border-color, #d6dde5); border-radius: 8px; padding: 12px; margin-top: 12px; min-width: 0; max-width: 100%; }
.skill-invocation-editor summary { cursor: pointer; font-weight: 600; }
.skill-invocation-editor .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 12px 0; }
.skill-invocation-editor .field { margin: 12px 0; }
.skill-invocation-editor label { display: block; min-width: 0; }
.skill-invocation-editor input, .skill-invocation-editor select, .skill-invocation-editor textarea { box-sizing: border-box; max-width: 100%; }
.skill-invocation-editor textarea { display: block; width: 100%; min-height: 110px; font-family: monospace; }
.skill-invocation-editor pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 400px; overflow: auto; font-size: 12px; }
@media (max-width: 600px) { .skill-invocation-editor .row > * { width: 100%; } }

/* Imported SKILL diagnostics remain readable when expanded in compact tables. */
.skill-readiness-status > .management-cell-secondary {
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
  max-width: 380px;
}
.skill-readiness-status > summary { cursor: pointer; }

/* SKILL verification dialogs remain inside their own scrollable viewport. */
.skill-verifier-dialog { width: min(820px, calc(100vw - 32px)); max-height: 88dvh; padding: 0; border: 1px solid var(--border-color, #dbe1ea); border-radius: 12px; color: inherit; background: var(--bg-card, #fff); }
.skill-verifier-dialog::backdrop { background: #11182766; }
.skill-verifier-dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; position: sticky; top: 0; background: #fff; z-index: 1; border-bottom: 1px solid #e5e7eb; }
.skill-verifier-dialog h2 { margin: 0; font-size: 20px; }
.skill-verifier-body { padding: 16px; overflow-wrap: anywhere; }
.skill-verifier-body form { display: grid; gap: 14px; }
.skill-verifier-body label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.skill-verifier-body label > textarea, .skill-verifier-body label > select, .skill-verifier-body label > input[type=number] { width: 100%; min-width: 0; }
.skill-verifier-body label > input[type=checkbox] { width: auto; order: -1; }
.skill-verifier-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; max-width: 100%; }
.skill-verifier-body .status { white-space: pre-wrap; }
.skill-verifier-panel { margin: 12px 0; padding: 12px; border: 1px solid #e5e7eb; border-radius: 8px; }
.skill-verifier-panel > button { margin: 4px 8px 4px 0; }
.skill-verifier-actions, .skill-verifier-job { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }

.skill-verifier-body label:has(input[type=checkbox]) { flex-wrap: nowrap; }
.skill-verifier-body form > button[type=submit] { position: sticky; bottom: 0; z-index: 1; }

/* Scoped to the two Tool wrapper editors. */
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table { min-width: 0; width: 100%; table-layout: fixed; }
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table th:nth-child(1),
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table th:nth-child(2) { width: 22%; }
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table th:nth-child(3) { width: 34%; }
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table th:nth-child(4) { width: 14%; }
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table th:nth-child(5) { width: 8%; }
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table td { vertical-align: top; }
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table input,
body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table select { min-width: 0; width: 100%; box-sizing: border-box; }
body.saas-app #tool-wrapper-modal .tool-wrapper-transform label { display: block; margin-bottom: 8px; font-size: 12px; }
body.saas-app #tool-wrapper-modal .tool-wrapper-transform .hint { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table thead { display: none; }
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table,
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table tbody,
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table tr,
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table td { display: block; width: 100%; box-sizing: border-box; }
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table tr { border-bottom: 2px solid var(--line); }
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table td::before { content: attr(data-label); display: block; color: var(--text-secondary); font-size: 12px; margin-bottom: 4px; }
  body.saas-app #tool-wrapper-modal .tool-wrapper-fields-table td.tool-wrapper-transform::before { display: none; }
}

@media (max-width: 700px) {
  .model-profile-editor-modal .model-request-extensions {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Model configuration cards keep their controls mounted while collapsed. */
.model-profile-editor-modal .model-profile-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.model-profile-editor-modal .model-profile-toggle:hover:not(:disabled) {
  background: transparent;
  color: var(--brand);
}

.model-profile-editor-modal .model-profile-toggle .management-cell-code {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
}

.model-profile-editor-modal .model-profile-toggle-label {
  flex: none;
  color: var(--text-secondary);
  font-size: 12px;
}

.model-profile-editor-modal .model-profile-chevron {
  flex: none;
  transition: transform 0.15s ease;
}

.model-profile-editor-modal [aria-expanded="true"] .model-profile-chevron {
  transform: rotate(90deg);
}

.model-profile-editor-modal tr[data-model-expanded="false"] .model-profile-identity {
  padding-bottom: 0;
  border-bottom: 0;
}

.model-profile-editor-modal .model-capability-table td[hidden] {
  display: none;
}

.model-profile-editor-modal .model-profile-summary {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.model-profile-editor-modal .model-profile-summary > div {
  display: inline-flex;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.model-profile-editor-modal .model-profile-summary dt {
  flex: none;
  color: var(--text-secondary);
}

.model-profile-editor-modal .model-profile-summary dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.model-profile-editor-modal tr[data-model-expanded="true"] .model-profile-summary {
  display: none;
}
