/* ============================================================
   Profiles
   ============================================================ */

.config-grid {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 20px;
}
@media (max-width: 1040px) {
  .config-grid { grid-template-columns: 1fr; }
}

.profile-list-panel,
.summary-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}

.config-grid .span-all { grid-column: 1 / -1; }

.system-default-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.4fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.system-default-panel h3 { margin: 2px 0 4px; font-size: 16px; }
.system-default-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
}
.system-default-title {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.system-default-title .chip {
  padding: 2px 8px;
  border-radius: 0;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11.5px;
}
.system-default-title .chip.ok { color: var(--success); background: var(--success-soft); }
.system-default-title .chip.err { color: var(--danger); background: var(--danger-soft); }
.system-default-title .chip.info { color: var(--brand); background: var(--brand-soft); }
.system-default-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px 10px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}
.system-default-grid code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.system-default-grid strong { font-weight: 600; color: var(--text); }
.system-default-grid em { font-style: normal; color: var(--text-faint); }
.system-default-actions {
  display: flex;
  gap: 8px;
  flex-direction: column;
  align-items: flex-start;
}
.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: var(--radius-btn);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease, color 120ms ease;
}
.switch-row:hover {
  background: var(--surface);
  color: var(--text);
}
.switch-row span {
  line-height: 1.5;
}
.profile-form.is-muted {
  opacity: 0.62;
}
.profile-form.is-muted::before {
  content: "当前使用系统默认接口；开启上方“覆盖系统默认”后可编辑个人接口。";
  display: block;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-btn);
  color: var(--text-muted);
  background: var(--surface-2);
  font-size: 13px;
}
@media (max-width: 1040px) {
  .system-default-panel { grid-template-columns: 1fr; }
  .system-default-actions { flex-direction: row; flex-wrap: wrap; }
}

.profile-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.profile-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  font: inherit; color: var(--text);
  transition: border-color 120ms ease, background 120ms ease;
}
.profile-item:hover { border-color: var(--border-strong); }
.profile-item.active { border-color: var(--brand); background: var(--brand-soft); }
.profile-item strong {
  min-width: 0;
  max-width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.profile-item small { display: block; color: var(--text-faint); font-size: 11.5px; margin-top: 2px; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 0;
  background: var(--surface-3);
  color: var(--text-muted);
  font-style: normal;
}
.badge.active { background: var(--success-soft); color: var(--success); }
.badge.draft { background: var(--warning-soft); color: var(--warning); }
.badge.paused { background: var(--surface-3); color: var(--text-faint); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.form-grid .span-2 { grid-column: span 2; }

.config-section {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-2);
}
.config-section h3 {
  margin: 0 0 4px;
  font-size: 14px;
}
.config-section .hint { margin: 0; }

.test-result {
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-btn);
  color: var(--text-faint);
  font-size: 13px;
  font-family: var(--font-mono);
}
.test-result[data-state="ok"]   { color: var(--success); border-color: var(--success); background: var(--success-soft); border-style: solid; }
.test-result[data-state="err"]  { color: var(--danger);  border-color: var(--danger);  background: var(--danger-soft);  border-style: solid; }
.test-result[data-state="busy"] { color: var(--brand);   border-color: var(--brand);   background: var(--brand-soft);   border-style: solid; }

.summary-grid {
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
.summary-grid > div {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
}
.summary-grid span { color: var(--text-faint); font-size: 12px; }
.summary-grid strong { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.summary-note { margin: 14px 0 0; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .profile-list-panel,
  .summary-panel,
  .system-default-panel {
    padding: 12px;
  }
  .system-default-card,
  .config-section { padding: 10px; }
  .system-default-grid {
    grid-template-columns: auto minmax(0, 1fr) minmax(0, .7fr) auto;
    gap: 6px;
  }
  .system-default-grid strong,
  .system-default-grid em {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .system-default-actions {
    width: 100%;
    align-items: stretch;
  }
  .system-default-actions > * {
    min-height: 44px;
  }
  .system-default-actions > button { width: 100%; }
  .switch-row {
    min-height: 44px;
    padding: 7px 8px;
  }
  .profile-item { min-height: 44px; }
  #configPanel .profile-form > .action-row > button {
    min-height: 44px;
    flex: 1 1 calc(50% - 4px);
  }
  .summary-grid > div {
    min-width: 0;
    gap: 10px;
  }
  .summary-grid strong {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
  }
}
