:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --sidebar: #182532;
  --sidebar-active: #29445b;
  --line: #d8dee6;
  --text: #18212b;
  --muted: #647181;
  --accent: #1769aa;
  --accent-soft: #e8f2fa;
  --good: #177245;
  --good-soft: #e7f5ee;
  --warn: #9a6500;
  --warn-soft: #fff3d6;
  --bad: #b4232f;
  --bad-soft: #fdebed;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 28px; }
h2 { font-size: 15px; line-height: 22px; }
h3 { margin-top: 18px; font-size: 13px; line-height: 20px; }

button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
button:disabled { opacity: 0.58; cursor: wait; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid #72aee0; outline-offset: 2px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f5;
}
.login-panel {
  width: min(380px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 14px 40px rgba(24, 33, 43, 0.1);
}
.login-brand { color: var(--accent); font-size: 13px; font-weight: 700; }
.login-panel h1 { margin-top: 5px; }
.login-panel > p { margin-top: 4px; color: var(--muted); }
.login-panel label { display: block; margin-top: 20px; }
.login-panel label span { display: block; margin-bottom: 7px; color: #3d4a57; font-size: 12px; font-weight: 600; }
.login-panel input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid #bdc7d2;
  border-radius: 4px;
  color: var(--text);
  background: #fff;
}
.login-panel > button { width: 100%; margin-top: 22px; height: 40px; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--bad); font-size: 12px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 208px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  color: #eef5fa;
  background: var(--sidebar);
}
.brand-block { min-height: 72px; padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-block strong { display: block; font-size: 17px; }
.brand-block span { display: block; margin-top: 2px; color: #aebdca; font-size: 12px; }
.sidebar nav { padding: 12px 10px; display: grid; gap: 4px; }
.sidebar nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 4px;
  color: #d7e2ea;
  text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); }
.sidebar nav a.active { color: #fff; background: var(--sidebar-active); font-weight: 600; }
.account-block {
  margin-top: auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #d7e2ea;
  font-size: 12px;
}
.text-button { min-height: auto; padding: 4px; border: 0; color: #aebdca; background: transparent; }
.text-button:hover { color: #fff; }

.content-shell { min-width: 0; }
.topbar {
  min-height: 72px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar p { color: var(--muted); font-size: 12px; }
main { min-width: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
}
.metrics div {
  min-height: 74px;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.metrics div:nth-child(4n) { border-right: 0; }
.metrics div:nth-child(n+5) { border-bottom: 0; }
.metrics span { color: var(--muted); font-size: 12px; }
.metrics strong { margin-top: 3px; font-size: 21px; line-height: 27px; }

.workspace {
  margin-top: 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.section-heading {
  min-height: 48px;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.section-heading > span { color: var(--muted); font-size: 12px; }
.version-pending { color: var(--warn); font-weight: 600; }
.filters { display: flex; align-items: center; gap: 8px; }
button.filter { min-height: 30px; padding: 0 10px; color: var(--text); background: #fff; border-color: var(--line); }
button.filter.active { color: var(--accent); background: var(--accent-soft); border-color: #9dc5e3; }
button.redrive { min-height: 28px; padding: 0 10px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.nodes-table { min-width: 1080px; }
.jobs-table { min-width: 1040px; }
.outbox-table { min-width: 760px; }
th, td {
  height: 42px;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e8ecf0;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
th { color: var(--muted); background: #fafbfc; font-size: 12px; font-weight: 600; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
.jobs-wrap tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }

.jobs-page { padding: 12px 0 40px; }
.jobs-workspace { margin-top: 0; }
.jobs-toolbar {
  min-height: 58px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.job-search { display: flex; align-items: center; gap: 8px; width: min(460px, 100%); }
.job-search input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid #bdc7d2;
  border-radius: 4px;
  color: var(--text);
  background: #fff;
}
.pagination {
  min-height: 54px;
  padding: 9px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}
.pagination > div { display: flex; gap: 8px; }
.secondary-button { color: var(--text); border-color: var(--line); background: #fff; }
.secondary-button:disabled { cursor: default; }

.status {
  display: inline-flex;
  min-width: 68px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.status.good { color: var(--good); background: var(--good-soft); }
.status.warn { color: var(--warn); background: var(--warn-soft); }
.status.bad { color: var(--bad); background: var(--bad-soft); }
.status.neutral { color: var(--muted); background: #eef1f4; }
.leg-status { display: flex; align-items: center; gap: 8px; }
.leg-status small { color: var(--muted); font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.docs-page { padding: 20px 24px 40px; }
.docs-intro {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}
.docs-intro div { min-height: 70px; padding: 14px 16px; border-right: 1px solid var(--line); }
.docs-intro div:last-child { border-right: 0; }
.docs-intro span { display: block; color: var(--muted); font-size: 12px; }
.docs-intro strong { display: block; margin-top: 6px; font-size: 15px; overflow-wrap: anywhere; }
.doc-section {
  max-width: 1040px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.doc-section p { max-width: 900px; margin-top: 9px; color: #4e5c6a; line-height: 1.7; }
code { padding: 2px 5px; border-radius: 3px; color: #175a8c; background: #edf4f8; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-block { position: relative; margin-top: 12px; border: 1px solid #ccd5df; border-radius: 5px; background: #17212b; }
.code-block pre {
  margin: 0;
  padding: 16px 72px 16px 16px;
  max-height: 540px;
  overflow: auto;
  color: #eef4f8;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}
.copy-button { position: absolute; z-index: 1; top: 9px; right: 9px; min-height: 28px; padding: 0 9px; border-color: #506477; color: #edf4f8; background: #263746; font-size: 12px; }
.endpoint-list { margin-top: 12px; border: 1px solid var(--line); background: var(--surface); }
.endpoint-list div { min-height: 48px; padding: 11px 14px; display: grid; grid-template-columns: minmax(260px, 0.8fr) 1.2fr; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.endpoint-list div:last-child { border-bottom: 0; }
.endpoint-list span, .error-grid span { color: var(--muted); font-size: 12px; }
.error-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); background: var(--surface); }
.error-grid div { min-height: 60px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.error-grid div:nth-child(2n) { border-right: 0; }
.error-grid div:nth-last-child(-n+2) { border-bottom: 0; }

dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(24, 33, 43, 0.24);
}
dialog::backdrop { background: rgba(18, 26, 34, 0.42); }
.dialog-head { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head span { color: var(--muted); font-size: 12px; }
.dialog-head h2 { margin-top: 2px; }
.icon-button { width: 34px; min-height: 34px; padding: 0; font-size: 22px; }
dialog > pre { margin: 0; padding: 16px; max-height: calc(100vh - 140px); overflow: auto; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

#notice {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 4px;
  color: #fff;
  background: #263442;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
#notice.visible { opacity: 1; }

@media (max-width: 900px) {
  .admin-shell { display: block; }
  .sidebar { position: sticky; z-index: 10; width: 100%; height: auto; flex-direction: row; align-items: center; }
  .brand-block { min-width: 148px; min-height: 58px; padding: 10px 14px; border-bottom: 0; border-right: 1px solid rgba(255,255,255,0.1); }
  .sidebar nav { padding: 8px; display: flex; flex: 1; }
  .sidebar nav a { min-height: 38px; white-space: nowrap; }
  .account-block { margin-top: 0; padding: 10px 14px; border-top: 0; border-left: 1px solid rgba(255,255,255,0.1); }
  .metrics { grid-template-columns: repeat(2, 1fr); padding: 0 16px; }
  .metrics div, .metrics div:nth-child(4n), .metrics div:nth-child(n+5) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .metrics div:nth-child(2n) { border-right: 0; }
  .metrics div:nth-last-child(-n+2) { border-bottom: 0; }
  .docs-intro { grid-template-columns: repeat(2, 1fr); }
  .docs-intro div:nth-child(2) { border-right: 0; }
  .docs-intro div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .sidebar { flex-wrap: wrap; }
  .brand-block { flex: 1; }
  .brand-block span { display: none; }
  .sidebar nav { order: 3; flex-basis: 100%; border-top: 1px solid rgba(255,255,255,0.1); }
  .sidebar nav a { flex: 1; justify-content: center; }
  .account-block { padding: 10px; }
  .account-block > span { display: none; }
  .topbar { min-height: 64px; padding: 10px 16px; }
  .metrics { padding: 0; }
  .metrics div { min-height: 68px; padding: 11px 14px; }
  .metrics strong { font-size: 18px; }
  .section-heading { padding: 8px 16px; align-items: flex-start; flex-direction: column; }
  .jobs-toolbar { padding: 10px 16px; align-items: stretch; flex-direction: column; }
  .job-search { width: 100%; }
  .filters { width: 100%; overflow-x: auto; }
  .pagination { padding: 9px 16px; }
  th:first-child, td:first-child { padding-left: 16px; }
  .docs-page { padding: 14px 12px 32px; }
  .docs-intro { grid-template-columns: 1fr; }
  .docs-intro div, .docs-intro div:nth-child(2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .docs-intro div:last-child { border-bottom: 0; }
  .endpoint-list div { grid-template-columns: 1fr; gap: 5px; }
  .error-grid { grid-template-columns: 1fr; }
  .error-grid div, .error-grid div:nth-child(2n), .error-grid div:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .error-grid div:last-child { border-bottom: 0; }
  .code-block pre { padding-right: 16px; padding-top: 48px; }
}
