:root {
  --bg: #0b0e14;
  --bg-card: #121722;
  --bg-elev: #181f2e;
  --border: #252e42;
  --text: #e6ebf5;
  --muted: #8f9bb3;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.14);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.16);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.16);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.16);
  --slate: #64748b;
  --slate-bg: rgba(100, 116, 139, 0.18);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: #7cb3ff; text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 20px 48px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.badge-cluster {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--blue-bg); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.35);
}
.subline { color: var(--muted); font-size: 12px; font-family: var(--mono); }

.pulse {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.65);
  animation: pulse 2s infinite;
}
.pulse.warn { background: var(--amber); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.top-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.btn {
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: #46577a; background: #1f283b; }
.btn-primary { background: #2563eb; border-color: #3b82f6; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 8px; font-size: 11px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.kpi-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-val { font-size: 24px; font-weight: 700; font-family: var(--mono); margin: 2px 0; }
.kpi-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.alert-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.alert-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; font-size: 13px; }
.alert-list { margin-top: 8px; display: grid; gap: 6px; }
.alert-item {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  background: rgba(11, 14, 20, 0.55); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12px;
}
.alert-item.critical { border-left: 3px solid var(--red); }
.alert-item.warn { border-left: 3px solid var(--amber); }
.alert-item.info { border-left: 3px solid var(--blue); }

.filter-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--bg-card); }
.tab.active { color: #fff; background: var(--bg-elev); border-color: var(--border); }

.owner-pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill {
  background: var(--bg-card); color: var(--muted); border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 10px; font-size: 11px; cursor: pointer; font-family: var(--mono);
}
.pill.active { background: var(--blue-bg); color: #bfdbfe; border-color: var(--blue); }

.panel { display: none; }
.panel.active { display: block; }

.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin: 14px 0 10px; font-size: 14px; font-weight: 700; color: #cbd5e1;
}

.nodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 12px;
}
.node-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  transition: border-color 0.15s;
}
.node-card:hover { border-color: #3a4a6b; }
.node-card.tier-prod { border-color: rgba(59, 130, 246, 0.45); background: linear-gradient(180deg, rgba(30, 58, 138, 0.14), var(--bg-card)); }
.node-card.status-zombie { border-color: rgba(239, 68, 68, 0.65); }
.node-card.status-offline { opacity: 0.72; border-color: rgba(239, 68, 68, 0.5); }

.node-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.node-name { font-size: 16px; font-weight: 700; font-family: var(--mono); display: flex; align-items: center; gap: 7px; cursor: pointer; }
.node-name:hover { color: #93c5fd; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; font-family: var(--mono);
}
.tag-green { background: var(--green-bg); color: #86efac; }
.tag-amber { background: var(--amber-bg); color: #fcd34d; }
.tag-red { background: var(--red-bg); color: #fca5a5; }
.tag-blue { background: var(--blue-bg); color: #93c5fd; }
.tag-purple { background: var(--purple-bg); color: #d8b4fe; }
.tag-slate { background: var(--slate-bg); color: #cbd5e1; }

.gpu-strip {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.gpu-tile {
  border-radius: 7px;
  padding: 6px 4px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}
.gpu-tile .g-idx { font-weight: 700; font-size: 11px; }
.gpu-tile .g-stat { font-size: 10px; opacity: 0.92; }
.gpu-tile .g-own { font-size: 9px; opacity: 0.78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.g-active, .g-prod_active { background: rgba(34, 197, 94, 0.22); border-color: rgba(34, 197, 94, 0.5); color: #bbf7d0; }
.g-warm_idle, .g-standby { background: rgba(245, 158, 11, 0.20); border-color: rgba(245, 158, 11, 0.45); color: #fde68a; }
.g-prod_standby { background: rgba(59, 130, 246, 0.20); border-color: rgba(59, 130, 246, 0.45); color: #bfdbfe; }
.g-zombie, .g-empty_grace, .g-prod_alert { background: rgba(239, 68, 68, 0.22); border-color: rgba(239, 68, 68, 0.55); color: #fecaca; }
.g-unleased { background: rgba(168, 85, 247, 0.22); border-color: rgba(168, 85, 247, 0.55); color: #e9d5ff; }
.g-free, .g-prod_empty { background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.25); color: #cbd5e1; }

.subblock {
  border-top: 1px solid #1d2433;
  padding-top: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.row-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 4px 0;
}
.host-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #1d2433;
}
.host-bar .danger { color: #fca5a5; font-weight: 700; }
.host-bar .warn { color: #fcd34d; font-weight: 700; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left; color: var(--muted); font-weight: 600; padding: 7px 8px;
  border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase;
}
td { padding: 7px 8px; border-bottom: 1px solid #1a2130; vertical-align: top; }
tr:last-child td { border-bottom: none; }

.eff-bar {
  display: flex; height: 10px; border-radius: 99px; overflow: hidden;
  background: #1e2536; min-width: 120px;
}
.eff-seg-act { background: var(--green); }
.eff-seg-warm { background: var(--amber); }
.eff-seg-zomb { background: var(--red); }

.drawer-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); z-index: 40;
  display: flex; justify-content: flex-end;
}
.modal-backdrop { justify-content: center; align-items: center; padding: 16px; }
.drawer {
  width: min(680px, 100vw); height: 100%; background: var(--bg-card);
  border-left: 1px solid var(--border); padding: 18px; overflow-y: auto;
}
.modal {
  width: min(520px, 100%); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; max-height: 90vh; overflow-y: auto;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer-head h2, .drawer-head h3 { margin: 0; }
.hidden { display: none !important; }

.form-grid { display: grid; gap: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 13px;
}
.spark-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
pre.log-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; font-size: 11px; overflow-x: auto; max-height: 240px; margin: 0;
}
.empty { color: var(--muted); font-size: 12px; padding: 10px 0; }

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .nodes-grid { grid-template-columns: 1fr; }
}
