:root {
  --bg: #171717; --panel: #0d0d0e; --panel-2: #141415; --raise: #1c1c1e; --line: #222225; --line-2: #2c2c30;
  --text: #ededee; --muted: #8b8b91; --dim: #56565c;
  --blue: #3ba8f6; --pink: #f2478f; --yellow: #f6c94e; --green: #4ae3a2; --purple: #8d6ef7; --orange: #f5894e;
  --sans: 'Inter', system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace; --pixel: 'Silkscreen', monospace;
  --spring: cubic-bezier(.34, 1.56, .64, 1); --spring-big: cubic-bezier(.22, 1.9, .5, 1); --out: cubic-bezier(.2, .8, .2, 1);
  --r: 22px; --r-sm: 12px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .dim { color: var(--dim); }

/* ---------- top bar ---------- */
.top { height: 56px; display: flex; align-items: center; gap: 18px; padding: 0 20px; border-bottom: 1px solid var(--line); background: #121213; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.brand canvas { width: 30px; height: 30px; image-rendering: pixelated; }
.brand .sep { color: var(--dim); }
.top .grow { flex: 1; }
.stamp { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(74, 227, 162, .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 227, 162, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 227, 162, 0); } }
.summary { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); }
.summary b { color: var(--text); font: 500 13px var(--mono); margin-right: 5px; }
.summary b.bad { color: var(--pink); }

/* segmented control with a sliding spring thumb */
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.seg button { position: relative; z-index: 1; padding: 5px 13px; border-radius: 8px; color: var(--muted); font-size: 13px; transition: color .25s; }
.seg button.on { color: var(--text); }
.seg .thumb { position: absolute; top: 3px; bottom: 3px; border-radius: 8px; background: #29292d; box-shadow: inset 0 1px 0 rgba(255,255,255,.06); transition: left .45s var(--spring), width .45s var(--spring); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); transition: transform .4s var(--spring), color .2s; }
.icon-btn:hover { color: var(--text); transform: scale(1.08); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.spin svg { animation: spin .8s var(--spring); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 16px; padding: 16px; height: calc(100% - 56px); }
.main { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 16px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 0 0 6px rgba(0,0,0,.18), 0 20px 40px -20px rgba(0,0,0,.6); min-height: 0; }
.ph { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.ph h2 { font-size: 15px; font-weight: 500; }
.ph .sub { color: var(--muted); font-size: 12.5px; }
.tile { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); display: grid; place-items: center; flex: none; }
.tile canvas { width: 18px; height: 18px; image-rendering: pixelated; }

/* ---------- live cards ---------- */
.live { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; cursor: pointer; transition: transform .5s var(--spring), border-color .3s, box-shadow .4s; }
.card:hover { transform: translateY(-4px) scale(1.012); border-color: var(--line-2); }
.card:active { transform: scale(.985); }
.card.sel { border-color: #3a3a40; box-shadow: 0 0 0 6px rgba(0,0,0,.18), 0 0 0 1px #3a3a40, 0 24px 50px -24px rgba(59,168,246,.35); }
.card .ph { border: 0; padding-bottom: 6px; }
.card .ph .name { font-size: 15px; font-weight: 500; }
.card .ph a.link { color: var(--muted); font-size: 12.5px; transition: color .2s; }
.card .ph a.link:hover { color: var(--blue); }
.big { display: flex; align-items: baseline; gap: 10px; padding: 8px 20px 4px; }
.big .n { font: 500 30px var(--mono); letter-spacing: -.02em; }
.big .l { color: var(--muted); font-size: 13px; }
.big .r { margin-left: auto; font-size: 13px; color: var(--muted); }
.big .r b { font: 500 14px var(--mono); color: var(--text); margin-right: 4px; }
.legend { display: flex; gap: 14px; padding: 4px 20px 0; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.dots { position: relative; height: 122px; margin: 6px 20px 0; }
.dots svg { width: 100%; height: 100%; overflow: visible; }
.dots circle { transform-box: fill-box; transform-origin: center; animation: pop .6s var(--spring-big) backwards; }
@keyframes pop { from { transform: scale(0); opacity: 0; } }
.axis { display: flex; justify-content: space-between; padding: 6px 20px 0; font: 11px var(--mono); color: var(--dim); }
.strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: auto; border-top: 1px solid var(--line); }
.strip > div { padding: 12px 20px 14px; border-left: 1px solid var(--line); }
.strip > div:first-child { border-left: 0; }
.strip .k { color: var(--muted); font-size: 12px; }
.strip .v { font: 500 16px var(--mono); margin-top: 3px; white-space: nowrap; }
.strip .v small { font-size: 11px; color: var(--muted); margin-left: 2px; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; background: var(--raise); color: var(--muted); border: 1px solid transparent; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--blue); background: rgba(59,168,246,.1); }
.pill.bad { color: var(--pink); background: rgba(242,71,143,.1); }
.pill.warn { color: var(--yellow); background: transparent; border: 1px dashed rgba(246,201,78,.5); }
.pill.sleep { color: var(--purple); background: rgba(141,110,247,.1); }
.pill.idle { color: var(--dim); }
.ph .pill { margin-left: auto; }

/* ---------- table ---------- */
.table { display: flex; flex-direction: column; }
.thead, .row { display: grid; grid-template-columns: minmax(150px, 1.3fr) 100px minmax(160px, 2fr) 120px 118px 118px minmax(140px, 1.2fr); align-items: center; gap: 14px; padding: 0 20px; }
.thead { height: 38px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.rows { overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding: 4px 8px; scrollbar-width: thin; scrollbar-color: #2a2a2e transparent; }
.row { height: 52px; padding: 0 12px; border-radius: 12px; cursor: pointer; transition: background .2s, transform .45s var(--spring); animation: rowIn .7s var(--spring) backwards; }
.row:hover { background: #161618; transform: translateX(3px); }
.row.sel { background: #1b1b1e; }
@keyframes rowIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.row .svc { min-width: 0; }
.row .svc b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .svc span { font-size: 12px; color: var(--muted); }
.row .dep { min-width: 0; font-size: 12.5px; }
.row .dep div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dep .t { color: var(--muted); font: 11.5px var(--mono); }
.row > * { min-width: 0; }
.row .dom { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s; }
.row .dom:hover { color: var(--blue); }
.spark { width: 100%; height: 26px; }
.attempts { display: flex; gap: 3px; align-items: center; }
.attempts i { width: 7px; height: 7px; border-radius: 50%; background: #2a2a2e; transition: transform .4s var(--spring); }
.attempts i.ok { background: var(--blue); } .attempts i.bad { background: var(--pink); }
.row:hover .attempts i { transform: scale(1.25); }
.lat { display: flex; align-items: center; gap: 8px; font: 12px var(--mono); }
.lat .bar { flex: 1; height: 6px; border-radius: 3px; background: #232326; overflow: hidden; }
.lat .bar div { height: 100%; border-radius: 3px; background: var(--blue); transform-origin: left; animation: grow .9s var(--spring) backwards; }
@keyframes grow { from { transform: scaleX(0); } }
.tfoot { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.tfoot .legend { padding: 0; }
.tfoot .grow { flex: 1; }

/* ---------- side panel ---------- */
.side { display: flex; flex-direction: column; overflow: hidden; }
.side .ph .crumb { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .ph .crumb span { color: var(--muted); }
.side .tabs { padding: 14px 20px 0; }
.side .tabs .seg button { padding: 5px 10px; }
.side .tabs .btn { padding: 7px 11px; }
.side .body { flex: 1; min-height: 0; padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.swap { animation: swapIn .6s var(--spring) backwards; }
@keyframes swapIn { from { opacity: 0; transform: translateX(26px) scale(.97); } }
.box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.box h3 { font-size: 13px; font-weight: 500; display: flex; justify-content: space-between; margin-bottom: 8px; }
.box h3 span { color: var(--muted); font-weight: 400; }
.gauge-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; }
.gauge { position: relative; height: 92px; }
.gauge svg { width: 100%; height: 100%; overflow: visible; }
.gauge line { animation: tick .5s var(--spring-big) backwards; transform-box: fill-box; transform-origin: center; }
@keyframes tick { from { opacity: 0; transform: scale(.2); } }
.gauge .val { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font: 500 22px var(--mono); }
.kv { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; padding: 3px 0; }
.kv i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; }
.kv .mono { color: var(--text); }
.chart { width: 100%; height: 74px; display: block; overflow: visible; }
.chart path.line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s var(--out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart path.area { animation: fade .8s .2s ease backwards; }
@keyframes fade { from { opacity: 0; } }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stats3 { display: flex; gap: 16px; font: 12px var(--mono); margin-top: 6px; color: var(--muted); }
.stats3 b { color: var(--text); font-weight: 500; }
.stats3 .p50 b { color: var(--blue); }
.tl { display: flex; flex-direction: column; }
.tl .it { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 7px 0; position: relative; animation: rowIn .6s var(--spring) backwards; }
.tl .it::before { content: ''; position: absolute; left: 10px; top: 26px; bottom: -8px; border-left: 1px dashed var(--line-2); }
.tl .it:last-child::before { display: none; }
.tl .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; border: 1.5px solid currentColor; margin-top: 1px; }
.tl .ok { color: var(--blue); } .tl .bad { color: var(--pink); } .tl .warn { color: var(--yellow); } .tl .gone { color: var(--dim); }
.tl .m { min-width: 0; font-size: 13px; }
.tl .m div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl .m .s { font: 11.5px var(--mono); }
.tl .t { font: 11.5px var(--mono); color: var(--muted); padding-top: 2px; }
.cfg .kv { padding: 8px 0; border-bottom: 1px solid var(--line); }
.cfg .kv:last-child { border: 0; }
.cfg .kv .mono { font-size: 12px; max-width: 230px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-block; padding: 3px 8px; border-radius: 7px; background: var(--raise); border: 1px solid var(--line-2); font: 11.5px var(--mono); margin: 0 0 4px 4px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 10px; font-size: 13px; font-weight: 500; white-space: nowrap; transition: transform .4s var(--spring); }
.btn:hover { transform: scale(1.05); } .btn:active { transform: scale(.94); }
.btn.light { background: #f1f1f1; color: #111; }
.btn.dark { background: var(--raise); border: 1px solid var(--line-2); }
.empty { color: var(--dim); font-size: 12.5px; padding: 6px 0; }

/* tooltip */
.tip { position: fixed; z-index: 50; pointer-events: none; background: rgba(28,28,30,.96); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 11px; font-size: 12px; min-width: 130px; box-shadow: 0 10px 30px rgba(0,0,0,.5); opacity: 0; transform: translateY(6px) scale(.94); transition: opacity .15s, transform .35s var(--spring); }
.tip.on { opacity: 1; transform: none; }
.tip .h { font-family: var(--mono); color: var(--muted); margin-bottom: 4px; }
.tip .kv { padding: 1px 0; gap: 14px; }

/* entrance: everything holds its first frame until the loader hands over */
body:not(.ready) .top *, body:not(.ready) .app * , body:not(.ready) .app { animation-play-state: paused !important; }
.enter { animation: enter .9s var(--spring) backwards; }
@keyframes enter { from { opacity: 0; transform: translateY(34px) scale(.94); } }
.skel { fill: #232326; animation: shimmer 1.2s ease-in-out infinite alternate; }
@keyframes shimmer { to { fill: #303035; } }

/* ?still: no motion, used for layout screenshots */
.still *, .still *::before { animation: none !important; transition: none !important; }
.still #loader { display: none; }

/* corner version */
.ver { position: fixed; right: 14px; bottom: 8px; font: 10.5px var(--pixel); color: var(--dim); letter-spacing: .05em; z-index: 5; }

/* ---------- pixel loader ---------- */
#loader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: #0b0b0c; }
#loader canvas.fx { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
#loader .ld { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; }
#loader .ld canvas { width: 240px; height: 240px; image-rendering: pixelated; }
#loader .bar { display: flex; gap: 4px; }
#loader .bar i { width: 14px; height: 14px; background: #1f1f22; transition: background .2s, transform .45s var(--spring-big); }
#loader .bar i.on { background: var(--blue); transform: translateY(-4px); }
#loader .bar i.on:nth-child(3n) { background: var(--pink); }
#loader .bar i.on:nth-child(4n) { background: var(--yellow); }
#loader .txt { font: 12px var(--pixel); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; height: 16px; }
#loader .txt b { color: var(--text); font-weight: 400; }
#loader.out .ld { animation: ldOut .5s var(--spring) forwards; }
@keyframes ldOut { 40% { transform: scale(1.08); } to { transform: scale(.4); opacity: 0; } }

@media (max-width: 1100px) {
  body { overflow: auto; } html, body { height: auto; }
  .app { grid-template-columns: 1fr; height: auto; padding: 16px; }
  .live { grid-template-columns: 1fr; }
  .rows { max-height: 520px; }
  .thead { display: none; }
  .row { grid-template-columns: 1fr auto; height: auto; padding: 10px 12px; }
  .row > :nth-child(n+3) { display: none; }
  .side { height: 760px; }
  .summary { display: none; }
}
