:root {
  --bg: #14110d; --bg-card: #1c1813; --bg-input: #25201a; --bg-hover: #2a241c;
  --border: #2d261e; --text: #f1ece3; --text-muted: #9a9183; --text-dim: #6a6256;
  --accent: #ff7a3d; --accent-soft: rgba(255,122,61,.14);
  --ok: #34d399; --warn: #fbbf24; --crit: #ef4444; --gpu: #a78bfa; --cpu: #60a5fa; --mem: #2dd4bf;
  --sidebar: #0f0d0a; --radius: 14px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 16px; }
.brand i { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); display: grid;
  place-items: center; color: #1a0e05; font-style: normal; font-size: 13px; }
.brand small { display: block; font-weight: 500; color: var(--text-muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-muted); font-weight: 600; }
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 17px; height: 17px; flex: none; }
.side-foot { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 12px; color: var(--text-muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); }

main { padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.sub { color: var(--text-muted); font-size: 12px; }
.view { display: none; } .view.active { display: block; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c, var(--accent)); }
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.kpi .s { font-size: 12px; color: var(--text-muted); }

.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.g2 { grid-template-columns: 2fr 1fr; } .g11 { grid-template-columns: 1fr 1fr; }
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel h2 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.panel h2 .tools { display: flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; }

.seg { display: inline-flex; background: var(--bg-input); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 7px; color: var(--text-muted); cursor: pointer; font-weight: 600; font-size: 12px; }
.seg button.on { background: var(--accent); color: #1a0e05; }
input[type=text], select { background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; outline: none; }
input[type=text]:focus, select:focus { border-color: var(--accent); }
.btn { background: var(--accent); color: #1a0e05; border: 0; border-radius: 9px; padding: 6px 14px; font-weight: 700; cursor: pointer; }

.bar { height: 7px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--c, var(--ok)); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--bg-input); color: var(--text-muted); }
.pill.ok, .pill.RUNNING, .pill.COMPLETED, .pill.idle, .pill.mixed, .pill.alloc { background: rgba(52,211,153,.14); color: var(--ok); }
.pill.PENDING, .pill.warn, .pill.drain, .pill.TIMEOUT { background: rgba(251,191,36,.14); color: var(--warn); }
.pill.crit, .pill.down, .pill.FAILED, .pill.NODE_FAIL, .pill.OUT_OF_MEMORY { background: rgba(239,68,68,.15); color: var(--crit); }
.pill.CANCELLED { background: var(--bg-input); color: var(--text-muted); }

.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.node { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.node:hover { border-color: var(--accent); }
.node .nh { display: flex; justify-content: space-between; align-items: center; font-weight: 800; margin-bottom: 8px; }
.node .row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin: 7px 0 3px; }
.node .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.gpus { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.gpus i { width: 18px; height: 18px; border-radius: 5px; background: var(--bg-hover); border: 1px solid var(--border); }
.gpus i.on { background: var(--gpu); border-color: transparent; }
.reason { font-size: 11px; color: var(--warn); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tablewrap { overflow-x: auto; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
tr:hover td { background: rgba(255,255,255,.02); }
td.dim { color: var(--text-muted); }
.empty { color: var(--text-dim); padding: 28px; text-align: center; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; }
.tip { position: absolute; pointer-events: none; background: #000d; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; display: none; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.axis { fill: var(--text-dim); font-size: 10px; }
.gridline { stroke: var(--border); stroke-width: 1; }

.hrow { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.hrow span:last-child { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hrow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.heat { display: grid; grid-template-columns: 30px repeat(24, 1fr); gap: 3px; font-size: 10px; color: var(--text-dim); }
.heat .c { aspect-ratio: 1; border-radius: 3px; background: var(--accent); }
.heat .lbl { display: flex; align-items: center; }
.donutwrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; background: #000a; display: none; place-items: center; z-index: 20; padding: 16px; }
.modal.open { display: grid; }
.modal .box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px; padding: 20px 22px; width: min(820px, 100%); max-height: 90vh; overflow: auto; }
.modal .close { float: right; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.stale { background: rgba(239,68,68,.12); border: 1px solid var(--crit); color: var(--crit); padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 0 8px 0 4px; } .nav { display: flex; flex-wrap: wrap; } .side-foot { display: none; }
  main { padding: 16px; } .g2, .g11 { grid-template-columns: 1fr; }
}

.gcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.gcard { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.gcard .gh { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.gcard .gh small { color: var(--text-muted); font-weight: 500; font-size: 11px; }
.gcard .big { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.gcard .big small { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-left: 4px; }
.gcard .row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin: 7px 0 3px; }
.gcard .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.gcard .proc { font-size: 11px; color: var(--text-muted); margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.gcard .proc div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard .proc b { color: var(--accent); }
.gcard.idle { opacity: .75; }

.pre { margin: 0; padding: 10px 12px; background: var(--bg-input); border-radius: 10px; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; overflow: auto; max-height: 340px; white-space: pre; color: var(--text-muted); }
.gpus i.part { background: linear-gradient(90deg, var(--gpu) 50%, var(--bg-hover) 50%); border-color: transparent; }

.health { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.health a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; background: var(--bg-card); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-muted); }
.health a:hover { border-color: var(--accent); color: var(--text); }
.health a.warn { border-color: var(--warn); color: var(--warn); } .health a.crit { border-color: var(--crit); color: var(--crit); }
.tgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tg { border-radius: 12px; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border); border-left: 5px solid var(--ok); }
.tg.warn { border-left-color: var(--warn); } .tg.crit { border-left-color: var(--crit); background: rgba(239,68,68,.1); }
.tg .n { font-size: 11px; color: var(--text-muted); font-weight: 700; letter-spacing: .04em; }
.tg .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tg .s { font-size: 11px; color: var(--text-muted); }
