/* HIGH dashboard. Dark is the house look (hijinks.uno is dark); light is its own set of steps.
   Chart series colours are validated with the dataviz palette checker against each page colour:
   dark #26aaa4 / #ac55d8 on #0c0a10, light #00968f / #a03fc7 on #f7f5f9. The brand cyan and pink
   are too light to carry data on the dark page, so they stay in the chrome. */

:root {
  color-scheme: dark;
  --page: #0c0a10;
  --raise: #16121c;
  --line: #2a2533;
  --base: #3a3444;
  --ink: #f2eef6;
  --ink-2: #bdb5c8;
  --muted: #8a8296;
  --brand: #54e2dc;
  --brand-2: #d979ff;
  --s1: #26aaa4;
  --s2: #ac55d8;
  --s1-wash: rgba(38, 170, 164, 0.12);
  --good: #0ca30c;
  --up: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2.6' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0.035'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --page: #f7f5f9;
    --raise: #ffffff;
    --line: #e3dfe8;
    --base: #c9c3d1;
    --ink: #16121b;
    --ink-2: #4f475a;
    --muted: #756d81;
    --brand: #00968f;
    --brand-2: #a03fc7;
    --s1: #00968f;
    --s2: #a03fc7;
    --s1-wash: rgba(0, 150, 143, 0.1);
    --up: #006300;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page) var(--grain);
  color: var(--ink);
  font: 400 15px/1.5 'Space Grotesk', system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration-color: var(--base);
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-color: var(--brand);
}
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 64px;
}
@media (min-width: 720px) {
  .wrap {
    padding: 0 32px 80px;
  }
}

/* ── Header ─────────────────────────────────────────── */

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0 20px;
  flex-wrap: wrap;
}
.top .logo {
  height: 26px;
  display: block;
}
.top h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
}
.top .when {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}
.top form {
  margin: 0;
}

button,
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
button:hover {
  border-color: var(--base);
  background: var(--raise);
}
button[disabled] {
  opacity: 0.6;
  cursor: progress;
}

/* ── Sections ───────────────────────────────────────── */

section {
  border-top: 1px solid var(--line);
  padding: 28px 0 8px;
}
section > header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}
.note {
  color: var(--muted);
  font-size: 13px;
}
section > header .note {
  margin-left: auto;
}
.cols {
  display: grid;
  gap: 32px 48px;
}
@media (min-width: 900px) {
  .cols {
    grid-template-columns: 1fr 1fr;
  }
  .cols.wide-left {
    grid-template-columns: 3fr 2fr;
  }
}
.cols > * {
  min-width: 0;
}

/* ── Needs you ──────────────────────────────────────── */

.alerts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.alerts li {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  min-width: 76px;
}
.badge::before {
  content: '';
  width: 10px;
  height: 10px;
  flex: none;
}
.badge.critical::before {
  background: var(--critical);
  border-radius: 50%;
}
.badge.serious::before {
  background: var(--serious);
  transform: rotate(45deg) scale(0.85);
}
.badge.warning::before {
  background: var(--warning);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.badge.good::before {
  background: var(--good);
  border-radius: 50%;
}
.all-clear {
  color: var(--ink-2);
  display: flex;
  gap: 10px;
  align-items: baseline;
}

/* ── Tables ─────────────────────────────────────────── */

.scroll {
  overflow-x: auto;
  margin: 0 -16px;
  padding: 0 16px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  padding: 0 12px 8px 0;
  white-space: nowrap;
}
td {
  padding: 9px 12px 9px 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
th.n,
td.n {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td .sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.d-up {
  color: var(--up);
}
.d-down {
  color: var(--muted);
}
.none {
  color: var(--base);
}

.projects td:first-child {
  padding-left: 14px;
  position: relative;
  white-space: nowrap;
  font-weight: 500;
}
.projects td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 2px;
  background: var(--tint);
}
.projects .links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 4px 0 0 -3px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
/* Each link is its site's favicon, on a light tile in both themes: some favicons are black
   (Shaperino's disc, Atlas Mundi's globe) and would vanish on the dark page. The padding makes
   a 22px target around a 16px icon. */
.projects .links a.icon {
  display: inline-flex;
  padding: 3px;
  border-radius: 5px;
  background: #f4f1f7;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.projects .links a.icon:hover {
  box-shadow: inset 0 0 0 1px var(--brand);
}
.projects .links img {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
}
.projects .n {
  min-width: 92px;
}

/* ── Figures ────────────────────────────────────────── */

.hero {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.hero .value {
  font-size: 56px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}
.hero .label {
  color: var(--ink-2);
}
.big {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.big .value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.tiles {
  display: grid;
  gap: 24px;
}
@media (min-width: 560px) {
  .tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}
.tile .label {
  color: var(--ink-2);
  font-size: 13px;
}
.tile .value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.tile .delta {
  font-size: 13px;
}
.tile .spark {
  margin-top: 6px;
}
.tile .off {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.stats {
  display: flex;
  gap: 8px 28px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--ink-2);
}
.stats b {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

/* ── Charts ─────────────────────────────────────────── */

.spark {
  display: block;
  width: 100%;
  max-width: 160px;
  height: 26px;
  overflow: visible;
}
.spark polyline {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.spark.on polyline {
  stroke: var(--s1);
}

.chart {
  margin: 0;
  position: relative;
  outline-offset: 6px;
}
.chart .plot {
  position: relative;
  height: 180px;
  margin-left: 40px;
}
.chart .grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
}
.chart .grid.zero {
  border-top-color: var(--base);
}
.chart .grid span {
  position: absolute;
  right: calc(100% + 8px);
  top: -9px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart svg.marks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart .area {
  fill: var(--s1-wash);
}
.chart .stroke {
  fill: none;
  stroke: var(--s1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .dot {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: 0 0 -5px -5px;
  border-radius: 50%;
  background: var(--s1);
  box-shadow: 0 0 0 2px var(--page);
}
.chart .xaxis {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 0 40px;
  font-size: 12px;
  color: var(--muted);
}
.chart .cross {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--base);
  pointer-events: none;
}
.chart .cross[hidden] {
  display: none;
}

.chart .bars {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
}
.chart .col {
  position: relative;
  flex: 1;
  max-width: 24px;
  margin: 0 auto;
}
.chart .col i {
  position: absolute;
  left: 0;
  right: 0;
  display: block;
}
.chart .col .u {
  background: var(--s1);
  border-radius: 4px 4px 0 0;
}
.chart .col .w {
  background: var(--s2);
  border-radius: 0 0 4px 4px;
}
.chart .col.on i {
  filter: brightness(1.25);
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-2);
  margin: 0 0 10px;
  flex-wrap: wrap;
}
.legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
  background: var(--k);
}
.legend .line::before {
  height: 2px;
  vertical-align: 3px;
  border-radius: 1px;
}

.tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.tip strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  margin-right: 6px;
}
.tip .row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tip .row::before {
  content: '';
  width: 12px;
  height: 2px;
  background: var(--k);
  border-radius: 1px;
}
.tip .head {
  color: var(--muted);
  margin-bottom: 4px;
}

details.table-view {
  margin: 10px 0 0;
  font-size: 13px;
}
details.table-view summary {
  color: var(--muted);
  cursor: pointer;
}
details.table-view table {
  margin-top: 8px;
  max-width: 420px;
}

/* ── Bars in lists ──────────────────────────────────── */

.ranked {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}
.ranked li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 5px 0;
}
.ranked .k {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranked .v {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.ranked .bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 2px;
  background: var(--s1);
}

.meter {
  margin-bottom: 14px;
}
.meter .row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.meter .track {
  height: 8px;
  border-radius: 4px;
  background: var(--s1-wash);
  overflow: hidden;
}
.meter .fill {
  height: 100%;
  border-radius: 4px;
  background: var(--s1);
}
.meter.warning .fill {
  background: var(--warning);
}
.meter.critical .fill {
  background: var(--critical);
}

/* ── Feeds ──────────────────────────────────────────── */

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.feed li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.feed li:first-child {
  border-top: 0;
  padding-top: 0;
}
.feed .meta {
  font-size: 12px;
  color: var(--muted);
}
.feed .title {
  display: block;
  font-weight: 500;
}

.off {
  color: var(--muted);
}
.off code {
  font-size: 12px;
  color: var(--ink-2);
}

/* ── Sources ────────────────────────────────────────── */

.sources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px 32px;
  font-size: 13px;
}
@media (min-width: 720px) {
  .sources {
    grid-template-columns: 1fr 1fr;
  }
}
.sources li {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.sources .name {
  width: 90px;
  flex: none;
  font-weight: 500;
}
.sources .state {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ── Login ──────────────────────────────────────────── */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login form {
  width: min(320px, 100%);
  display: grid;
  gap: 14px;
}
.login img {
  height: 32px;
  justify-self: start;
}
.login input {
  font: inherit;
  color: var(--ink);
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
}
.login .error {
  color: var(--ink);
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .refreshing {
    opacity: 0.55;
    transition: opacity 0.2s;
  }
}
