/* One stylesheet, no framework — the dashboard is a list and a detail pane. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #dfe3e8;
  --text: #16191d;
  --dim: #626b76;
  --accent: #2563eb;

  --up: #16a34a;
  --warn: #d97706;
  --down: #dc2626;
  --unknown: #94a3b8;

  --kind-html: #2a78d6;
  --kind-css: #eb6834;
  --kind-js: #1baf7a;
  --kind-images: #eda100;
  --kind-fonts: #e87ba4;
  --kind-media: #008300;
  --kind-other: #8b929c;

  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1b1e24;
    --panel-2: #23272e;
    --line: #2e333b;
    --text: #e8eaed;
    --dim: #9aa3ae;
    --accent: #60a5fa;

    --up: #22c55e;
    --warn: #f59e0b;
    --down: #ef4444;
    --unknown: #64748b;

    --kind-html: #3987e5;
    --kind-css: #d95926;
    --kind-js: #199e70;
    --kind-images: #c98500;
    --kind-fonts: #d55181;
    --kind-media: #008300;
    --kind-other: #6b727c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.loading { padding: 3rem; text-align: center; color: var(--dim); }

/* ── shell ─────────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

header h1 { font-size: 1rem; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
header .spacer { flex: 1; }

.rollup { display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; color: var(--dim); }
.rollup b { color: var(--text); font-variant-numeric: tabular-nums; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* ── buttons and fields ────────────────────────────────────────────────── */

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger:hover { border-color: var(--down); color: var(--down); }
button:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  width: 100%;
}
label { display: block; font-size: 0.8rem; color: var(--dim); margin-bottom: 0.2rem; }
.field { margin-bottom: 0.75rem; }
.field > textarea + button { margin-top: 0.4rem; }
.note { color: var(--dim); font-size: 0.85rem; margin: 0.3rem 0 0; }
.note:empty { display: none; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1 1 10rem; }
.check { display: flex; align-items: center; gap: 0.5rem; }
.check input { width: auto; }
.check label { margin: 0; color: var(--text); font-size: 0.9rem; }

/* ── site list ─────────────────────────────────────────────────────────── */

.sites { display: flex; flex-direction: column; gap: 0.5rem; }

.site {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.site:hover { border-color: var(--accent); }
.site.open { border-color: var(--accent); }
.site.disabled { opacity: 0.55; }

.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--unknown); flex: none; }
.dot.up { background: var(--up); }
.dot.warn { background: var(--warn); }
.dot.down { background: var(--down); }
.dot.paused { background: transparent; box-shadow: inset 0 0 0 2px var(--unknown); }
.dot.checking { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.site .name { font-weight: 600; }
.site .url { color: var(--dim); font-size: 0.8rem; word-break: break-all; }
.site .facts { grid-column: 2; color: var(--dim); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.site .meta { text-align: right; color: var(--dim); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.site .pause { margin-top: 0.25rem; padding: 0.1rem 0.5rem; font-size: 0.75rem; }

.problems { grid-column: 2 / -1; display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.25rem; }
.problem { font-size: 0.85rem; display: flex; gap: 0.45rem; align-items: baseline; }
.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  flex: none;
}
.tag.warn { color: var(--warn); }
.tag.down { color: var(--down); }

/* ── sparkline ─────────────────────────────────────────────────────────── */

.spark { display: flex; gap: 1px; align-items: flex-end; height: 28px; }
.spark i { display: block; width: 3px; border-radius: 1px; background: var(--unknown); }
.spark i.up { background: var(--up); }
.spark i.warn { background: var(--warn); }
.spark i.down { background: var(--down); }

/* ── detail ────────────────────────────────────────────────────────────── */

.detail {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1rem;
  margin-top: -0.5rem;
}
.detail h3 { margin: 1rem 0 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); }
.detail h3:first-child { margin-top: 0; }
.detail .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; color: var(--dim); font-weight: 500; padding: 0.25rem 0.5rem 0.25rem 0; }
td { padding: 0.25rem 0.5rem 0.25rem 0; border-top: 1px solid var(--line); vertical-align: top; word-break: break-word; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
a { color: var(--accent); }

.empty { color: var(--dim); font-size: 0.85rem; padding: 0.4rem 0; }

/* ── login ─────────────────────────────────────────────────────────────── */

.login { max-width: 22rem; margin: 15vh auto; padding: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.login h1 { font-size: 1.1rem; margin: 0 0 1rem; }
.error { color: var(--down); font-size: 0.85rem; min-height: 1.2em; }

/* ── dialog ────────────────────────────────────────────────────────────── */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 1.25rem;
  width: min(34rem, calc(100vw - 2rem));
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h2 { margin: 0 0 1rem; font-size: 1rem; }
dialog .actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
dialog.wide { width: min(52rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; }
dialog.wide h2 { display: flex; gap: 0.5rem; align-items: center; }

/* ── tabs ──────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.tabs button { border-color: transparent; background: none; color: var(--dim); }
.tabs button.on { color: var(--text); border-color: var(--line); background: var(--panel-2); }

.hint { color: var(--dim); font-size: 0.8rem; margin: -0.25rem 0 0.75rem; }

/* ── the queue ─────────────────────────────────────────────────────────── */

.queue { display: flex; flex-direction: column; gap: 1rem; }

.timeline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.lane { display: grid; grid-template-columns: 9rem 1fr; gap: 0.75rem; align-items: center; height: 26px; }
.lane-name { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-track { position: relative; height: 100%; border-top: 1px solid var(--line); }
.lane:last-of-type .lane-track { border-bottom: 1px solid var(--line); }
/* The now line runs down every lane, through the axis. */
.lane-track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px dashed var(--dim); opacity: 0.6; }
.lane.axis { height: 1.4rem; }
.lane.axis .lane-track { border-top: none; }
.lane.axis .lane-track::after { display: none; }
.tick { position: absolute; transform: translateX(-50%); font-size: 0.72rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.tick.zero { color: var(--text); font-weight: 600; }

.mark {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--unknown);
  /* A ring of the surface, so marks a second apart stay separate. */
  box-shadow: 0 0 0 2px var(--panel);
  z-index: 1;
}
.mark.home { border-radius: 2px; width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.mark.up { background: var(--up); }
.mark.warn { background: var(--warn); }
.mark.down { background: var(--down); }
.mark.planned { background: var(--panel); border: 2px solid var(--dim); }
.mark.now { background: var(--accent); animation: pulse 1s ease-in-out infinite; z-index: 2; }
.mark:hover { transform: scale(1.5); z-index: 3; }

.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 0.6rem; font-size: 0.78rem; color: var(--dim); }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend .mark { position: static; margin: 0; box-shadow: none; animation: none; }

.queue-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.queue-cols section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; min-width: 0; }
.queue-cols h3 { margin: 0 0 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); }
.qrow {
  display: grid;
  grid-template-columns: 5.5rem 6rem auto minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.82rem;
  padding: 0.2rem 0;
  border-top: 1px solid var(--line);
}
.qrow .when { color: var(--dim); }
.qrow .who, .qrow .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow .dot { width: 8px; height: 8px; align-self: center; }

.kind { font-size: 0.68rem; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 0.3rem; text-transform: uppercase; letter-spacing: 0.03em; }
.kind.home { color: var(--text); border-color: var(--dim); }
.result.warn { color: var(--warn); }
.result.down { color: var(--down); }

.queue-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.queue-mini h4 { margin: 0 0 0.2rem; font-size: 0.78rem; color: var(--dim); font-weight: 500; }

.offline { background: var(--warn); color: #000; text-align: center; font-size: 0.8rem; padding: 0.2rem; }

@media (max-width: 900px) {
  .queue-cols { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  header { flex-wrap: wrap; }
  .lane { grid-template-columns: 5rem 1fr; }
  .qrow { grid-template-columns: 4.5rem minmax(0, 1fr) auto; }
  .qrow .what { grid-column: 1 / -1; }
  .queue-mini { grid-template-columns: 1fr; }
  .site { grid-template-columns: auto 1fr; }
  .site .meta { grid-column: 2; text-align: left; }
}

/* ── browser check ─────────────────────────────────────────────────────── */

.timings { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: 0.5rem; margin: 0.5rem 0; }
.timings div { display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem 0.6rem; }
.timings b { font-size: 1.05rem; }
.timings span { color: var(--dim); font-size: 0.75rem; }
.cov { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; font-size: 0.82rem; margin: 0.3rem 0; }
.cov .bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.cov .bar i { display: block; height: 100%; background: var(--up); }
.cov .num { color: var(--dim); }
/* Transferred bytes by kind. The colours are a validated categorical set in
   fixed order (the ring wraps, so the last sits beside the first); "Other" is
   grey on purpose. A kind keeps its colour whichever others are present. */
.transfer { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; margin: 0.75rem 0; }
.transfer svg { width: 7.5rem; height: 7.5rem; flex: none; overflow: visible; }
.transfer path { stroke: var(--panel); stroke-width: 1; stroke-linejoin: round; transition: opacity 0.12s; }
.transfer.picking path:not(.picked), .transfer.picking tr:not(.picked) { opacity: 0.35; }
.transfer .legend { border-collapse: collapse; font-size: 0.82rem; }
.transfer .legend td { padding: 0.12rem 0.4rem; }
.transfer .legend td.num { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.transfer .swatch { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; margin-right: 0.45rem; vertical-align: -0.05rem; }
.transfer [data-kind="html"] { --kind: var(--kind-html); }
.transfer [data-kind="css"] { --kind: var(--kind-css); }
.transfer [data-kind="js"] { --kind: var(--kind-js); }
.transfer [data-kind="images"] { --kind: var(--kind-images); }
.transfer [data-kind="fonts"] { --kind: var(--kind-fonts); }
.transfer [data-kind="media"] { --kind: var(--kind-media); }
.transfer [data-kind="other"] { --kind: var(--kind-other); }
.transfer path { fill: var(--kind); }
.transfer .swatch { background: var(--kind); }
.findings { margin: 0.2rem 0 0.6rem; padding-left: 1.2rem; font-size: 0.82rem; word-break: break-word; }
/* A whole page is thousands of pixels tall: it scrolls inside its own box
   rather than making the detail pane as long as the site. */
.shot { display: block; margin: 0.5rem 0; max-width: 640px; max-height: 32rem; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.shot img { display: block; width: 100%; height: auto; }
/* A broken link's snapshot in the list: small enough to scan a column of,
   opened full size on its own. Dashed when the link itself was hidden. */
.link-shot { display: block; width: 10rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.link-shot.hidden { border-style: dashed; }
.link-shot img { display: block; width: 100%; height: auto; max-height: 6rem; object-fit: cover; object-position: center; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
h3 .more, h4 .more { float: right; font-weight: 400; color: var(--accent); text-transform: none; letter-spacing: 0; }
h3 .more + .more { margin-right: 1em; }

/* ── domain check ──────────────────────────────────────────────────────── */

.email-form > button { flex: none; align-self: flex-end; margin-bottom: 0.75rem; }
.email h3 { display: flex; align-items: center; gap: 0.5rem; margin: 1.1rem 0 0.4rem; font-size: 0.9rem; }
.email h3 small { color: var(--dim); font-weight: 400; }
.email h4 { margin: 1.4rem 0 0; padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); }
.email h4:first-child { margin-top: 0.25rem; }
.email .hint { margin-top: 0; }
/* A DKIM key is one unbroken word of 400 characters. */
/* robots.txt and the sitemaps, in a site's detail pane: one block per file. */
.crawler-file h4 { display: flex; align-items: center; gap: 0.5rem; margin: 0.7rem 0 0.15rem; font-size: 0.85rem; font-weight: 500; word-break: break-all; }
.crawler-file h4 small { color: var(--dim); font-weight: 400; white-space: nowrap; }
.crawler-file .fact { color: var(--dim); font-size: 0.8rem; padding-left: 1.25rem; }
.crawler-file .problems { padding-left: 1.25rem; }
.crawler-file details { padding-left: 1.25rem; font-size: 0.8rem; }
.crawler-file summary { cursor: pointer; color: var(--dim); }

.record { margin: 0.3rem 0; padding: 0.4rem 0.55rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font: 0.78rem/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; }
