:root {
  color-scheme: dark;
  --bg: #08090a;
  --raised: #111214;
  --hover: #16171a;
  --control: #17181b;
  --line: #1f2024;
  --line-2: #2c2e33;
  --text: #f2f3f5;
  --text-2: #a4a7ae;
  --text-3: #71747c;
  --accent: #5763d0;
  --accent-hover: #6570dc;
  --accent-text: #a5adf2;
  --good: #4cc38a;
  --warn: #f0b440;
  --bad: #f2636a;
  --fig: #62656d;
  --fig-bright: #d4d6da;
  --fig-dim: #303238;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
main:focus { outline: none; }
svg { display: block; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---- frame ---- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  background: var(--bg); padding: 14px 10px; border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; padding: 3px 8px; font-size: 13px; font-weight: 600; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--text); position: relative; flex: none; }
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; left: 4px; right: 4px; height: 2.5px; border-radius: 1px; background: var(--bg);
}
.brand-mark::before { top: 5px; }
.brand-mark::after { bottom: 5px; opacity: .55; }
#nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 8px;
  border-radius: 6px; color: var(--text-2); font-weight: 500; transition: background .1s, color .1s;
}
.nav-item .icon { color: var(--text-3); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--control); color: var(--text); }
.nav-item.active .icon { color: var(--text); }
.nav-count { margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 9px; text-align: center; font-size: 11px; font-weight: 600; line-height: 18px; }
.nav-count.critical { background: var(--bad); color: #1c0506; }
.nav-count.warning { background: var(--warn); color: #1c1200; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 45px; padding: 0 32px; position: sticky; top: 0; z-index: 5; background: rgba(8, 9, 10, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.crumbs { color: var(--text-3); display: flex; gap: 7px; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a:hover { color: var(--text); }
.crumbs strong { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.fresh { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.fresh-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.fresh.stale .fresh-dot { background: var(--bad); }
.btn.menu-button { display: none; }
#page { padding: 0 32px 56px; max-width: 1480px; width: 100%; }

/* ---- headline ---- */
.headline { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 40px 0 36px; flex-wrap: wrap; }
.headline h1 { font-size: clamp(24px, 2.7vw, 36px); line-height: 1.16; font-weight: 500; letter-spacing: -.022em; color: var(--text-3); max-width: 880px; text-wrap: pretty; }
.headline h1 b { font-weight: 500; color: var(--text); }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.page-head { display: flex; align-items: flex-end; gap: 20px; padding: 32px 0 24px; flex-wrap: wrap; }
.page-head > div:first-child { margin-right: auto; }
.page-head h1 { font-size: 26px; line-height: 1.2; font-weight: 500; letter-spacing: -.018em; }
.page-head p { color: var(--text-3); margin-top: 4px; font-size: 14px; }
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 28px 0 12px; flex-wrap: wrap; }
.subhead h2 { font-size: 15px; font-weight: 500; }
.head-fig { width: 112px; color: var(--text-3); }
.head-fig .fig-label { margin-bottom: 2px; }

/* ---- figures ---- */
.fig-label { display: block; font: 10.5px/1.4 var(--mono); color: #4d5057; }
.figs { margin-bottom: 0; }
.fig-cell { display: flex; flex-direction: column; min-width: 0; padding: 18px 24px 22px; background: var(--bg); transition: background .15s; }
.fig-art { flex: 1; display: grid; place-items: center; padding: 10px 0 18px; }
.fig-art svg { width: 100%; height: clamp(150px, 17vw, 230px); }
.head-fig svg { width: 100%; height: 84px; }
.fig-cell h3 { font-size: 13px; font-weight: 500; color: var(--text); }
.fig-cell p { color: var(--text-3); margin-top: 4px; max-width: 34ch; min-height: 4.5em; }
a.fig-cell:hover { background: #0c0d0f; }
a.fig-cell:hover .fig-label { color: var(--text-3); }
.f { fill: var(--bg); stroke: var(--fig); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.f.bright { stroke: var(--fig-bright); }
.f.dim { stroke: var(--fig-dim); }
.f.bad { stroke: var(--bad); }
.f.open { fill: none; }
.f.dots { stroke-dasharray: 1 2.5; }
.f.lit { stroke: var(--fig-bright); fill: none; }
.f.solid { fill: var(--fig-bright); stroke: none; }
.f.solid-bad { fill: var(--bad); stroke: none; }
.fig-cube { cursor: pointer; }
.fig-cube:hover .f:not(.bad):not(.solid) { stroke: var(--fig-bright); }

/* ---- hairline layout ---- */
.card { padding: 20px 0; min-width: 0; border-top: 1px solid var(--line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; min-height: 24px; flex-wrap: wrap; }
.card-head h2 { font-size: 13px; font-weight: 500; }
h2.minor { font-size: 13px; font-weight: 500; margin: 20px 0 6px; }
.grid { display: grid; gap: 1px; background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grid > .card { background: var(--bg); border: 0; padding: 18px 20px 20px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 > :nth-child(2n+1), .cols-3 > :nth-child(3n+1) { padding-left: 0 !important; }
.cols-2 > :nth-child(2n), .cols-3 > :nth-child(3n) { padding-right: 0 !important; }
.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: stretch; border-bottom: 1px solid var(--line); }
.with-rail > :first-child { padding-right: 28px; min-width: 0; }
.with-rail > :last-child { padding-left: 24px; border-left: 1px solid var(--line); min-width: 0; }
.stack > .card:first-child { border-top: 0; }
.section-gap { margin-top: 28px; }
.card.section-gap { margin-top: 0; }
.hero { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; padding: 32px 0 24px; }
.hero-icon { display: none; }
.hero-text { flex: 1; min-width: 220px; }
.hero-text h1 { font-size: 26px; font-weight: 500; letter-spacing: -.018em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; line-height: 1.2; }
.hero-text p { color: var(--text-3); margin-top: 6px; font-size: 14px; overflow-wrap: anywhere; }

/* ---- status, buttons ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; white-space: nowrap; letter-spacing: 0; color: var(--text-2); vertical-align: middle; }
.pill .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.pill.good .icon { color: var(--good); }
.pill.warn { color: var(--warn); }
.pill.bad { color: var(--bad); }
.pill.idle { color: var(--text-3); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 0 11px;
  border: 1px solid var(--line-2); border-radius: 6px; background: var(--control); color: var(--text); font-weight: 500; cursor: pointer;
  transition: background .1s, border-color .1s;
}
.btn .icon { width: 14px; height: 14px; }
.btn:hover { background: #202125; border-color: #393b41; }
.btn:active { background: #1a1b1f; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); }
.btn-solid-danger { background: #c9383f; border-color: #c9383f; color: #fff; }
.btn-solid-danger:hover { background: #d9444b; border-color: #d9444b; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--text); }
.btn-small { min-height: 26px; padding: 0 8px; font-size: 12px; border-radius: 5px; }
.btn-icon { width: 32px; padding: 0; }
.btn.only-icon { width: 28px; padding: 0; }
.btn-block { width: 100%; }
.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text-2); }

.segments { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.segments button { border: 0; border-left: 1px solid var(--line-2); background: transparent; color: var(--text-3); min-height: 26px; padding: 0 10px; font-size: 12px; font-weight: 500; cursor: pointer; }
.segments button:first-child { border-left: 0; }
.segments button:hover { color: var(--text); background: var(--hover); }
.segments button.on { background: var(--control); color: var(--text); }

/* ---- attention ---- */
.attention { display: flex; flex-direction: column; }
.alert { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin: 0 -8px; border-radius: 6px; transition: background .1s; }
a.alert:hover { background: var(--hover); }
.alert-icon { display: grid; place-items: center; flex: none; }
.alert.critical .alert-icon { color: var(--bad); }
.alert.warning .alert-icon { color: var(--warn); }
.alert.info .alert-icon { color: var(--text-3); }
.alert strong { font-weight: 500; }
.alert span.muted { margin-left: 8px; }
.alert > div:last-child { min-width: 0; }

/* ---- metrics ---- */
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-2); font-weight: 500; }
.metric-head > span { display: flex; align-items: center; gap: 7px; min-width: 0; }
.metric-head .icon { color: var(--text-3); }
.metric-value { font-size: 24px; font-weight: 500; letter-spacing: -.02em; line-height: 1.2; margin-top: 8px; }
.metric-value small { font-size: 13px; color: var(--text-3); font-weight: 400; letter-spacing: 0; margin-left: 3px; }
.metric-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; min-height: 18px; }
.bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--text-2); transition: width .4s ease; }
.bar.warn i { background: var(--warn); }
.bar.bad i { background: var(--bad); }

.chart { position: relative; height: 130px; margin-top: 14px; touch-action: pan-y; }
.chart.tall { height: 200px; }
.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 10.5px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); text-align: center; }
.tip {
  position: absolute; top: 0; z-index: 4; pointer-events: none; min-width: 120px; padding: 7px 9px;
  background: var(--raised); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .6); font-size: 12px; white-space: nowrap;
}
.tip b { font-weight: 500; }
.tip .row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.tip .swatch, .legend .swatch { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 400; color: var(--text-3); font-size: 12px; padding: 4px 10px 8px; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
td strong { font-weight: 500; }
tr.row-link { cursor: pointer; transition: background .1s; }
tr.row-link:hover { background: var(--raised); }
th.right, td.right { text-align: right; }
.name-cell { min-width: 220px; }
.name-cell strong { display: block; font-weight: 500; }
.name-cell span { color: var(--text-3); font-size: 12px; }
.grid .name-cell { min-width: 110px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
/* Actions stay in view when a wide table scrolls sideways. */
table:has(.row-actions) th:last-child, td:has(> .row-actions) { position: sticky; right: 0; background: var(--bg); padding-left: 10px; }

/* ---- detail lists ---- */
.facts { display: grid; }
.fact { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); }
.fact:first-child { border-top: 0; padding-top: 0; }
.fact:last-child { padding-bottom: 0; }
.fact > span:first-child { color: var(--text-3); flex: none; max-width: 60%; overflow-wrap: anywhere; }
.fact > span:last-child { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.copy { background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-family: var(--mono); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.copy:hover { color: var(--accent-text); }
.copy .icon { width: 12px; height: 12px; color: var(--text-3); }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 18px 16px; }
.stat strong { display: block; font-size: 20px; font-weight: 500; letter-spacing: -.015em; line-height: 1.25; }
.stat span { color: var(--text-3); font-size: 12px; }

.split-bar { display: flex; gap: 2px; height: 4px; overflow: hidden; margin: 10px 0 12px; }
.split-bar i { display: block; min-width: 2px; border-radius: 1px; }
.key-rows .fact > span:first-child { color: var(--text-2); }

/* ---- logs ---- */
.logs {
  margin: 0; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 12px; height: 420px; overflow: auto;
  font: 11.5px/1.6 var(--mono); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere;
}
.log-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- dialog, toast ---- */
dialog { border: 1px solid var(--line-2); padding: 20px; background: var(--raised); color: var(--text); border-radius: 10px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 24px 70px #000; }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog h2 { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
dialog p { color: var(--text-2); margin-bottom: 14px; }
dialog code { font-family: var(--mono); color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
input[type=text], input[type=password], .login-card input {
  width: 100%; min-height: 36px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; font-size: 16px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.toast-area { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--raised); border: 1px solid var(--line-2); padding: 9px 12px; border-radius: 7px; font-weight: 500; box-shadow: 0 8px 30px #000; max-width: min(420px, calc(100vw - 40px)); overflow-wrap: anywhere; animation: rise .16s ease-out; }
.toast.bad { color: var(--bad); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---- login ---- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { padding: 0; }
.login-card h1 { font-size: 24px; font-weight: 500; letter-spacing: -.018em; margin-top: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.login-card .btn { margin-top: 6px; min-height: 36px; }
.form-error { color: var(--bad); }

/* ---- smaller windows and phones ---- */
@media (max-width: 1180px) {
  .with-rail { grid-template-columns: minmax(0, 1fr); border-bottom: 0; }
  .with-rail > :first-child { padding-right: 0; }
  .with-rail > :last-child { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .cols-3:not(.figs) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3:not(.figs) > :nth-child(n) { padding-left: 20px !important; padding-right: 20px !important; }
  .cols-3:not(.figs) > :nth-child(2n+1) { padding-left: 0 !important; }
  .cols-3:not(.figs) > :nth-child(2n) { padding-right: 0 !important; }
  /* An odd last card takes the full row instead of leaving a hole. */
  .cols-3:not(.figs) > :last-child:nth-child(odd) { grid-column: 1 / -1; padding-right: 0 !important; }
  .fig-cell { padding: 16px 16px 20px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 20; left: 0; top: 0; bottom: 0; width: 260px; height: 100dvh; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 60px #000; }
  .sidebar.open { transform: none; }
  .nav-item { min-height: 40px; }
  .btn.menu-button { display: inline-flex; margin-left: -8px; }
  .topbar { padding: 0 16px; padding-top: env(safe-area-inset-top); }
  #page { padding: 0 16px 40px; }
  .headline { padding: 28px 0 24px; }
  .head-fig { display: none; }
  .cols-2, .cols-3, .cols-3:not(.figs) { grid-template-columns: minmax(0, 1fr); }
  .grid > .card:nth-child(n), .cols-3:not(.figs) > :nth-child(n), .fig-cell:nth-child(n) { padding-left: 0 !important; padding-right: 0 !important; }
  .fig-art svg { height: 130px; }
  .fig-cell p { min-height: 0; }
  .fig-cell:nth-child(n) { padding-top: 16px; padding-bottom: 20px; }
  .btn { min-height: 40px; }
  .btn-small { min-height: 34px; }
  .btn.only-icon { width: 36px; }
  .segments { max-width: 100%; }
  .segments button { min-height: 34px; padding: 0 8px; }
  .alert span.muted { display: block; margin-left: 0; }
  .logs { height: 340px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
