/* vps-monitor — navy command-center theme. No external fonts or libraries. */
:root {
  --bg: #070b1a;
  --bg2: #0b1330;
  --panel: rgba(17, 27, 62, 0.62);
  --panel-solid: #0f1838;
  --brd: rgba(140, 165, 255, 0.16);
  --brd-strong: rgba(140, 165, 255, 0.3);
  --text: #eef2ff;
  --muted: #c3cce8;     /* secondary text  ~10:1 on panel */
  --faint: #a2afd6;     /* tertiary text   ~7.5:1 on panel */
  --grid: rgba(162, 175, 214, 0.14);
  --accent: #22d3ee;    /* UI accent (focus, logo) */
  --accent2: #a78bfa;

  /* metric colours: validated categorical pairs on the dark panel (OKLCH L .48–.67, CVD ΔE ≥ 14) */
  --c-cpu: #0aa6c4;
  --c-mem: #9061f9;
  --c-disk: #0d9f9a;
  --c-rx: #0aa6c4;
  --c-tx: #9061f9;
  --c-rd: #0d9f9a;
  --c-wr: #d97706;

  --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --r: 16px;
  --gap: 16px;
  --num: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: 15px/1.5 var(--sans);
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(34, 211, 238, .075), transparent 60%),
    radial-gradient(900px 480px at 100% -4%, rgba(167, 139, 250, .075), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg) 520px);
  -webkit-font-smoothing: antialiased;
}
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sr-only, .skip:not(:focus) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 20; top: 10px; left: 10px; padding: 8px 12px; border-radius: 10px; background: var(--accent); color: #031018; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
h1, h2, p { margin: 0; }

/* ---------- surfaces ---------- */
.card, .chart, .panel, .strip {
  background: var(--panel);
  border: 1px solid var(--brd);
  border-radius: var(--r);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045), 0 10px 30px rgba(0, 0, 0, .22);
}

/* ---------- header ---------- */
.topbar {
  max-width: 1280px; margin: 0 auto; padding: 22px 24px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 260px; }
.brand-text { min-width: 0; }
.logo { flex: none; width: 42px; height: 42px; padding: 9px; border-radius: 12px; background: rgba(34, 211, 238, .09); border: 1px solid rgba(34, 211, 238, .3); }
.logo path { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 5px rgba(34, 211, 238, .45)); }
h1 { font-size: 21px; font-weight: 650; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; align-items: center; gap: 10px; }

.status {
  display: inline-flex; align-items: center; gap: 9px; height: 40px; padding: 0 14px; border-radius: 999px;
  font-size: 14px; font-weight: 550; color: var(--text); background: rgba(255, 255, 255, .045); border: 1px solid var(--brd);
  white-space: nowrap;
}
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.status[data-state="live"] .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.status[data-state="connecting"] .dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.status[data-state="paused"] .dot { background: var(--warn); }
.status[data-state="stale"] { border-color: rgba(251, 191, 36, .45); }
.status[data-state="stale"] .dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.status[data-state="reconnecting"] { border-color: rgba(248, 113, 113, .5); }
.status[data-state="reconnecting"] .dot { background: var(--bad); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.field select, .btn, .seg button, .linkbtn {
  font: inherit; font-size: 14px; font-weight: 550; color: var(--text);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--brd); border-radius: 12px;
  height: 40px; padding: 0 14px; cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.field select option { background: var(--panel-solid); color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 8px; }
.ico { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ico-play { fill: currentColor; stroke: none; display: none; }
.btn[aria-pressed="true"] { color: #fde68a; border-color: rgba(251, 191, 36, .5); background: rgba(251, 191, 36, .08); }
.btn[aria-pressed="true"] .ico-pause { display: none; }
.btn[aria-pressed="true"] .ico-play { display: block; }
.field select:hover, .btn:hover, .seg button:hover, .linkbtn:hover { border-color: var(--brd-strong); background-color: rgba(34, 211, 238, .07); }

/* ---------- main ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 0 24px 40px; display: grid; gap: var(--gap); }

.strip { display: grid; grid-template-columns: 1fr 1.3fr 1.6fr; }
.chip { display: flex; flex-direction: column; gap: 2px; padding: 12px 20px; min-width: 0; }
.chip + .chip { border-left: 1px solid var(--brd); }
.k { color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
.kk { color: var(--faint); font-weight: 500; letter-spacing: 0; text-transform: none; }
.v { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.alert, .notice { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; font-size: 14.5px; }
.alert { border: 1px solid rgba(248, 113, 113, .45); background: rgba(127, 29, 29, .3); color: #fee2e2; }
.notice { justify-content: space-between; border: 1px solid rgba(34, 211, 238, .4); background: rgba(8, 51, 68, .45); color: #e0fbff; }
.alert[hidden], .notice[hidden] { display: none; }
.linkbtn { height: 34px; padding: 0 12px; font-size: 13.5px; flex: none; }

/* ---------- usage cards ---------- */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); outline: none; }
.card { position: relative; padding: 18px 20px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow: hidden; transition: border-color .25s var(--ease); }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--mc, var(--accent)); opacity: .9; }
.card:hover { border-color: var(--brd-strong); }
.m-cpu { --mc: var(--c-cpu); }
.m-mem { --mc: var(--c-mem); }
.m-disk { --mc: var(--c-disk); }
.m-net { --mc: linear-gradient(90deg, var(--c-rx), var(--c-tx)); }
.card header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card h2, .section-title { font-size: 13px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.meta { color: var(--faint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--mc, var(--accent)); display: inline-block; flex: none; }
.m-net h2 .sw { background: linear-gradient(90deg, var(--c-rx) 50%, var(--c-tx) 50%); }
.sw.s-rx { background: var(--c-rx); } .sw.s-tx { background: var(--c-tx); }
.sw.s-rd { background: var(--c-rd); } .sw.s-wr { background: var(--c-wr); }
.big { font-size: 40px; font-weight: 620; line-height: 1.08; letter-spacing: -.02em; }
.big.pending, .mid.pending { color: var(--faint); font-size: 17px; font-weight: 500; font-family: var(--sans); letter-spacing: 0; line-height: 1.3; min-height: 43px; display: flex; align-items: center; }
.mid.pending { min-height: 0; }
.mid { font-size: 24px; font-weight: 600; display: block; line-height: 1.2; }
.bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--mc); transition: width .5s var(--ease), opacity .3s; }
.bar i.empty { opacity: 0; }
.kv { margin: 0; display: grid; gap: 5px; }
.kv div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; min-width: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.foot { color: var(--muted); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.foot b { color: var(--text); font-weight: 550; }
.lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rates { display: grid; gap: 12px; }
.lbl { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13.5px; }

/* stale / old readings */
body.is-stale .card .big, body.is-stale .card .mid, body.is-stale .kv dd, body.is-stale .v:not(#updated) { color: #9aa6c9; }
body.is-stale .bar i { opacity: .45; }

/* ---------- charts ---------- */
.charts-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-top: 6px; }
.span-note { color: var(--faint); font-size: 13.5px; flex: 1 1 240px; }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 13px; background: rgba(255, 255, 255, .04); border: 1px solid var(--brd); }
.seg button { height: 34px; min-width: 52px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.seg button[aria-checked="true"] { background: rgba(34, 211, 238, .14); color: var(--text); box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .45); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.chart { margin: 0; padding: 14px 16px 10px; min-width: 0; }
.chart figcaption { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.ct { font-size: 14.5px; font-weight: 650; color: var(--text); }
.unit { color: var(--faint); font-size: 13px; }
.legend { display: inline-flex; gap: 14px; color: var(--muted); font-size: 13px; }
.plot { position: relative; height: 210px; touch-action: pan-y; border-radius: 8px; }
.plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.axis text { fill: var(--faint); font: 12px var(--num); }
.grid line { stroke: var(--grid); stroke-width: 1; }
.base { stroke: rgba(162, 175, 214, .3); stroke-width: 1; }
.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { stroke: none; opacity: .16; }
.dotm { stroke: var(--panel-solid); stroke-width: 2; }
.norec { fill: url(#hatch); }
.norec-text { fill: var(--faint); font: 12.5px var(--sans); }
.cross { stroke: rgba(238, 242, 255, .55); stroke-width: 1; stroke-dasharray: 3 3; }
.empty-msg { position: absolute; inset: 0 0 26px 58px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; padding: 0 12px; pointer-events: none; }
.hint { color: var(--faint); font-size: 13px; margin-top: -4px; }

.tip {
  position: fixed; z-index: 30; pointer-events: none; min-width: 150px; max-width: 260px;
  padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  background: rgba(10, 16, 40, .96); border: 1px solid var(--brd-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.tip .t { color: var(--muted); margin-bottom: 4px; font-family: var(--num); }
.tip .r { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.tip .r b { font-family: var(--num); font-weight: 550; }

/* ---------- filesystems, details, footer ---------- */
.panel { padding: 16px 20px; }
.panel > .section-title { margin-bottom: 10px; display: flex; }
.fs-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fs-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--brd); }
.fs-table td { padding: 10px; border-bottom: 1px solid rgba(140, 165, 255, .08); font-family: var(--num); font-variant-numeric: tabular-nums; }
.fs-table tr:last-child td { border-bottom: 0; }
.fs-table .r { text-align: right; }
.usecell { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.minibar { width: 64px; height: 6px; border-radius: 9px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.minibar i { display: block; height: 100%; background: var(--c-disk); }
.fs-cards { display: none; list-style: none; margin: 0; padding: 0; gap: 10px; }
.fs-cards li { padding: 12px 14px; border: 1px solid var(--brd); border-radius: 12px; background: rgba(255, 255, 255, .025); display: grid; gap: 8px; }
.fs-cards .top { display: flex; justify-content: space-between; gap: 10px; font-family: var(--num); }
.fs-cards .top span:last-child { color: var(--faint); }
.fsbar i { background: var(--c-disk); }

.details summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.details summary::-webkit-details-marker { display: none; }
.details summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease); margin-right: 4px; }
.details[open] summary::after { transform: rotate(-135deg); }
.kv.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 32px; margin-top: 12px; }
.kv.grid div { border-bottom: 1px solid rgba(140, 165, 255, .08); padding: 6px 0; }

.foot-note { color: var(--muted); font-size: 14px; display: grid; gap: 6px; margin-top: 4px; }
.foot-note summary { cursor: pointer; color: var(--faint); width: fit-content; }
.foot-note ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; max-width: 900px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --gap: 12px; --r: 14px; }
  body { font-size: 14.5px; }
  .topbar { padding: 14px 14px 10px; gap: 10px; }
  .logo { width: 36px; height: 36px; padding: 7px; }
  h1 { font-size: 18px; }
  .sub { font-size: 13px; }
  .controls { width: 100%; }
  .status { flex: 1 1 auto; height: 44px; justify-content: flex-start; }
  .field select, .btn { height: 44px; }
  main { padding: 0 14px calc(28px + env(safe-area-inset-bottom)); }
  .strip { grid-template-columns: 1fr 1.25fr; }
  .chip { padding: 9px 14px; }
  .chip-wide { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--brd); flex-direction: row; justify-content: space-between; align-items: baseline; gap: 10px; }
  .k { font-size: 12px; }
  .kk { display: none; }
  .v { font-size: 14.5px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 14px 14px 14px; gap: 8px; }
  .card h2 { font-size: 12.5px; letter-spacing: .08em; }
  .card header .meta { display: none; }
  .big { font-size: 30px; }
  .big.pending { font-size: 15px; min-height: 33px; }
  .mid { font-size: 18px; }
  .kv div { font-size: 13px; }
  .foot, .lbl { font-size: 12.5px; }
  .card .foot { flex-direction: column; gap: 2px; }
  .plot { height: 180px; }
  .seg button { height: 40px; min-width: 56px; }
  .fs-table { display: none; }
  .fs-cards { display: grid; }
  .kv.grid { grid-template-columns: 1fr; }
  .hint { font-size: 12.5px; }
}
@media (max-width: 379px) {
  .big { font-size: 26px; }
  .card { padding: 12px; }
  .kv div { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .sw, .bar i, .minibar i { forced-color-adjust: none; }
  .status .dot { forced-color-adjust: none; }
}
