:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --line: #d7dee5;
  --text: #1f2933;
  --muted: #66727f;
  --brand: #0f766e;
  --brand-2: #115e59;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-sub,
.muted,
.log-meta {
  color: var(--muted);
}

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

.nav-link,
.nav-button,
.text-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link.active {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand-2);
}

.nav-button {
  font: inherit;
}

.logout-form {
  margin: 0;
}

.flash-wrap {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash {
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash-success {
  border-color: rgba(6, 118, 71, 0.25);
  background: #effdf3;
}

.flash-error {
  border-color: rgba(180, 35, 24, 0.25);
  background: #fff1f0;
}

.flash-info {
  border-color: rgba(17, 94, 89, 0.22);
  background: #eff8f7;
}

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

.panel {
  margin-bottom: 16px;
  padding: 16px;
}

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

.panel-head h2,
.auth-card h1 {
  margin: 0;
  font-size: 18px;
}

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

.node-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.node-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.node-name {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.node-meta {
  color: var(--muted);
  word-break: break-word;
}

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

.metric-grid.compact {
  grid-template-columns: 1fr;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-row span {
  color: var(--muted);
}

.metric-row strong {
  font-size: 16px;
}

.metric-sub {
  color: var(--muted);
  font-size: 12px;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: #dbe7ef;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #0ea5a3);
}

.node-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.node-facts span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.node-facts-detail {
  margin: 10px 0 12px;
}

.node-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat {
  padding: 16px;
}

.stat-num {
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
}

.stat-label {
  margin-top: 8px;
  color: var(--muted);
}

.grid-form,
.stack-form,
.filters {
  display: grid;
  gap: 12px;
}

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

.grid-form label,
.stack-form label,
.filters label {
  display: grid;
  gap: 6px;
}

.span-2 {
  grid-column: span 2;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 92px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: rgba(15, 118, 110, 0.4);
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
}

.secondary-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.danger-btn {
  background: #fff1f0;
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
}

.host-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selection-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.selection-toolbar .text-btn {
  padding: 7px 10px;
}

.host-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.host-table th,
.host-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.host-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
  white-space: nowrap;
}

.row-actions form {
  margin: 0;
}

.host-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.text-btn {
  padding: 7px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f7;
  color: var(--text);
  font-size: 12px;
  border: 1px solid var(--line);
}

.badge-ok {
  background: #effdf3;
  color: var(--ok);
  border-color: rgba(6, 118, 71, 0.2);
}

.badge-error {
  background: #fff1f0;
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.2);
}

.badge-warn {
  background: #fff7ed;
  color: var(--warn);
  border-color: rgba(181, 71, 8, 0.2);
}

.badge-muted {
  background: #f8fafc;
}

.log-list {
  display: grid;
  gap: 12px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.log-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.log-title {
  font-weight: 700;
}

.log-cmd {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-output-block {
  margin-top: 10px;
}

.log-output-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.log-output-block pre {
  margin-top: 0;
}

.log-output-error pre {
  background: #1f2937;
  color: #fee2e2;
}

.batch-runner {
  margin-top: 12px;
}

.batch-runner.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
  color: var(--muted);
}

.batch-runner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.batch-runner-meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.batch-progress {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.batch-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: #dbe7ef;
  overflow: hidden;
}

.batch-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #0ea5a3);
}

.batch-progress-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.batch-result-running {
  border-color: rgba(15, 118, 110, 0.3);
}

.batch-result-success {
  border-color: rgba(6, 118, 71, 0.2);
}

.batch-result-error {
  border-color: rgba(180, 35, 24, 0.2);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

details {
  margin-top: 8px;
}

summary {
  cursor: pointer;
  color: var(--brand-2);
}

pre {
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 20px;
}

.auth-card p {
  margin-top: 8px;
}

.inline-form {
  margin-top: 12px;
}

.filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 16px;
}

@media (max-width: 980px) {
  .grid-form,
  .filters {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .panel-head,
  .log-top,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

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

@media (max-width: 640px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
