/* Live: a dark band for right now, then tables and charts in alternating white and tone sections. */
.section-head:has(+ .kpis) { --lead: 9; } /* the lead starts over the third figure below */

.dash-section { padding-block-start: var(--section); }
.page-section--dark { --dash-muted: var(--on-dark-muted); }

/* the live line under the title */
.live-bar { gap: 1rem 1.75rem; }
.live-line { display: inline-flex; align-items: center; font-variant-numeric: tabular-nums; }
.owner-chip { display: inline-flex; align-items: center; gap: 0.75rem; }
.owner-chip[hidden], .live-state[hidden] { display: none; }
.live-noscript { grid-column: 1 / -1; }

/* six figures */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--block-gap) var(--gutter); }
.kpi { min-inline-size: 0; }
.kpi .figure-num { white-space: nowrap; }
.kpi .figure-num.is-down { color: var(--on-dark-warn); }
.kpi .figure-label { color: inherit; font-size: var(--step-body); margin-block-start: 0.6rem; max-inline-size: none; }
.kpi-foot { font-size: var(--step-small); color: var(--dash-muted, var(--muted)); font-variant-numeric: tabular-nums; }
.spark { display: block; inline-size: 100%; block-size: 30px; margin-block-start: 0.75rem; overflow: visible; }
.spark-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: currentColor; fill-opacity: 0.14; }
.meter { display: block; margin-block: 0.9rem 0.35rem; block-size: 4px; border-radius: 2px; background: color-mix(in oklch, currentColor 18%, transparent); overflow: clip; }
.meter > span { display: block; block-size: 100%; inline-size: var(--v, 0%); background: var(--ui-green); }

/* two panels side by side, on the page's twelve columns so they line up with the section head above */
.pair { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); row-gap: var(--block-gap); align-items: start; }
.pair--wide > :first-child { grid-column: 1 / span 7; }
.pair--wide > :last-child { grid-column: 9 / span 4; }
.pair--even > :first-child { grid-column: 1 / span 5; }
.pair--even > :last-child { grid-column: 7 / span 6; }
.pair + .pair, .kpis + .pair { margin-block-start: var(--block-gap); }
.traffic-main + .traffic-pair { margin-block-start: var(--block-gap); }
.panel { min-inline-size: 0; }
.panel-title { font-size: var(--step-lead); font-weight: 500; line-height: 1.2; }
.panel-title--next { margin-block-start: 2.5rem; }
.panel-sub { margin-block: 0.4rem 1.5rem; max-inline-size: 60ch; }
.panel-note { margin-block-start: 1rem; }
.panel .live-state { color: var(--dash-muted, var(--muted)); }
.panel .live-state[data-state='error'] { color: var(--warn); }
.page-section--dark .panel .live-state[data-state='error'] { color: var(--on-dark-warn); }

/* status words */
.st { display: inline-flex; align-items: center; white-space: nowrap; }
.live-dot--off { background: var(--muted); }

/* the network map */
.map { min-block-size: 340px; }
/* chart placeholders take the size page.js draws at: the map is 15 tool rows (10 when narrow), the bar charts scale with width */
.skel-chart--map { block-size: 408px; }
@media (max-width: 600px) { .skel-chart--map { block-size: 340px; } }
.skel-chart--traffic { aspect-ratio: 100 / 22; min-block-size: 190px; max-block-size: 300px; }
.skel-chart--byday { aspect-ratio: 100 / 18; min-block-size: 170px; max-block-size: 260px; }
.net { display: block; overflow: visible; font-family: inherit; }
.net .edge { fill: none; stroke: var(--field-1-ink); }
.net .edge.is-down { stroke: var(--on-dark-warn); }
.net .node--src { fill: var(--field-1); stroke: var(--field-1-ink); stroke-width: 2; }
.net .node--host { fill: var(--field-1); stroke: var(--on-dark-pos); stroke-width: 2.5; }
.net .node--host.is-down { stroke: var(--on-dark-warn); }
.net .node--tool { fill: var(--field-1-ink); }
.net .lab { font-size: var(--step-small); fill: var(--on-dark-muted); }
.net .lab--strong { fill: var(--field-1-ink); font-weight: 500; }
.net .lab--dim { fill: var(--on-dark-muted); }
.net .dot-req { fill: var(--on-dark-muted); }
.net .dot-paid { fill: var(--field-1-ink); }

/* legends */
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-block: 0.75rem; font-size: var(--step-small); color: var(--dash-muted, var(--muted)); }
.legend li { display: inline-flex; align-items: center; gap: 0.45rem; }
.sw { flex: none; display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 2px; }
.sw--0 { background: var(--ink); }
.sw--1 { background: var(--muted); }
.sw--2 { background: color-mix(in oklch, var(--ink) 28%, var(--bg)); }
.sw--paid { background: var(--bg); border: 2px solid var(--ink); border-radius: 50%; }
.sw--err { background: var(--warn); border-radius: 50%; }
.sw--req { background: var(--on-dark-muted); border-radius: 50%; inline-size: 6px; block-size: 6px; }
.sw--paidcall { background: var(--field-1-ink); border-radius: 50%; }
.sw--down { background: var(--ui-red); border-radius: 50%; }

/* paid calls, live */
.feed { display: grid; }
.feed li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.75rem; align-items: baseline; padding-block: 0.55rem; border-radius: var(--radius); }
.feed .tag-text { margin-inline-start: 0; }
.page-section--dark .tag-text { background: color-mix(in oklch, var(--field-1-ink) 14%, transparent); color: inherit; }
.feed-ago { color: var(--dash-muted, var(--muted)); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* services */
.hosts .days { display: inline-flex; gap: 2px; align-items: flex-end; block-size: 24px; inline-size: 11rem; vertical-align: middle; }
.hosts .days i { flex: 1; block-size: var(--v, 100%); min-inline-size: 2px; border-radius: 1px 1px 0 0; background: var(--ink); }
.hosts .days i.is-warn { background: var(--ui-amber); }
.hosts .days i.is-crit { background: var(--warn); }

/* bar charts */
.chart { overflow: visible; }
.vbars { display: block; overflow: visible; font-family: inherit; }
.vbars .grid { stroke: color-mix(in oklch, var(--ink) 14%, transparent); stroke-width: 1; }
.vbars .axis { font-size: var(--step-small); fill: var(--muted); font-variant-numeric: tabular-nums; }
.vbars .part--0 { fill: var(--ink); }
.vbars .part--1 { fill: var(--muted); }
.vbars .part--2 { fill: color-mix(in oklch, var(--ink) 28%, var(--bg)); }
.vbars .mark--paid { fill: var(--bg); stroke: var(--ink); stroke-width: 2; }
.vbars .mark--err { fill: var(--warn); }
.vbars .hit { fill: transparent; }

.hbars { display: grid; gap: 0.5rem; }
.hbars li { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) minmax(3.5rem, auto); gap: 0.75rem; align-items: center; }
.hb-name { overflow: clip; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { display: block; block-size: 12px; background: color-mix(in oklch, currentColor 6%, transparent); border-start-end-radius: 3px; border-end-end-radius: 3px; }
.hb-bar { display: block; block-size: 100%; inline-size: var(--v, 0%); min-inline-size: 2px; background: currentColor; border-start-end-radius: 3px; border-end-end-radius: 3px; }
.hb-bar--paid { background: var(--pos); }
.hb-val { text-align: end; font-variant-numeric: tabular-nums; }

/* the last 24 hours */
.strip { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.strip i { position: relative; block-size: 40px; border-radius: 2px; }
.strip i.is-paid::after { content: ''; position: absolute; inset-block-start: 5px; inset-inline-start: calc(50% - 4px); inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--ink); border: 2px solid var(--bg); }
.lv-0 { background: var(--field-2); }
.lv-1 { background: color-mix(in oklch, var(--ink) 16%, var(--bg)); }
.lv-2 { background: color-mix(in oklch, var(--ink) 30%, var(--bg)); }
.lv-3 { background: color-mix(in oklch, var(--ink) 44%, var(--bg)); }
.lv-4 { background: color-mix(in oklch, var(--ink) 58%, var(--bg)); }
.lv-5 { background: color-mix(in oklch, var(--ink) 72%, var(--bg)); }
.lv-6 { background: color-mix(in oklch, var(--ink) 86%, var(--bg)); }
.lv-7 { background: var(--ink); }
.strip-axis { display: flex; justify-content: space-between; margin-block-start: 0.4rem; font-size: var(--step-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.ramp { display: flex; align-items: center; gap: 3px; margin-block-start: 0.75rem; font-size: var(--step-small); color: var(--muted); }
.ramp i { inline-size: 14px; block-size: 10px; border-radius: 2px; }
.ramp span:first-child { margin-inline-end: 0.4rem; }
.ramp span:last-child { margin-inline-start: 0.4rem; }

/* show as table */
.as-table { margin-block-start: 1rem; }
.as-table summary { display: inline-flex; align-items: center; min-block-size: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 0.07em; }
.as-table summary:active { opacity: 0.7; }
.as-table[open] summary { margin-block-end: 0.5rem; }
/* a closed toggle keeps no layout for its table (closed details otherwise still lay out their hidden rows);
   an opening one fades its table in from a few px above, with no exit animation (the rows just go) */
.as-table:not([open]) > .table-wrap { display: none; }
.as-table[open] > .table-wrap { transition: opacity 180ms var(--ease-out); }
@starting-style { .as-table[open] > .table-wrap { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .as-table[open] > .table-wrap { transition: opacity 180ms var(--ease-out), translate 180ms var(--ease-out); }
  @starting-style { .as-table[open] > .table-wrap { translate: 0 -4px; } }
}
@media (min-width: 901px) {
  .as-table .table-wrap { max-block-size: 26rem; overflow-y: auto; }
}
table.data .of { color: var(--muted); }
table.data code { font-size: var(--step-body); }

/* two-ended rows: checks, counts, machine */
.check-list, .pairs { display: grid; grid-template-columns: minmax(0, 1fr); }
/* the checks run across the page in columns instead of one long list beside a short chart */
.checks-panel .check-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); column-gap: clamp(2rem, 1rem + 4vw, 6rem); }
.days-main + .checks-panel { margin-block-start: var(--block-gap); }
.check-list li, .pairs li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding-block: 0.5rem; }
.check-list li > span:first-child, .pairs li > span:first-child { color: var(--dash-muted, var(--muted)); }

/* owner view */
.owner .pair, .owner .kpis + .pair { margin-block-start: var(--block-gap); }
.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: 1.5rem var(--gutter); margin-block-end: 1.5rem; }
.mini-num { font-size: var(--step-lead); font-weight: 500; font-variant-numeric: tabular-nums; }
.minis .figure-label { margin-block-start: 0.2rem; }

@media (hover: hover) and (pointer: fine) {
  .vbars .hit:hover { fill: color-mix(in oklch, var(--ink) 6%, transparent); }
  .as-table summary:hover { color: var(--muted); }
}
/* a row that arrived since the last refresh starts lit and fades: an overlay's opacity, so nothing repaints the row */
.feed li { position: relative; }
.feed li.is-new::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: color-mix(in oklch, var(--field-1-ink) 18%, transparent); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .feed li.is-new::before { transition: opacity 1.2s ease; }
  @starting-style { .feed li.is-new::before { opacity: 1; } }
}

@media (max-width: 1100px) {
  .pair > * { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .hosts .days { inline-size: 9rem; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem var(--gutter); }
  .hbars li { grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) auto; gap: 0.5rem; }
  .strip i { block-size: 32px; }
  .pair + .pair, .kpis + .pair { margin-block-start: var(--block-gap); }
}
