* { box-sizing: border-box; }

:root {
  --primary: #6755e7;
  --primary-soft: #f0eeff;
  --border: #e3e6ef;
  --text: #252836;
  --muted: #727789;
  --bg: #f5f6fa;
  --danger: #d14343;
  --success: #25835d;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: #fff;
  background: linear-gradient(110deg, #5642d5, #7d6bf0);
  box-shadow: 0 5px 18px rgba(70, 53, 174, .22);
}

.brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: rgba(255, 255, 255, .18); }
.top-credentials-button { display: inline-flex; align-items: center; gap: 9px; height: 36px; border-color: rgba(255, 255, 255, .35); color: #fff; background: rgba(255, 255, 255, .12); }
.top-credentials-button:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, .2); }
.credentials-dot { width: 9px; height: 9px; border: 2px solid rgba(255, 255, 255, .72); border-radius: 50%; background: #aeb2c0; box-shadow: 0 0 0 2px rgba(0, 0, 0, .08); }
.credentials-dot.active { border-color: #bff5d8; background: #36c77a; }

main { width: min(1760px, 100%); margin: 0 auto; padding: 22px; }
.card { margin-bottom: 18px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 3px 14px rgba(39, 43, 65, .05); }
.card-head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 20px; border-bottom: 1px solid var(--border); }
h2 { margin: 0; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 16px; padding: 20px; }
label { display: block; margin-bottom: 7px; color: #565b6c; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid #d8dbe5; border-radius: 7px; color: var(--text); background: #fff; outline: none; }
input, select { height: 39px; padding: 0 11px; }
textarea { min-height: 270px; padding: 13px; resize: vertical; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(103, 85, 231, .1); }
input[readonly] { color: #74798a; background: #f4f5f8; cursor: not-allowed; }
.actions { display: flex; align-items: center; gap: 10px; padding: 0 20px 20px; }
button { height: 39px; padding: 0 18px; border: 1px solid #d9dce6; border-radius: 7px; color: #424657; background: #fff; cursor: pointer; }
button:hover { border-color: #a9a1ed; color: var(--primary); }
button.primary { border-color: var(--primary); color: #fff; background: var(--primary); }
button:disabled { opacity: .58; cursor: not-allowed; }
.status { margin-left: auto; color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }
.summary { display: flex; flex-wrap: wrap; gap: 24px; padding: 15px 20px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.summary b { color: var(--text); }
.batch-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: #fafaff; }
.batch-bar label { margin-bottom: 5px; }
.batch-field { width: 180px; }
.batch-field input { height: 36px; }
.batch-status { color: var(--muted); font-size: 13px; }
.batch-status.error { color: var(--danger); }
button.batch { height: 36px; border-color: var(--primary); color: #fff; background: var(--primary); }
.selection { min-width: 88px; color: #565b6c; font-size: 13px; line-height: 36px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
th.checkbox, td.checkbox { width: 45px; padding-left: 18px; padding-right: 8px; cursor: default; }
.table-wrap { overflow: auto; max-height: 560px; }
table { width: 100%; min-width: 1450px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 12px 13px; border-bottom: 1px solid #eceef4; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: #5b6070; background: #fafbfe; font-weight: 600; user-select: none; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--primary); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.name { color: #5545c8; font-weight: 600; }
.sub { margin-top: 4px; color: #9a9eab; font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 12px; color: #31825d; background: #edf9f3; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #4dc682; }
.empty { padding: 60px; color: var(--muted); text-align: center; }
.inspect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px; }
details { border: 1px solid var(--border); border-radius: 9px; background: #fbfbfd; overflow: hidden; }
summary { padding: 12px 15px; cursor: pointer; font-size: 13px; font-weight: 600; }
pre { max-height: 440px; margin: 0; padding: 15px; overflow: auto; border-top: 1px solid var(--border); color: #343849; background: #f7f8fb; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.advanced { padding: 0 20px 20px; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(24, 25, 37, .48); backdrop-filter: blur(2px); }
.modal-panel { position: relative; width: min(720px, 100%); border: 1px solid var(--border); border-radius: 13px; background: #fff; box-shadow: 0 24px 70px rgba(23, 24, 39, .25); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-close { width: 34px; height: 34px; padding: 0; border: 0; font-size: 23px; line-height: 1; }
.credentials-form { display: grid; gap: 16px; padding: 20px; }
.security-note { margin: 0; padding: 11px 13px; border: 1px solid #eadfb5; border-radius: 8px; color: #725d1f; background: #fffaf0; font-size: 13px; line-height: 1.55; }
.credential-field { min-width: 240px; }
.optional { color: var(--muted); font-weight: 400; }
.inline-input { display: flex; gap: 8px; }
.inline-input button { flex: 0 0 auto; }
.credentials-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.credentials-status { color: var(--muted); font-size: 13px; }
.credentials-status.saved { color: var(--success); }
.credentials-status.error { color: var(--danger); }

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .inspect-grid { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  main { padding: 10px; }
  .topbar { padding: 0 15px; }
  .filters { grid-template-columns: 1fr 1fr; gap: 12px; }
  .actions, .credentials-actions { flex-wrap: wrap; }
  .status { width: 100%; margin: 4px 0 0; }
  .inspect-grid { padding: 10px; }
}
