:root {
  color-scheme: dark;
  --page: #141416;
  --surface: #1C1C1E;
  --raise: #232326;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .12);
  --fg: #F4F4F5;
  --fg2: #C7C7CC;
  --muted: #8E8E93;
  --faint: #5C5C61;
  --accent: #FF5A1F;
  --s1: #f0602a;   /* validated dark categorical: user / primary series */
  --s2: #3987e5;   /* nice / second series */
  --s3: #199e70;   /* system / third series */
  --track: rgba(255, 255, 255, .06);
  --crit: #d03b3b;
  --warn: #fab219;
  --good: #0ca30c;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --pad: clamp(16px, 2.6vw, 36px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); }
body {
  color: var(--fg);
  font: 400 13px/1.45 "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
p { margin: 0; }

.brand { font-size: 12px; letter-spacing: .38em; text-transform: uppercase; }

/* ---------------------------------------------------------------- login */
body.login { height: 100vh; overflow: hidden; background: var(--surface); }
#book {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity 2.4s var(--ease);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
}
#book.ready { opacity: .28; }
@media (orientation: portrait) {
  #book {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  }
}
.gate {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 56px;
  animation: in 1.4s var(--ease) both;
}
.gate form { width: min(300px, 80vw); display: grid; gap: 14px; }
.gate label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.gate input {
  font: inherit; font-size: 16px; color: var(--fg); background: transparent;
  border: 0; border-bottom: 1px solid var(--line2); border-radius: 0; padding: 8px 0; outline: none;
  transition: border-color .4s var(--ease);
}
.gate input:focus { border-color: var(--accent); }
.gate button {
  justify-self: start; margin-top: 10px; font-size: 14px; color: var(--accent);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .6s var(--ease);
}
.gate button::after { content: " \2192"; }
.gate button:hover, .gate button:focus-visible { background-size: 100% 1px; outline: none; }
.err { color: var(--fg2); font-size: 12px; }
.err::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--crit); margin-right: 8px; vertical-align: 1px; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 14px var(--pad);
  background: rgba(20, 20, 22, .82);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.crumb { color: var(--muted); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.bar .nav { margin-right: auto; margin-left: 10px; }
.crumb::before { content: "/"; margin-right: 14px; color: var(--faint); }
.seg { display: inline-flex; background: var(--surface); border-radius: 8px; padding: 2px; }
.seg button { padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; transition: color .2s, background .2s; }
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--raise); color: var(--fg); }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; min-width: 120px; font-variant-numeric: tabular-nums; }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.live.ok i { background: var(--good); box-shadow: 0 0 0 0 rgba(12, 163, 12, .5); animation: pulse 2s infinite; }
.live.bad i { background: var(--crit); }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
.ghost { color: var(--muted); font-size: 12px; transition: color .2s; }
.ghost:hover { color: var(--fg); }

/* ---------------------------------------------------------------- machines */
.machines { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.mach {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; align-items: end;
  padding: 18px var(--pad) 16px; background: var(--page); text-align: left; position: relative;
  transition: background .3s var(--ease);
}
.mach:hover { background: #17171a; }
.mach::after { content: ""; position: absolute; left: var(--pad); right: var(--pad); bottom: 0; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }
.mach.on::after { transform: scaleX(1); }
.mach .mn { font-size: 22px; font-weight: 500; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.mach .mn i { width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.mach .mn i.bad { background: var(--crit); }
.mach .ms { grid-column: 1; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mach .mx { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 18px; font-variant-numeric: tabular-nums; }
.mach .mx div { display: grid; gap: 2px; text-align: right; }
.mach .mx b { font-weight: 500; font-size: 15px; }
.mach .mx span { color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }

/* ---------------------------------------------------------------- layout */
main#view { padding: 20px var(--pad) 48px; display: grid; gap: 16px; max-width: 1680px; margin: 0 auto; transition: opacity .3s; }
main#view.stale { opacity: .55; }
.row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.col { display: grid; gap: 16px; align-content: start; }
.panel { background: var(--surface); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.panel:empty { display: none; }
.ph { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ph h2 { margin: 0; font-size: 11px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--fg2); }
.ph .sub { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ph .end { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }
.legend i.ln { height: 2px; border-radius: 1px; }

/* ---------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border-radius: 14px; padding: 16px 18px 12px; display: grid; gap: 2px; min-width: 0; }
.tile .tl { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg2); }
.tile .tl .legend { margin-left: auto; letter-spacing: 0; text-transform: none; }
.tile .tv { font-size: 28px; font-weight: 600; letter-spacing: -.01em; margin-top: 6px; white-space: nowrap; }
.tile .tv { overflow: hidden; text-overflow: ellipsis; }
.tile .tv.dual { font-size: 22px; margin-top: 8px; margin-bottom: 2px; }
.tile .tv.dual .sep { display: inline-block; width: 16px; margin: 0; }
.tile .tv .key { display: inline-block; width: 10px; height: 2px; border-radius: 1px; margin-right: 7px; vertical-align: 6px; }
.tile .tv small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.tile .tv .sep { color: var(--faint); font-weight: 400; margin: 0 8px; }
.tile .ts { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile canvas { width: 100%; height: 64px; display: block; margin-top: 10px; cursor: crosshair; touch-action: pan-y; }

/* ---------------------------------------------------------------- bars */
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 9px 28px; font-variant-numeric: tabular-nums; }
.core { display: grid; grid-template-columns: 22px 1fr 40px; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); }
.core b { font-weight: 400; color: var(--fg2); text-align: right; }
.stack { display: flex; gap: 2px; height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.stack.tall { height: 10px; border-radius: 4px; }
.stack i { display: block; height: 100%; flex: none; }
.stack i:last-child { border-radius: 0 3px 3px 0; }
.stack i.u { background: var(--s1); } .stack i.n { background: var(--s2); } .stack i.s { background: var(--s3); }
.stack i.m { background: var(--fg2); } .stack i.c { background: var(--s2); }
.stack i.crit { background: var(--crit); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 12px 18px; margin-top: 16px; font-variant-numeric: tabular-nums; }
.kv div { display: grid; gap: 2px; }
.kv span { color: var(--muted); font-size: 11px; }
.kv b { font-weight: 500; font-size: 14px; white-space: nowrap; }
.meter { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 10px; }
.meter b { font-weight: 400; color: var(--fg2); min-width: 120px; text-align: right; }

/* ---------------------------------------------------------------- tables */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; table-layout: fixed; }
.tbl th { font-weight: 500; font-size: 11px; color: var(--muted); text-align: right; padding: 0 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .2s; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, .025); }
.tbl th.l, .tbl td.l { text-align: left; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl td.cmd { font-family: var(--mono); font-size: 12px; color: var(--fg); }
.tbl td.dim { color: var(--muted); }
.tbl td .tag { display: inline-block; font-family: "Inter", system-ui, sans-serif; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; margin-right: 10px; vertical-align: 1px; }
.tbl td .tag.job { color: var(--fg); border-color: rgba(240, 96, 42, .55); }
.tbl td .cap { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.tbl td .cap .stack { height: 4px; }
.tbl td .hot { color: var(--fg); }
.flag { color: var(--fg); }
.flag::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--crit); margin-right: 6px; vertical-align: 1px; }
.more { margin-top: 12px; color: var(--muted); font-size: 12px; transition: color .2s; }
.more:hover { color: var(--fg); }
.search {
  font: inherit; font-size: 12px; color: var(--fg); background: var(--page); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; width: 200px; outline: none; transition: border-color .2s;
}
.search:focus { border-color: var(--line2); }
.scroll { overflow-x: auto; }
.scroll .tbl { min-width: 760px; }

.devs { display: grid; gap: 14px; }
.dev { display: grid; grid-template-columns: minmax(80px, 140px) 1fr auto; gap: 6px 14px; align-items: center; font-variant-numeric: tabular-nums; font-size: 12px; }
.dev .dn { color: var(--fg); }
.dev .dn small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev b { font-weight: 400; color: var(--fg2); text-align: right; }
.dev .io { grid-column: 2 / span 2; color: var(--muted); font-size: 11px; display: flex; gap: 16px; }
.off { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------------------------------------------------------------- tooltip */
.tip {
  position: fixed; z-index: 10; pointer-events: none; opacity: 0; transition: opacity .15s;
  background: rgba(35, 35, 38, .96); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 120px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.tip.on { opacity: 1; }
.tip .tt { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.tip .tr { display: flex; align-items: center; gap: 8px; }
.tip .tr i { width: 10px; height: 2px; border-radius: 1px; }
.tip .tr b { font-weight: 600; color: var(--fg); }
.tip .tr span { color: var(--muted); }

@media (max-width: 980px) {
  .row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 12px; }
  .live { min-width: 0; }
  .crumb { display: none; }
  .mach .mx { gap: 12px; }
  .search { width: 140px; }
  .cores { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
  .core { grid-template-columns: 16px 1fr 34px; gap: 8px; }
  .tile .tv { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
