:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: #263752;
  background: #e8effc;
  font-synthesis: none;
  --ink: #263752;
  --muted: #7183a1;
  --line: #e1e7f1;
  --line-strong: #ccd6e5;
  --canvas: #e8effc;
  --surface: #ffffff;
  --surface-soft: #f5f8fd;
  --brand: #3e587f;
  --brand-dark: #30486d;
  --brand-soft: #e4ebf6;
  --accent: #41648f;
  --danger: #b54747;
  --warning: #a66a22;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; color: #2f486f; font-size: 22px; font-weight: 700; }
h2 { margin-bottom: 0; color: #304a72; font-size: 18px; font-weight: 700; }
h3 { margin-bottom: 0; color: #314b72; font-size: 15px; }

.app-shell {
  min-height: 100vh;
  padding: 14px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: 72px minmax(0, 1fr);
  grid-template-areas: "header header" "sidebar main";
  gap: 16px 18px;
}

.topbar {
  grid-area: header;
  min-width: 0;
  padding: 0 18px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgb(255 255 255 / 56%);
  border: 1px solid #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgb(84 113 160 / 8%);
}
.topbar-brand { min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar-brand strong, .topbar-brand small { display: block; }
.topbar-brand strong { color: #2f3e55; font-size: 15px; }
.topbar-brand small { margin-top: 1px; color: #8090a7; font-size: 9px; letter-spacing: 1px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #79c8da;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 5px 12px rgb(86 173 194 / 20%);
}
.menu-button { width: 36px; height: 36px; margin-left: 64px; border: 0; color: #52657f; background: transparent; font-size: 21px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.environment { padding: 7px 11px; color: #4c6385; background: #fff; border: 1px solid #d8e1ee; border-radius: 18px; font-size: 12px; white-space: nowrap; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; color: #425879; border: 0; background: transparent; border-radius: 50%; }
.icon-button:hover { background: #edf2fa; }
.user-pill { min-height: 42px; padding: 5px 12px 5px 5px; display: flex; align-items: center; gap: 7px; color: #37475f; background: rgb(255 255 255 / 72%); border-radius: 24px; box-shadow: 0 6px 18px rgb(71 99 144 / 10%); font-size: 13px; white-space: nowrap; }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; color: #fff; background: #e17f75; border-radius: 50%; font-weight: 700; }

.sidebar {
  grid-area: sidebar;
  min-height: 0;
  padding: 14px 12px;
  overflow: auto;
  color: #617697;
  background: rgb(255 255 255 / 60%);
  border: 1px solid #fff;
  border-radius: 16px;
}
.main-nav { display: grid; gap: 3px; }
.nav-item { width: 100%; padding: 11px 14px; border: 0; color: #657a9b; background: transparent; border-radius: 20px; text-align: left; font-weight: 600; }
.nav-item:hover { color: #3c557b; background: #edf2fa; }
.nav-parent { display: flex; justify-content: space-between; align-items: center; }
.nav-group { margin: 3px 0; padding-bottom: 7px; background: #fff; border-radius: 18px; }
.nav-parent.active { color: #fff; background: var(--brand); box-shadow: 0 6px 14px rgb(53 78 116 / 20%); }
.sub-nav { display: grid; gap: 1px; padding: 9px 10px 2px 30px; }
.sub-nav-item { padding: 9px 10px; border: 0; color: #63799c; background: transparent; border-radius: 8px; text-align: left; font-weight: 600; }
.sub-nav-item:hover { color: #334f78; background: #f3f6fb; }
.sub-nav-item.active { color: #344f79; background: #e8eef7; }

.workspace { grid-area: main; min-width: 0; min-height: 0; overflow: auto; padding: 2px 0 24px; }
.page-heading { display: flex; flex-direction: column-reverse; gap: 4px; margin: 4px 0 12px; }
.breadcrumb { color: #8997ad; font-size: 11px; }
.view, .gateway-tab, .monitor-tab, .connection-tab, .sub-page { display: none; }
.view.active, .gateway-tab.active, .monitor-tab.active, .connection-tab.active, .sub-page.active { display: block; }
.section-head { min-height: 42px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-actions { display: flex; align-items: center; gap: 12px; }
.section-kicker { margin-bottom: 4px; color: #7b8ca7; font-size: 11px; }
.panel { border: 0; background: transparent; }
.section-block { margin-bottom: 16px; padding: 18px; background: #fff; border: 1px solid #fff; border-radius: 18px; box-shadow: 0 7px 20px rgb(79 105 146 / 5%); }
.block-head { margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.primary-button, .secondary-button, .danger-button, .back-button {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.primary-button { color: #fff; background: var(--brand); box-shadow: 0 5px 12px rgb(55 79 116 / 14%); }
.resource-download { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button, .back-button { color: #3f5d87; background: #fff; border-color: #d5deeb; }
.secondary-button:hover, .back-button:hover { background: #f5f8fc; }
.danger-button { color: #fff; background: var(--danger); }
.back-button { margin: 0 0 12px; }
.text-button { padding: 2px 4px; border: 0; color: #35577f; background: transparent; white-space: nowrap; }
.text-button:hover { color: #203e68; }
.text-button.danger { color: var(--danger); }

.toolbar {
  min-height: 92px;
  margin-bottom: 18px;
  padding: 16px;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  border: 1px solid #fff;
  border-radius: 18px;
  box-shadow: 0 7px 20px rgb(79 105 146 / 5%);
}
.toolbar::before { content: "查询"; flex: 0 0 100%; color: #3d4d64; font-size: 13px; font-weight: 600; }
.toolbar-between { justify-content: space-between; }
.toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.search-control { height: 36px; min-width: 310px; display: flex; align-items: center; overflow: hidden; background: #fff; border: 1px solid var(--line-strong); border-radius: 3px; }
.search-control.wide { min-width: 390px; }
.search-control span { padding: 0 10px; color: #8290a4; border-right: 1px solid var(--line); font-size: 11px; white-space: nowrap; }
.search-control input { width: 100%; min-width: 0; padding: 8px 10px; color: #34465f; border: 0; outline: 0; }
.search-control input::placeholder { color: #a2adbd; }
select { height: 36px; padding: 0 30px 0 10px; color: #536780; background: #fff; border: 1px solid var(--line-strong); border-radius: 3px; }
.result-count { margin-left: auto; color: #8391a4; font-size: 11px; white-space: nowrap; }

.table-wrap { width: 100%; max-height: 610px; padding: 14px 16px 18px; overflow: auto; background: #fff; border: 1px solid #fff; border-radius: 18px; box-shadow: 0 7px 20px rgb(79 105 146 / 5%); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; color: #334158; font-size: 12px; white-space: nowrap; }
.app-table { min-width: 1380px; }
.capability-table { min-width: 1920px; }
.monitor-table { min-width: 1760px; }
.data-table th { position: sticky; top: -14px; z-index: 1; padding: 12px 14px; color: #7a8799; background: #fafbfc; font-weight: 600; text-align: left; }
.data-table th + th { border-left: 1px solid #eef1f5; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #e8edf4; }
.data-table tbody tr:hover td { background: #f8faff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.sticky-action { position: sticky !important; right: -16px; z-index: 2 !important; background: #fafbfc !important; box-shadow: -12px 0 16px -16px #536987; }
td.sticky-action { background: #fff !important; }
.action-cell { display: flex; gap: 6px; }
.code { color: #3e628e; font-family: "SFMono-Regular", Consolas, monospace; }
.status-pill, .channel-pill, .result-pill { display: inline-flex; align-items: center; padding: 3px 8px; border: 1px solid #d8e0ec; border-radius: 12px; color: #526681; background: #f5f7fb; font-size: 11px; }
.status-pill.success, .result-pill.success { color: #41735f; background: #edf7f2; border-color: #cce5da; }
.status-pill.warning, .result-pill.warning { color: #94631f; background: #fff7e9; border-color: #ead7b4; }
.result-pill.danger { color: #9e4747; background: #fff1f1; border-color: #edcece; }
.channel-pill { color: #3e5f8a; background: #edf2f9; border-color: #d5e0ee; }
.empty-row { padding: 30px !important; color: #8290a4; text-align: center; }
.header-filter { display: flex; align-items: center; gap: 7px; }
.header-filter > span { white-space: nowrap; }
.header-filter select { width: 74px; height: 28px; padding: 0 22px 0 7px; color: #596d88; background-color: #fff; border-color: #d8e0eb; font-size: 11px; font-weight: 400; }
.sortable-head { display: inline-flex; align-items: center; gap: 5px; }
.sort-button { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; color: #8795a8; background: transparent; border: 0; border-radius: 50%; }
.sort-button:hover { color: #3e587f; background: #e9eef6; }
.sort-button.active { color: #fff; background: var(--brand); }

.tabs, .segmented { padding: 3px; display: inline-flex; background: rgb(255 255 255 / 50%); border: 0; border-radius: 22px; }
.tab-button, .segmented button { min-width: 112px; padding: 7px 14px; color: #667794; background: transparent; border: 0; border-radius: 18px; white-space: nowrap; }
.tab-button.active, .segmented button.active { color: #fff; background: var(--brand); font-weight: 600; box-shadow: 0 5px 12px rgb(52 76 112 / 14%); }
.policy-callout { margin-bottom: 14px; padding: 11px 14px; color: #765727; background: #fff8ed; border-left: 3px solid #c99043; font-size: 12px; }

.overview-toolbar { margin-bottom: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: #7788a2; font-size: 11px; }
.metrics-grid { margin-bottom: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { padding: 17px 18px; background: #fff; border: 1px solid #fff; border-radius: 18px; box-shadow: 0 7px 20px rgb(79 105 146 / 5%); }
.metric-card span, .metric-card small { display: block; color: #7b8ba1; font-size: 11px; }
.metric-card strong { display: block; margin: 8px 0 4px; color: #334e76; font-size: 25px; }
.metric-card small.positive { color: #4c7e68; }
.metric-card small.negative { color: #a75858; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.legend, .line-legend { display: flex; gap: 12px; color: #7b8aa0; font-size: 11px; }
.legend span::before, .line-legend span::before { content: ""; width: 8px; height: 8px; margin-right: 5px; display: inline-block; border-radius: 2px; }
.success-dot::before { background: #587fae; }
.failure-dot::before { background: #d08a83; }
.line-legend { margin-top: 12px; justify-content: center; flex-wrap: wrap; }
.line-legend .rest::before { background: #3e587f; }
.line-legend .event::before { background: #668eb6; }
.line-legend .mcp::before { background: #d19a55; }
.line-legend .cli::before { background: #8b77a7; }
.bar-chart { height: 250px; padding: 18px 8px 28px; display: flex; align-items: end; justify-content: space-around; gap: 10px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bar-group { position: relative; flex: 1; max-width: 56px; height: 100%; display: flex; align-items: end; justify-content: center; gap: 4px; }
.bar { width: 15px; min-height: 4px; border-radius: 2px 2px 0 0; }
.bar.success { height: var(--height); background: #587fae; }
.bar.failure { height: var(--height); background: #d08a83; }
.bar-label { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); color: #8491a4; font-size: 10px; }
.line-chart { position: relative; height: 250px; overflow: hidden; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.line-chart::before { content: ""; position: absolute; inset: 25% 0 auto; height: 1px; background: #edf1f6; box-shadow: 0 50px #edf1f6, 0 100px #edf1f6; }
.line { position: absolute; inset: 12% 4% 10%; }
.line svg { width: 100%; height: 100%; overflow: visible; }
.line polyline { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.line.rest polyline { stroke: #3e587f; }
.line.event polyline { stroke: #668eb6; }
.line.mcp polyline { stroke: #d19a55; }
.line.cli polyline { stroke: #8b77a7; }

.drawer { position: fixed; inset: 0; z-index: 20; display: none; justify-content: flex-end; background: rgb(30 45 67 / 35%); }
.drawer.open { display: flex; }
.drawer-panel { width: min(660px, 100vw); height: 100%; display: flex; flex-direction: column; background: #f6f8fc; box-shadow: -14px 0 34px rgb(42 61 90 / 18%); }
.drawer-head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.drawer-head p { margin-bottom: 4px; color: #8190a5; font-size: 11px; }
.drawer-body { padding: 20px; overflow: auto; }
.helper-box { margin-bottom: 18px; padding: 14px; background: #edf3fb; border: 1px solid #d5e1ef; border-radius: 12px; }
.helper-actions { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.helper-box p { margin-bottom: 0; color: #657894; font-size: 12px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; color: #4f627e; font-size: 12px; }
.field.full { grid-column: 1 / -1; }
.application-form-grid > .field:not(.full) { grid-template-rows: 16px 36px 14px; align-content: start; }
.application-form-grid > .field:not(.full) > input,
.application-form-grid > .field:not(.full) > select { height: 36px; }
.application-form-grid > .field:not(.full) > .field-hint,
.application-form-grid > .field:not(.full) > .field-count { grid-row: 3; align-self: start; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; }
.field textarea { min-height: 86px; resize: vertical; }
.field input[readonly] { color: #7a899e; background: #edf1f6; }
.field-hint, .field-count { color: #8795a8; font-size: 10px; font-weight: 400; }
.field-count { justify-self: end; margin-top: -2px; }
.required::after { content: " *"; color: var(--danger); }
.drawer-actions { margin-top: 20px; padding-top: 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.resource-list { display: grid; gap: 10px; }
.resource-row { padding: 11px 0; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; border-bottom: 1px solid var(--line); }
.resource-row span { color: #7a899e; font-size: 12px; }
.resource-row code { overflow-wrap: anywhere; white-space: normal; }
.resource-value { min-width: 0; display: flex; align-items: center; gap: 8px; }
.resource-value code { min-width: 0; flex: 1; }
.secret-toggle { position: relative; width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; padding: 0; color: #627896; background: transparent; border: 0; border-radius: 4px; cursor: pointer; }
.secret-toggle:hover { color: #35557e; background: #edf3fb; }
.secret-toggle:focus-visible { outline: 2px solid #6e8db6; outline-offset: 1px; }
.secret-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.secret-toggle.revealed::after { content: ""; position: absolute; width: 18px; height: 1.5px; background: currentColor; transform: rotate(45deg); border-radius: 1px; }
.connection-actions { margin-bottom: 18px; display: grid; gap: 10px; }
.resource-action-card { padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border: 1px solid #dce4ef; border-radius: 12px; }
.resource-action-card div { min-width: 0; }
.resource-action-card strong, .resource-action-card span { display: block; }
.resource-action-card strong { margin-bottom: 4px; color: #3b5275; font-size: 13px; }
.resource-action-card span { color: #7b8ba1; font-size: 11px; line-height: 1.5; }
.connection-tip { margin: 2px 0 0; padding: 10px 12px; color: #667b98; background: #edf3fb; border-left: 3px solid #6685ad; border-radius: 4px; font-size: 11px; line-height: 1.6; }
.request-code { padding: 14px; color: #dce5f1; background: #263752; border-radius: 8px; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.modal { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 20px; background: rgb(30 45 67 / 35%); }
.modal.open { display: flex; }
.modal-panel { width: min(440px, 100%); padding: 22px; background: #fff; border-radius: 16px; box-shadow: 0 20px 48px rgb(39 58 86 / 20%); }
.modal-panel p { margin: 12px 0 22px; color: #65758d; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: none; padding: 10px 14px; color: #fff; background: var(--brand-dark); border-radius: 18px; box-shadow: 0 8px 24px rgb(40 58 86 / 20%); font-size: 12px; }
.toast.show { display: block; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); gap: 12px; }
  .menu-button { margin-left: 24px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-shell { display: block; padding: 10px; }
  .topbar { min-height: 64px; padding: 8px 12px; }
  .menu-button, .topbar-actions .icon-button, .topbar-actions .user-pill { display: none; }
  .sidebar { margin-top: 10px; padding: 10px; }
  .main-nav > .nav-item:not(.nav-parent), .main-nav > .nav-group ~ .nav-item { display: none; }
  .sub-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px 6px 1px; }
  .sub-nav-item { padding: 8px 3px; text-align: center; font-size: 11px; }
  .workspace { margin-top: 12px; padding-bottom: 20px; overflow: visible; }
  .page-heading { margin-bottom: 10px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .section-head > .primary-button, .section-head > .tabs, .section-actions { width: 100%; }
  .section-actions { justify-content: space-between; }
  .tabs .tab-button { min-width: 0; flex: 1; }
  .toolbar, .toolbar-group { align-items: stretch; flex-direction: column; }
  .toolbar-between { align-items: stretch; }
  .search-control, .search-control.wide, select, .toolbar .primary-button { width: 100%; min-width: 0; }
  .header-filter select { width: 74px; min-width: 74px; }
  .result-count { margin-left: 0; }
  .table-wrap { padding: 10px; border-radius: 14px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .application-form-grid > .field:not(.full) { grid-template-rows: auto; }
  .application-form-grid > .field:not(.full) > .field-hint,
  .application-form-grid > .field:not(.full) > .field-count { grid-row: auto; }
  .resource-row { grid-template-columns: 1fr; gap: 4px; }
  .resource-action-card { align-items: stretch; flex-direction: column; }
  .resource-action-card button { width: 100%; }
  .helper-actions .secondary-button { width: 100%; }
  .app-table .sticky-action { width: 154px; max-width: 154px; }
  .app-table .action-cell { width: 130px; flex-wrap: wrap; row-gap: 6px; }
}

@media (max-width: 430px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card strong { font-size: 22px; }
  .bar-chart, .line-chart { height: 220px; }
}
