/* TG ServerOps vPro Gold - dark theme */
:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #14171d;         /* chart surface (palette validated against this) */
  --surface-2: #1a1e25;
  --surface-3: #222731;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #ecebe6;
  --text-2: #b3b1a8;
  --muted: #85847d;
  --grid: #242830;
  --axis: #3a3f47;
  --gold: #d6b25e;
  --gold-2: #b8923a;
  --gold-soft: rgba(214, 178, 94, 0.14);
  --ok: #0ca30c;
  --warn: #f28c28;            /* alarm: warning (orange) */
  --crit: #e5484d;            /* alarm: critical (red) */
  --warn-rgb: 242, 140, 40;
  --crit-rgb: 229, 72, 77;
  --radius: 10px;
  --card-pad: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 10px 16px;
  background: rgba(11, 13, 16, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { width: 26px; height: 26px; fill: var(--gold); flex: none; }
.brand .led { fill: var(--bg); }
.brand h1 {
  margin: 0; font-size: 17px; font-weight: 650; letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(90deg, var(--text) 0%, var(--text) 55%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.status-pills { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-2); font-size: 12px; white-space: nowrap;
}
button.pill { cursor: pointer; }
button.pill:hover { border-color: var(--line-2); color: var(--text); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.crit { color: var(--text); border-color: rgba(var(--crit-rgb), .55); }
.pill.crit .dot { background: var(--crit); }
.pill.warn { color: var(--text); border-color: rgba(var(--warn-rgb), .55); }
.pill.warn .dot { background: var(--warn); }
.pill.ok .dot { background: var(--ok); }
.pill.off .dot { background: transparent; border: 1.5px solid var(--muted); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.control { display: flex; align-items: center; gap: 8px; }
.control-label { color: var(--muted); font-size: 12px; }
.updated { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* segmented control */
.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px;
}
.seg button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 3px 9px; border-radius: 6px; cursor: pointer; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.seg button:hover { color: var(--text); background: var(--surface-3); }
.seg button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.banner {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: var(--radius);
  background: rgba(var(--crit-rgb), .12); border: 1px solid rgba(var(--crit-rgb), .45);
  color: var(--text); font-size: 13px;
}

/* ---------------------------------------------------------------- servers */
main { padding: 16px; display: flex; flex-direction: column; gap: 22px; }
.empty { color: var(--muted); padding: 40px; text-align: center; }

.server-wrap { container: server / inline-size; }
.server {
  display: grid;
  grid-template-columns: var(--summary-w) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
}
.server[data-state="ok"]       { border-left-color: var(--ok); }
.server[data-state="warning"]  { border-left-color: var(--warn); }
.server[data-state="critical"] { border-left-color: var(--crit); }
.server[data-state="offline"]  { border-left-color: var(--muted); border-left-style: dashed; }

/* summary panel */
.summary {
  padding: 14px 16px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  min-width: 0;
}
.summary-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.summary h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: .2px; word-break: break-all; }
.online { font-size: 12px; color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.online .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(12,163,12,.18); }
.online.is-off .dot { background: var(--crit); box-shadow: 0 0 0 3px rgba(var(--crit-rgb), .2); }
.online.is-off { color: var(--text); font-weight: 600; }
.uuid {
  font: 11px var(--mono); color: var(--muted); margin: 2px 0 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: all;
}
.summary dl {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 12px; margin: 0; font-size: 13px;
}
.summary dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.summary dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.summary .sub { color: var(--muted); font-size: 12px; }
.summary .list { display: flex; flex-direction: column; gap: 1px; }
.summary .mono { font-family: var(--mono); font-size: 12px; }
.tag {
  display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11.5px;
  border: 1px solid var(--line-2); color: var(--text-2); margin: 1px 2px 1px 0; white-space: nowrap;
}
.tag.sec { border-color: rgba(var(--warn-rgb), .6); color: #f5b36f; }
.tag.boot { border-color: rgba(var(--crit-rgb), .6); color: #f08a8d; }
.tag.good { border-color: rgba(12,163,12,.5); color: #6fcf6f; }
.summary-foot { margin-top: 10px; color: var(--muted); font-size: 11.5px; }

/* charts grid: shrink to --chart-min before wrapping */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(calc(var(--chart-min) + 2 * var(--card-pad) + 2px), 1fr));
  gap: 10px; padding: 12px; align-content: start; min-width: 0;
  grid-auto-rows: auto;
}
.chart {
  position: relative; min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px var(--card-pad) 8px;
  /* rows: head, alarm, range, frequency, plot, legend */
  display: grid; grid-row: span 6; grid-template-rows: subgrid; row-gap: 4px;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}
@supports not (grid-template-rows: subgrid) {
  .chart { display: flex; flex-direction: column; gap: 4px; }
}
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.chart-title { font-size: 12.5px; font-weight: 600; color: var(--text); min-width: 0; }
.chart-head { align-items: baseline; row-gap: 0; }
.chart-now { flex: none; }
.chart-now { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-now .u { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 1px; }
.chart-sub { display: flex; align-items: center; }
.chart-alarm { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-height: 16px; }
.chart .seg button { padding: 2px 6px; font-size: 11px; }
.freq { overflow-wrap: anywhere; font-size: 10.5px; color: var(--muted); line-height: 1.25; }
.plot { width: 100%; min-height: var(--chart-h); position: relative; }
.plot .msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 10px; font-size: 12px; color: var(--muted);
}
.legend { display: flex; flex-wrap: wrap; align-content: flex-start; align-self: start; gap: 2px 10px; font-size: 11px; color: var(--text-2); min-height: 15px; }
.legend .it { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.legend svg { width: 16px; height: 6px; flex: none; }
.legend .v { color: var(--text); font-variant-numeric: tabular-nums; }
.legend .t { color: var(--muted); font-variant-numeric: tabular-nums; }

/* alarm badge (icon + label so state is never color-only) */
.alarm-badge {
  display: none; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px;
}
.alarm-badge svg { width: 10px; height: 10px; }
.chart[data-level="warning"] .alarm-badge { display: inline-flex; background: rgba(var(--warn-rgb), .18); color: #ffb366; }
.chart[data-level="critical"] .alarm-badge { display: inline-flex; background: rgba(var(--crit-rgb), .2); color: #ff8589; }
.alarm-detail { font-size: 10.5px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* strobing */
@keyframes strobe-warn {
  0%, 100% { border-color: rgba(var(--warn-rgb), .35); box-shadow: 0 0 0 0 rgba(var(--warn-rgb), 0); background-color: var(--surface-2); }
  50%      { border-color: rgba(var(--warn-rgb), 1);   box-shadow: 0 0 0 2px rgba(var(--warn-rgb), .85), 0 0 22px 4px rgba(var(--warn-rgb), .45); background-color: #2a2118; }
}
@keyframes strobe-crit {
  0%, 100% { border-color: rgba(var(--crit-rgb), .4); box-shadow: 0 0 0 0 rgba(var(--crit-rgb), 0); background-color: var(--surface-2); }
  50%      { border-color: rgba(var(--crit-rgb), 1);  box-shadow: 0 0 0 2px rgba(var(--crit-rgb), .9), 0 0 26px 6px rgba(var(--crit-rgb), .5); background-color: #2b1719; }
}
.chart[data-level="warning"]  { animation: strobe-warn 1.4s ease-in-out infinite; }
.chart[data-level="critical"] { animation: strobe-crit 0.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .chart[data-level="warning"]  { animation: none; border-color: var(--warn); box-shadow: 0 0 0 2px rgba(var(--warn-rgb), .8); }
  .chart[data-level="critical"] { animation: none; border-color: var(--crit); box-shadow: 0 0 0 2px rgba(var(--crit-rgb), .9); }
}

/* uPlot tweaks */
.uplot { font-family: var(--font); }
.u-select { background: rgba(214, 178, 94, .12); }
.u-cursor-x, .u-cursor-y { border-color: rgba(255,255,255,.28) !important; }

.page-foot { padding: 6px 16px 24px; color: var(--muted); font-size: 11.5px; }

@media (max-width: 640px) {
  main { padding: 10px; gap: 16px; }
  .topbar { padding: 8px 10px; }
  .brand h1 { font-size: 15px; }
  .charts { padding: 10px; gap: 8px; }
}
.server-wrap { scroll-margin-top: 84px; }


/* RAID arrays in the summary's Disk row */
.summary .raid { display: flex; flex-direction: column; margin-top: 3px; }
.summary .raid-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; }
.summary .raid-members { font-size: 11.5px; overflow-wrap: anywhere; }
.summary .raid .tag { white-space: normal; max-width: 100%; border-radius: 8px; }

/* direct link (chain icon) beside the server name */
.permalink { display: inline-flex; vertical-align: middle; color: var(--muted); margin-left: 2px; padding: 2px; border-radius: 4px; }
.permalink svg { width: 15px; height: 15px; }
.permalink:hover, .permalink:focus-visible { color: var(--gold); background: var(--surface-3); outline: none; }
.all-link { color: var(--gold); font-size: 12.5px; text-decoration: none; margin-left: 6px; white-space: nowrap; }
.all-link:hover { text-decoration: underline; }
.empty a { color: var(--gold); }
/* end-of-support line under the OS */
.summary .eol { display: block; margin-top: 2px; font-size: 12px; }
.summary .eol .tag { white-space: normal; border-radius: 8px; }
