/*
 * One stylesheet, no framework. Plain and descriptive, like the product: a
 * near-white page, near-black ink, one blue for anything you can press, and
 * the chart's two series colours used for exactly one job each. SQL is set in
 * the system monospace because people will copy it. Dark mode is its own set
 * of steps, not an inversion.
 */
:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #fcfcfb;
  --panel: #efefeb;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --ink: #14161a;
  --muted: #52514e;
  --faint: #898781;
  --accent: #1c5cab;
  --accent-soft: #e3eefb;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #006300;
  --warning: #8a5a00;
  --warning-soft: #fbf0d9;
  --critical: #c22f2f;
  --critical-soft: #f9e3e1;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d; --surface: #1a1a19; --panel: #232321; --line: #2c2c2a; --axis: #383835;
    --ink: #f4f4f2; --muted: #c3c2b7; --faint: #898781;
    --accent: #6da7ec; --accent-soft: #16263b; --accent-ink: #0b0b0b;
    --series-1: #3987e5; --series-2: #d95926;
    --good: #0ca30c; --warning: #f0bf4c; --warning-soft: #34290f; --critical: #f07a7a; --critical-soft: #3a1c1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 72px; }
main.narrow { max-width: 760px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 750; margin: 0 0 14px; }
h2 { font-size: clamp(21px, 3vw, 27px); font-weight: 700; margin: 44px 0 12px; }
h3 { font-size: 18px; font-weight: 700; margin: 20px 0 6px; }
a { color: var(--accent); text-underline-offset: 3px; }
p { margin: 0 0 14px; }
code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
.lede { font-size: 19px; color: var(--muted); max-width: 46em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
[hidden] { display: none !important; }

/* ── Header and footer, on every page via BaseLayout ─────────────────────── */
.masthead {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  max-width: 1040px; margin: 0 auto; padding: 16px 20px 0;
}
.wordmark { font-weight: 800; font-size: 23px; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.wordmark span { color: var(--accent); }
.masthead nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.masthead nav.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.masthead nav.tabs a:hover { background: var(--panel); }
.masthead nav.tabs a[aria-current] { background: var(--accent-soft); color: var(--ink); }
.masthead nav.more { margin-left: auto; font-size: 15px; gap: 14px; }
.masthead nav.more a { color: var(--muted); text-decoration: none; }
.masthead nav.more a[aria-current] { color: var(--ink); font-weight: 700; }

.siteftr {
  max-width: 1040px; margin: 0 auto; padding: 24px 20px 44px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.siteftr .feedback-line { font-size: 15px; color: var(--ink); }
.siteftr .feedback-line a { font-weight: 700; }

/* ── Buttons, forms, panels ──────────────────────────────────────────────── */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 650 16px/1.2 var(--sans); padding: 12px 20px; border-radius: 10px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; text-align: center;
}
button:hover, .button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; filter: none; }
button.quiet, .button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--critical); border: 1px solid var(--critical); }
button.small, .button.small { padding: 7px 12px; font-size: 14px; }
button.big, .button.big { padding: 16px 26px; font-size: 18px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

label { display: block; font-weight: 650; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; min-height: 140px; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.error { color: var(--critical); }
.ok { color: var(--good); }
.note { background: var(--accent-soft); border-radius: 10px; padding: 12px 15px; font-size: 15px; }
.warning { background: var(--warning-soft); border-radius: 10px; padding: 12px 15px; font-size: 15px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .two, .three { grid-template-columns: 1fr; } }

pre.sql {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.5; white-space: pre; margin: 8px 0 12px;
}
.copy-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 12px; }

/* ── The front page ──────────────────────────────────────────────────────── */
.hero { margin: 18px 0 34px; }
.hero h1 { max-width: 17em; }
.hero .controls { margin-top: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin-top: 0; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 16px 0; counter-reset: step; }
.steps > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.steps > div::before { counter-increment: step; content: counter(step); font-weight: 800; font-size: 26px; color: var(--accent); display: block; line-height: 1; margin-bottom: 6px; }
.steps strong { display: block; margin-bottom: 4px; }
.callout { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; margin: 18px 0; }
ul.plain { padding-left: 20px; }
ul.plain li { margin-bottom: 6px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.name { word-break: break-word; }
.table-wrap { overflow-x: auto; }
.share { display: block; height: 4px; border-radius: 2px; background: var(--series-1); margin-top: 4px; min-width: 2px; }

/* ── The app ─────────────────────────────────────────────────────────────── */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list .name { font-weight: 750; font-size: 18px; text-decoration: none; color: var(--ink); }
.status { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; font-weight: 650; padding: 2px 10px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.status.good { color: var(--good); }
.status.waiting { color: var(--warning); }
.status.bad { color: var(--critical); }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.choice label { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); cursor: pointer; font-weight: 600; }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: auto; margin-right: 8px; }
.choice .hint { display: block; font-weight: 400; color: var(--muted); font-size: 14px; margin-top: 2px; }

.head-row { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: baseline; justify-content: space-between; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.tile.lead { grid-column: span 2; }
.tile.lead .value { font-size: 48px; line-height: 1.1; white-space: nowrap; }
@media (max-width: 560px) { .tile.lead { grid-column: auto; } .tile.lead .value { font-size: 36px; } }
.range { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.range a { padding: 5px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.range a[aria-current] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }

.query { border-bottom: 1px solid var(--line); padding: 14px 0; }
.query .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); }
.query .cost { font-weight: 750; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.query details pre { max-height: 360px; overflow: auto; }
.query ul.hints { margin: 8px 0 0; padding-left: 20px; }
.query ul.hints li { margin-bottom: 4px; }
.alert-row { border-left: 3px solid var(--critical); padding: 6px 0 6px 14px; margin: 10px 0; }
.spike-word { color: var(--critical); font-weight: 700; }

/* ── The chart ───────────────────────────────────────────────────────────── */
.chart-figure { margin: 10px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 8px; }
.chart-wrap { position: relative; }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { stroke: var(--axis); stroke-width: 1; }
svg.chart .tick { fill: var(--faint); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
svg.chart .series-1 { fill: var(--series-1); }
svg.chart .series-2 { fill: var(--series-2); }
svg.chart .spike-mark { fill: var(--critical); font: 11px var(--sans); }
svg.chart .hit { fill: transparent; cursor: pointer; }
svg.chart .hit:hover { fill: var(--ink); fill-opacity: 0.04; }
.chart-tip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; line-height: 1.45; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); white-space: nowrap;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.series-1 { background: var(--series-1); }
.swatch.series-2 { background: var(--series-2); }
.table-view { margin-top: 8px; font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--muted); }

/* ── The printable report ───────────────────────────────────────────────── */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.report header { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 14px; }
.report h1 { font-size: 26px; margin: 0; }
.report h2 { font-size: 18px; margin: 22px 0 6px; }
.report .footnote { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 18px; }

@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --panel: #f3f3f3; --line: #cfcfcf; --ink: #000; --muted: #444;
    --series-1: #2a78d6; --series-2: #eb6834; }
  @page { size: A4; margin: 14mm; }
  body { font-size: 10.5pt; }
  .masthead, .siteftr, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; }
  table.data { font-size: 9.5pt; }
  table.data th, table.data td { padding: 3px 6px; }
  .chart-figure { border: 0; padding: 0; break-inside: avoid; }
  .table-view { display: none; }
  a { color: inherit; text-decoration: none; }
}
