/* SmokeTrail – fog-grey surfaces, slate-blue smoke, status colours reserved for loss. */
:root {
  color-scheme: light;
  --page: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --ink: #17202b;
  --ink-2: #4c5866;
  --muted: #7d8896;
  --line: #dbe0e6;
  --line-strong: #c3cad3;
  --grid: #e8ebef;
  --smoke: 61, 90, 128;          /* rgb triplet, alpha applied in the chart */
  --median-ink: #17202b;
  --accent: #2c5c9a;
  --accent-wash: rgba(44, 92, 154, 0.09);
  --select: rgba(44, 92, 154, 0.14);

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --unknown: #a3acb7;

  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --radius-s: 4px;
  --radius-m: 8px;
  --sidebar-w: 288px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #151b23;
    --panel: #1b222c;
    --panel-2: #212a35;
    --ink: #e4e8ee;
    --ink-2: #b2bcc8;
    --muted: #8590a0;
    --line: #2b3542;
    --line-strong: #3a4656;
    --grid: #253039;
    --smoke: 150, 178, 218;
    --median-ink: #e4e8ee;
    --accent: #8db4ea;
    --accent-wash: rgba(141, 180, 234, 0.10);
    --select: rgba(141, 180, 234, 0.16);
    --unknown: #5f6b7a;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #151b23;
  --panel: #1b222c;
  --panel-2: #212a35;
  --ink: #e4e8ee;
  --ink-2: #b2bcc8;
  --muted: #8590a0;
  --line: #2b3542;
  --line-strong: #3a4656;
  --grid: #253039;
  --smoke: 150, 178, 218;
  --median-ink: #e4e8ee;
  --accent: #8db4ea;
  --accent-wash: rgba(141, 180, 234, 0.10);
  --select: rgba(141, 180, 234, 0.16);
  --unknown: #5f6b7a;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ app shell */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  text-decoration: none; color: var(--ink);
}
.brand svg { flex: none; }
.brand-name { font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.search {
  margin: 0 14px 10px;
  position: relative;
}
.search input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--panel-2);
}
.search input::placeholder { color: var(--muted); }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.tree { flex: 1; overflow: auto; padding: 4px 8px 16px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 14px; }
.tree-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: 0; border-radius: var(--radius-s);
  background: none; text-align: left; cursor: pointer;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
}
.tree-row:hover { background: var(--accent-wash); color: var(--ink); }
.tree-row[aria-current="page"], .tree-row.current { background: var(--accent-wash); color: var(--ink); }
.tree-row[aria-current="page"] .label, .tree-row.current .label { font-weight: 650; }
.tree-row a.label { color: inherit; text-decoration: none; }
.tree-row a.label::after { content: ""; position: absolute; inset: 0; }
.tree-row.group { position: relative; }
.tree-row.group .caret, .tree-row.group .badge { position: relative; z-index: 1; }
.tree-row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .value { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tree-row.group { color: var(--ink); font-weight: 550; }
.caret {
  flex: none; width: 16px; height: 16px; display: grid; place-items: center;
  border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted);
  border-radius: 3px;
}
.caret svg { transition: transform .15s ease; }
.collapsed > .tree-row .caret svg { transform: rotate(-90deg); }
.collapsed > ul { display: none; }
.tree .empty { padding: 12px; color: var(--muted); font-size: 14px; }

.dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--unknown);
}
.dot.ok { background: var(--good); }
.dot.light { background: var(--warning); }
.dot.medium { background: var(--serious); }
.dot.heavy, .dot.down { background: var(--critical); }
.dot.down { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--critical); width: 7px; height: 7px; margin: 0 1px; }
.badge {
  font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 3px 6px; border-radius: 10px;
  background: color-mix(in srgb, var(--critical) 15%, transparent);
  color: var(--critical);
}
.badge.warn { background: color-mix(in srgb, var(--serious) 18%, transparent); color: var(--ink-2); }

.sidebar-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--panel); cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

/* ------------------------------------------------------------ main */
main { min-width: 0; padding: 22px 32px 48px; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.menu-btn { display: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--ink-2); text-decoration: none; padding: 2px 4px; border-radius: 3px; }
.crumbs a:hover { color: var(--ink); background: var(--accent-wash); }
.crumbs .sep { color: var(--line-strong); }
.topbar .spacer { flex: 1; }

.ranges {
  display: inline-flex; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m);
}
.ranges button {
  border: 0; background: none; cursor: pointer;
  padding: 4px 11px; border-radius: 5px; font-size: 13.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.ranges button:hover { color: var(--ink); }
.ranges button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.zoom-note { font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 8px; align-items: center; }
.text-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-m);
  padding: 4px 10px; cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.text-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.banner {
  margin: 0 0 16px; padding: 10px 14px;
  border-radius: var(--radius-m); font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent);
  background: color-mix(in srgb, var(--critical) 8%, var(--panel));
}
.banner.demo {
  border-color: color-mix(in srgb, var(--warning) 50%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, var(--panel));
}
.banner code { font-family: var(--mono); font-size: 13px; }

.page-head { margin-bottom: 18px; }
.page-head .remark, .page-head h1 { max-width: 72ch; }
.page-head h1 {
  margin: 0; font-size: 30px; line-height: 1.15; font-weight: 680; letter-spacing: -0.02em;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--ink-2); font-size: 14px; }
.meta .host { font-family: var(--mono); font-size: 13.5px; color: var(--ink); }
.remark { margin: 8px 0 0; color: var(--ink-2); }

/* the instrument: chart panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.stat { padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat dt { font-size: 13px; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 22px; font-weight: 620; letter-spacing: -0.01em; white-space: nowrap; }
.stat dd small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .sub { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat .loss-flag { display: inline-flex; align-items: center; gap: 7px; }

.chart-box { padding: 14px 14px 10px 8px; }
.chart-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 4px 8px 12px; font-size: 13px; color: var(--muted);
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 3px 10px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.chart { position: relative; height: 380px; touch-action: pan-y; }
.chart.small { height: 170px; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart canvas.overlay { cursor: crosshair; }
.chart .nodata {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; pointer-events: none; text-align: center; padding: 0 20px;
}

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  padding: 10px 12px 2px; font-size: 12.5px; color: var(--ink-2);
}
.legend .sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend .box { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend .group-label { color: var(--muted); }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 190px; padding: 9px 11px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-m);
  box-shadow: 0 6px 24px rgba(15, 25, 40, 0.14);
  font-size: 12.5px; line-height: 1.45;
}
.tooltip .tt-time { color: var(--muted); margin-bottom: 4px; }
.tooltip table { border-collapse: collapse; width: 100%; }
.tooltip td { padding: 0; }
.tooltip td:last-child { text-align: right; font-variant-numeric: tabular-nums; padding-left: 14px; }
.tooltip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.section-title { font-size: 17px; font-weight: 640; margin: 30px 0 12px; letter-spacing: -0.01em; }
.multiples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.multiple { padding: 10px 10px 6px 4px; cursor: pointer; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-m); width: 100%; }
.multiple:hover { border-color: var(--line-strong); }
.multiple h3 { margin: 0 0 4px 12px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }

/* overview list */
.ov-group { margin-bottom: 26px; }
.ov-group h2 { font-size: 15px; font-weight: 640; margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; }
.ov-group h2 a { color: var(--ink); text-decoration: none; }
.ov-group h2 a:hover { text-decoration: underline; }
.ov-group h2 .count { color: var(--muted); font-weight: 450; font-size: 13px; }
.ov-list { list-style: none; margin: 0; padding: 0; }
.ov-head, .ov-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(160px, 2.4fr) 96px 92px 132px;
  gap: 16px; align-items: center;
  padding: 8px 16px;
}
.ov-head { font-size: 12.5px; color: var(--muted); padding-top: 0; padding-bottom: 6px; }
.ov-head span:nth-child(n+3), .ov-row .r { text-align: right; }
.ov-row { border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.ov-list li:first-child .ov-row { border-top: 0; }
.ov-row:hover { background: var(--accent-wash); }
.ov-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ov-name > div { min-width: 0; }
.ov-name strong { display: block; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-name .host { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-row canvas { width: 100%; height: 34px; display: block; }
.ov-row .r { font-variant-numeric: tabular-nums; font-size: 14px; }
.ov-row .r small { color: var(--muted); font-size: 12px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.summary span { display: inline-flex; align-items: center; gap: 7px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px 14px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data .r { text-align: right; }

.empty-state { max-width: 60ch; padding: 40px 0; color: var(--ink-2); }
.empty-state h1 { font-size: 22px; color: var(--ink); }
.empty-state pre { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; font-size: 13px; overflow: auto; }

.loading { opacity: .55; transition: opacity .2s; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 20; left: 0; top: 0; width: min(88vw, 320px);
    transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .2);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10, 15, 25, .35); z-index: 15; }
  .menu-btn { display: inline-grid; }
  main { padding: 14px 16px 40px; }
  .page-head h1 { font-size: 24px; }
  .multiples { grid-template-columns: 1fr; }
  .chart { height: 300px; }
  .ov-head { display: none; }
  .ov-row { grid-template-columns: minmax(0, 1fr) 70px 64px; gap: 4px 12px; }
  .ov-row canvas { grid-column: 1 / -1; grid-row: 2; }
  .ov-row .r.range-loss { display: none; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { border-left: 0; }
  .stat:nth-child(4) { border-left: 1px solid var(--line); }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat dd { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ------------------------------------------------------------ zoom & embed */
.toolbar-right { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.zoombar button { display: inline-grid; place-items: center; padding: 4px 8px; }
.chart-help { margin: 4px 12px 0; font-size: 12px; color: var(--muted); }
@media (hover: none) { .chart-help { display: none; } }
.chart canvas.overlay:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chart-hint {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  padding: 8px 14px; border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--ink) 82%, transparent); color: var(--panel);
  font-size: 13px; pointer-events: none; z-index: 4; white-space: nowrap;
}
.head-row { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; }
.embed-btn { flex: none; margin-top: 4px; }
.embed-panel { margin: -4px 0 18px; }
.embed-body { padding: 16px 18px 18px; max-width: 980px; }
.embed-body h2 { font-size: 16px; margin: 0 0 10px; }
.embed-body h3 { font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin: 16px 0 6px; }
.embed-body p { margin: 0; color: var(--ink-2); font-size: 14px; max-width: 72ch; }
.embed-body code, .snippet pre { font-family: var(--mono); font-size: 12.5px; }
.embed-form { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: 13.5px; color: var(--ink-2); }
.embed-form label { display: inline-flex; align-items: center; gap: 6px; }
.embed-form select {
  font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2); color: var(--ink);
}
.snippet { display: flex; gap: 10px; align-items: flex-start; }
.snippet pre {
  flex: 1; min-width: 0; margin: 0; padding: 10px 12px; overflow-x: auto; white-space: pre;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-m); color: var(--ink);
}
.embed-note { margin-top: 10px !important; font-size: 13px !important; }
.embed-preview { width: 100%; border: 1px dashed var(--line-strong); border-radius: var(--radius-m); background: var(--page); }
