/* Analytics user guide. Static page shipped in dist/manual/; no scripts (the
   app's CSP only allows same-origin scripts, and this page needs none). Colours
   follow the --tk-* tokens in src/index.css. */

:root {
  --blue: #3f52ff;
  --blue-50: #f5f6ff;
  --blue-100: #d9dcff;
  --navy: #263054;
  --navy-50: #eaedfa;
  --text: #192a3e;
  --muted: #5f6b78;
  --line: #e3e5ea;
  --bg: #ffffff;
  --surface: #f9f9fa;
  --card: #ffffff;
  --good: #36a163;
  --good-bg: #e8f6ee;
  --warn: #9a6a00;
  --warn-bg: #fff6df;
  --bad: #c13a3a;
  --bad-bg: #fbeaea;
  --info: #3f52ff;
  --info-bg: #eef0ff;
  --grey-bg: #eef0f3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #8c98ff;
    --blue-50: #1b2040;
    --blue-100: #2c3466;
    --navy: #c9d0ee;
    --navy-50: #20263f;
    --text: #e6e9ef;
    --muted: #a3acb8;
    --line: #2d3240;
    --bg: #12141b;
    --surface: #181b24;
    --card: #1c2029;
    --good: #5cc98a;
    --good-bg: #183326;
    --warn: #f2c14e;
    --warn-bg: #362c14;
    --bad: #f08080;
    --bad-bg: #3a1d1f;
    --info: #8c98ff;
    --info-bg: #1f2547;
    --grey-bg: #252a35;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --blue: #8c98ff;
  --blue-50: #1b2040;
  --blue-100: #2c3466;
  --navy: #c9d0ee;
  --navy-50: #20263f;
  --text: #e6e9ef;
  --muted: #a3acb8;
  --line: #2d3240;
  --bg: #12141b;
  --surface: #181b24;
  --card: #1c2029;
  --good: #5cc98a;
  --good-bg: #183326;
  --warn: #f2c14e;
  --warn-bg: #362c14;
  --bad: #f08080;
  --bad-bg: #3a1d1f;
  --info: #8c98ff;
  --info-bg: #1f2547;
  --grey-bg: #252a35;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--blue); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---------- masthead ---------- */
.masthead {
  background: var(--navy-50);
  border-bottom: 1px solid var(--line);
  padding: 48px 0 40px;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}
.masthead h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.lede { max-width: 680px; margin: 12px 0 0; font-size: 18px; color: var(--muted); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 48px;
  padding-top: 32px;
  padding-bottom: 64px;
}

.toc { position: sticky; top: 16px; align-self: start; font-size: 14px; }
.toc-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: flex;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
.toc a::before { content: counter(toc); min-width: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toc a:hover { background: var(--blue-50); color: var(--blue); }

.content { min-width: 0; max-width: 760px; }

section { padding-bottom: 32px; margin-bottom: 40px; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }

h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
h2 .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy-50);
  color: var(--blue);
  font-size: 16px;
}
h3 { margin: 28px 0 8px; font-size: 19px; font-weight: 700; }

p, ul, ol, dl { margin: 0 0 14px; }
ul, ol { padding-left: 22px; }
li { margin-bottom: 4px; }
li > ul { margin-top: 6px; }

.ui {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-size: 0.9em;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--card);
  font-family: inherit;
  font-size: 0.85em;
}

.role-note {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- steps ---------- */
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps > li {
  position: relative;
  padding: 2px 0 10px 40px;
  counter-increment: step;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
}

/* ---------- definition lists ---------- */
.defs { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 10px 20px; }
.defs dt { font-weight: 700; }
.defs dd { margin: 0; color: var(--text); }

/* ---------- callouts ---------- */
.callout {
  margin: 20px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0;
  background: var(--info-bg);
}
.callout.tip { border-color: var(--good); background: var(--good-bg); }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { margin-bottom: 4px; font-weight: 800; }

/* ---------- chips and pills ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.chips li {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 14px;
  color: var(--muted);
}
.chips b { display: block; color: var(--text); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills span {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.grid-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.grid-chips span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 14px;
  color: var(--muted);
}
.grid-chips b { display: block; color: var(--text); }

/* ---------- cards ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.card.good { border-top: 4px solid var(--good); }
.card ul { margin: 0; padding-left: 18px; }
.card-title { margin: 0 0 8px; font-weight: 800; }

/* ---------- report groups ---------- */
.report-groups { display: grid; gap: 16px; }
.rg { padding: 4px 18px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.rg h3 { margin-top: 14px; }
.rg dl { display: grid; grid-template-columns: minmax(170px, 240px) 1fr; gap: 8px 16px; }
.rg dt { font-weight: 700; }
.rg dd { margin: 0; color: var(--muted); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.callout table td { border-color: color-mix(in srgb, var(--line) 70%, transparent); }
.qa td:first-child { width: 42%; }
.roles td:not(:first-child), .roles th:not(:first-child) { width: 22%; }
.roles .y { color: var(--good); font-weight: 700; }
.roles .n { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.g { color: var(--good); background: var(--good-bg); }
.badge.a { color: var(--warn); background: var(--warn-bg); }
.badge.b { color: var(--info); background: var(--info-bg); }
.badge.r { color: var(--bad); background: var(--bad-bg); }
.badge.s { color: var(--muted); background: var(--grey-bg); }

/* ---------- outcome swatches ---------- */
.sw { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 3px; vertical-align: -1px; }
.sw.rr { background: #1f8a4c; }
.sw.rc { background: #7cc597; }
.sw.ri { background: #6f86e8; }
.sw.nc { background: #a9b0bb; }
.sw.dt { background: #d65a5a; }

/* ---------- details ---------- */
details {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 700;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; display: inline-block; width: 20px; color: var(--blue); font-weight: 800; }
details[open] summary::before { content: "−"; }
details > :not(summary) { margin: 0 16px 14px 36px; }
details.example { background: var(--blue-50); border-color: var(--blue-100); }

/* ---------- layout diagram ---------- */
.diagram { margin: 8px 0 24px; }
.mock {
  display: grid;
  grid-template-columns: 34% 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12px;
}
.mock em { font-style: normal; }
.mock-panel { position: relative; padding: 12px; border-right: 1px solid var(--line); background: var(--card); }
.mock-h { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 15px; }
.mock-plus { color: var(--blue); font-weight: 700; }
.mock-search { margin-bottom: 8px; padding: 4px 8px; border-radius: 4px; background: var(--grey-bg); color: var(--muted); }
.mock-row { padding: 3px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mock-row.strong { font-weight: 700; }
.mock-sec { margin-top: 8px; padding: 0 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.mock-main { display: flex; flex-direction: column; min-width: 0; }
.mock-header {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
}
.mock-badge { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--good-bg); color: var(--good); font-weight: 700; }
.mock-tools { display: flex; gap: 4px; }
.mock-tools em, .mock-titlebar span em { padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }
.mock-body { position: relative; flex: 1; padding: 12px; }
.mock-titlebar { position: relative; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-bottom: 10px; }
.mock-titlebar span { display: flex; gap: 4px; }
.mock-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mock-grid i { height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.mock-grid i.wide { grid-column: 1 / -1; height: 70px; }
.pin {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 0 3px var(--bg);
}
.mock-header, .mock-titlebar { padding-right: 34px; }
.p1 { top: 8px; right: 8px; }
.p2, .p3 { top: 50%; right: 6px; transform: translateY(-50%); }
.p3 { right: 0; }
.p4 { bottom: 8px; right: 8px; }

.legend { list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.legend li { display: flex; gap: 10px; }
.legend b {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
}

/* ---------- footer ---------- */
.foot { padding-top: 8px; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 24px; }
  .toc { position: static; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .toc ol { columns: 2; column-gap: 16px; }
}

@media (max-width: 600px) {
  body { font-size: 15px; }
  .masthead { padding: 32px 0 28px; }
  h2 { font-size: 23px; }
  .defs, .rg dl { grid-template-columns: 1fr; gap: 2px; }
  .defs dd, .rg dd { margin-bottom: 10px; }
  .two-col { grid-template-columns: 1fr; }
  .toc ol { columns: 1; }
  .mock { grid-template-columns: 1fr; }
  .mock-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .qa td:first-child { width: auto; }
  .ui { white-space: normal; }
  table { font-size: 14px; }
  th, td { padding: 8px 6px; }
}

@media print {
  .toc { display: none; }
  .layout { display: block; }
  details { break-inside: avoid; }
  details > :not(summary) { display: block; }
  a { color: inherit; }
  section { break-inside: auto; }
}
