:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f4f7;
  --text: #18212f;
  --muted: #657184;
  --line: #dce3ea;
  --blue: #1f6feb;
  --green: #168a53;
  --amber: #a36200;
  --red: #c93c37;
  --ink: #0f1722;
  --shadow: 0 12px 28px rgba(18, 26, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
a.button-link,
input,
select,
textarea {
  font: inherit;
}

button,
a.button-link {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 1180px;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
}

.brand p {
  color: var(--muted);
  margin: 6px 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.topbar-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.top-nav {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  overflow: hidden;
}

.nav-link {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link + .nav-link {
  border-left: 1px solid var(--line);
}

.nav-link.active {
  background: var(--ink);
  color: #fff;
}

.dashboard {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 1180px;
}

.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  min-height: 132px;
  padding: 16px;
}

.label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric {
  font-size: 28px;
  font-weight: 800;
  margin: 18px 0 8px;
  overflow-wrap: anywhere;
}

.subtle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-pill {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.tag {
  background: #e8f5ee;
  border-radius: 999px;
  color: #16794a;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  padding: 2px 7px;
  vertical-align: middle;
  white-space: nowrap;
}

.dot {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot.online {
  background: var(--green);
}

.dot.offline {
  background: var(--red);
}

.dot.warning {
  background: var(--amber);
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel h2 {
  font-size: 18px;
  margin: 0;
}

code {
  background: rgba(31, 111, 235, 0.09);
  border-radius: 6px;
  color: #184f9e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  padding: 2px 5px;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tabs button {
  min-height: 32px;
  padding: 0 10px;
}

.tabs button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.chart {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  height: 290px;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.chart svg {
  height: 100%;
  width: 100%;
}

.chart-axis {
  stroke: #cbd5df;
}

.chart-area {
  fill: url(#chart-area-gradient);
}

.chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chart-grid {
  stroke: var(--line);
  stroke-dasharray: 4 6;
}

.chart-x-tick {
  stroke: #9ba8b7;
}

.chart-point {
  cursor: crosshair;
  outline: none;
}

.chart-hit-area {
  fill: transparent;
}

.chart-dot {
  fill: #fff;
  opacity: 0;
  stroke: var(--blue);
  stroke-width: 3;
  transition: opacity 120ms ease, r 120ms ease;
}

.chart-point:hover .chart-dot,
.chart-point:focus .chart-dot {
  opacity: 1;
  r: 5px;
}

.chart-tooltip {
  background: rgba(15, 23, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  box-shadow: 0 10px 28px rgba(15, 23, 34, 0.24);
  color: #fff;
  display: grid;
  font-size: 12px;
  gap: 3px;
  min-width: 164px;
  padding: 9px 11px;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 2;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip strong {
  font-size: 15px;
}

.chart-tooltip span {
  color: #dce7f4;
}

.chart-empty {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

.merge-panel {
  display: grid;
  gap: 14px;
}

.tools-header h2 {
  font-size: 20px;
  margin: 0;
}

.tools-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  display: grid;
  gap: 8px;
  min-height: 110px;
  padding: 16px;
  text-decoration: none;
}

.tool-card:hover,
.nav-link:hover {
  text-decoration: none;
}

.tool-title {
  font-size: 18px;
  font-weight: 800;
}

.tool-detail,
.breadcrumbs {
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.breadcrumbs a {
  color: var(--blue);
  text-decoration: none;
}

.empty-state {
  align-items: flex-start;
  display: grid;
  gap: 12px;
}

.empty-state h2 {
  font-size: 18px;
  margin: 0;
}

.merge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.user-form {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) minmax(120px, 0.5fr) minmax(120px, 0.5fr) minmax(240px, 1.3fr) auto;
}

.user-form .field {
  margin-bottom: 0;
}

.node-form {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(160px, 0.9fr) minmax(220px, 1.4fr) minmax(120px, 0.5fr) minmax(120px, 0.5fr) minmax(160px, 0.8fr) auto;
}

.node-form .field,
.node-assignment-form .field {
  margin-bottom: 0;
}

.node-field {
  min-width: 0;
}

.node-checks {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.check-card {
  align-items: flex-start;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 52px;
  padding: 9px 10px;
}

.check-card input {
  margin-top: 3px;
}

.check-card strong,
.check-card small {
  display: block;
  overflow-wrap: anywhere;
}

.current-node-check {
  background: #eef6ff;
  border-color: #b9d7fb;
  cursor: default;
}

.node-empty-note {
  align-self: center;
  padding: 8px 2px;
}

.check-card small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.node-assignment-form {
  display: grid;
  gap: 12px;
}

.form-actions {
  align-items: end;
  display: flex;
}

.subscription-result {
  display: grid;
  gap: 12px;
}

.subscription-links {
  display: grid;
  gap: 12px;
}

.copy-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.copy-row code {
  min-height: 38px;
  padding: 9px 10px;
}

.small-link {
  min-height: 32px;
  padding: 0 10px;
}

.merge-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(220px, 1fr);
}

.merge-editors {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.merge-warnings {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

pre {
  background: #111827;
  border-radius: 8px;
  color: #e5edf6;
  margin: 0;
  max-height: 340px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

pre code,
td code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.guide-panel {
  display: grid;
  gap: 16px;
}

.guide-shell .guide-panel {
  padding: 20px;
}

.guide-intro {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  max-width: 900px;
}

.guide-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.guide-section {
  min-width: 0;
}

.guide-section h2,
.guide-section h3,
.manual-section h3 {
  font-size: 16px;
  margin: 0 0 10px;
}

.guide-section ol {
  display: grid;
  gap: 8px;
  line-height: 1.55;
  margin: 0;
  padding-left: 20px;
}

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

.config-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.config-list div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 10px 12px;
}

.config-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.config-list dd {
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.missing {
  color: var(--red);
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  color: var(--muted);
  font-size: 13px;
}

.warnings {
  display: grid;
  gap: 8px;
}

.warning {
  background: #fff8e8;
  border: 1px solid #f0d48a;
  border-radius: 8px;
  color: var(--amber);
  padding: 10px 12px;
}

.event-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.login-wrap {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login h1 {
  font-size: 24px;
  margin: 0 0 6px;
}

.login p {
  color: var(--muted);
  margin: 0 0 22px;
}

.login-guide-link {
  color: var(--blue);
  display: inline-block;
  font-size: 14px;
  margin-top: 14px;
  text-decoration: none;
}

.login-guide-link:hover,
a.button-link:hover {
  text-decoration: underline;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

.field input[type="file"] {
  align-items: center;
  display: flex;
  padding: 8px 12px;
}

.field textarea {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 340px;
  padding: 12px;
  resize: vertical;
}

.error {
  color: var(--red);
  min-height: 22px;
}

@media (max-width: 900px) {
  .guide-grid,
  .merge-editors,
  .merge-grid,
  .metrics,
  .node-form,
  .tools-list,
  .user-form,
  .layout {
    grid-template-columns: 1fr;
  }

  .config-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-controls {
    justify-content: flex-start;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 16px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric {
    font-size: 23px;
  }

  .config-list {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .topbar-controls,
  .top-nav {
    width: 100%;
  }

  .nav-link {
    flex: 1;
    justify-content: center;
    padding: 0 10px;
  }

  .actions button {
    flex: 1 1 140px;
  }
}
