/* Technical GTM Command Center — shared styles.
   Neutral palette, system font, light + dark mode. Colors are tokens so the
   charts (via common.js) and the page read from the same source. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;      /* series 1: in capacity / primary actions */
  --highlight: #eb6834;   /* series 2: Northwind */
  --out: #a3a29c;         /* de-emphasized marks */
  --good: #0ca30c;
  --warning: #c98500;
  --critical: #d03b3b;
  --banner-bg: #fff4d6;
  --banner-text: #5c4300;
  --radius: 10px;
  /* Lifecycle step types: grey = data, purple = decision, green = action & revenue */
  --type-data: #898781;
  --type-decision: #6250d6;
  --type-action: #008300;
  --series-2: #1baf7a;     /* second chart series (executive stacked bar) */
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --highlight: #d95926;
    --out: #5d5c57;
    --warning: #fab219;
    --banner-bg: #3a2e0a;
    --banner-text: #f5dc9a;
    --type-decision: #9085e9;
    --type-action: #0ca30c;
  --series-2: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9a9890;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --highlight: #d95926;
  --out: #5d5c57;
  --warning: #fab219;
  --banner-bg: #3a2e0a;
  --banner-text: #f5dc9a;
  --type-decision: #9085e9;
  --type-action: #0ca30c;
  --series-2: #199e70;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.55 var(--font);
}
a { color: var(--accent); }

/* Disclaimer banner — required on every page. */
.banner {
  background: var(--banner-bg);
  color: var(--banner-text);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
}

/* Header + nav */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
}
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 36px 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.lede { color: var(--text-2); margin: 0 0 24px; max-width: 760px; }
.responsibility {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
/* Lifecycle metric cards: 4 across on desktop, 2×2 on phones */
.grid-metrics { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }

.kpi .label { font-size: 13px; color: var(--text-2); }
.kpi .value { font-size: 28px; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }

/* Tables: wrapper scrolls sideways on phones so the page never does. */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.is-selected td { background: color-mix(in srgb, var(--highlight) 10%, transparent); }
tfoot td { font-weight: 700; background: var(--surface-2); }

/* Chips for flags, quadrants, status */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1.4;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
  margin: 1px 2px 1px 0;
}
.status { font-weight: 600; color: var(--text); }
.status .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-green .dot { background: var(--good); }
.status-yellow .dot { background: var(--warning); border-radius: 2px; transform: rotate(45deg); width: 8px; height: 8px; }
.status-red .dot { background: var(--critical); border-radius: 1px; }

.reasons { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--text-2); min-width: 200px; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 0 0 12px; }
.controls label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
select, input[type="search"] {
  font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--text);
}
input[type="range"] { width: 160px; max-width: 100%; accent-color: var(--accent); }
.btn {
  font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--axis); background: var(--surface); color: var(--text);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }

.chart { width: 100%; height: 460px; }

/* Guided tour flowchart */
.flow { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flow li { display: flex; align-items: center; gap: 8px; }
.flow li:not(:last-child)::after { content: "→"; color: var(--muted); }
.flow button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--text-2);
}
.flow button:hover { color: var(--text); border-color: var(--text-2); }
.flow button[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.flow .n { opacity: .7; margin-right: 4px; }
.step-panel h2 { margin-top: 0; }
.step-panel dl { margin: 0; display: grid; gap: 14px; }
.step-panel dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.step-panel dd { margin: 2px 0 0; }
.nw-box { border-left: 3px solid var(--highlight); padding: 2px 0 2px 12px; }
.step-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 12px; }

ul.tight, ol.tight { margin: 0; padding-left: 20px; }
ul.tight li, ol.tight li { margin: 3px 0; }
.metric { border-left: 3px solid var(--good); padding-left: 12px; }

/* Selected account callout + back link (cross-page state) */
.back-link { margin: -8px 0 12px; }
.callout { border-left: 3px solid var(--highlight); }
.callout h3 { margin-bottom: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px 16px; margin: 12px 0 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Lifecycle: account picker */
.picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.picker .featured {
  font: inherit; text-align: left; cursor: pointer; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--text); min-width: 0;
}
.picker .featured span { display: block; font-size: 12px; color: var(--muted); }
.picker .featured:hover { border-color: var(--text-2); }
.picker .featured[aria-pressed="true"] { border: 2px solid var(--highlight); padding: 7px 11px; }
.search-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search-row input { width: 260px; max-width: 100%; }

/* Lifecycle: step blocks */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 0 0 10px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.steps button {
  width: 100%; height: 100%; font: inherit; text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: 8px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-top: 4px solid var(--c);
}
.steps button:hover { background: var(--surface-2); }
.steps button[aria-current="step"] { background: color-mix(in srgb, var(--c) 14%, var(--surface)); outline: 2px solid var(--c); outline-offset: -1px; }
.steps .num { font-size: 12px; color: var(--muted); }
.steps .nm { display: block; font-weight: 600; font-size: 14px; }
.steps .ty { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--c); }
.type-data { --c: var(--type-data); }
.type-decision { --c: var(--type-decision); }
.type-action { --c: var(--type-action); }
.sentence { font-size: 16px; line-height: 1.6; margin: 0; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; }
.panel-actions .group { display: flex; gap: 8px; align-items: center; }
@media (max-width: 700px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* JD keyword pill (Lifecycle panel, Methodology mapping table) */
.kw {
  display: inline-block; font-size: 12px; line-height: 1.5; padding: 0 7px; border-radius: 4px;
  background: color-mix(in srgb, var(--type-decision) 12%, transparent); color: var(--text); margin: 1px 2px;
}

/* Glossary tooltips */
.term { white-space: nowrap; }
/* Long names (e.g. "Deep engagement (SA + FDE)") must wrap inside cards rather than overflow. */
.kpi .value .term, .kpi .label .term, .facts dd .term, .facts dt .term, td .term { white-space: normal; }
.facts dt { overflow-wrap: anywhere; padding-right: 6px; }
.chip .term { white-space: nowrap; }   /* chips wrap between each other, never inside */
.kpi .value { overflow-wrap: anywhere; }
.kpi .sub .why { white-space: normal; display: inline-block; margin-left: 0; }
.info {
  font: inherit; font-size: 11px; line-height: 1; cursor: help; background: none; border: 0;
  color: var(--muted); padding: 2px 1px 2px 3px; margin-left: 1px; vertical-align: 1px; border-radius: 4px;
}
.info:hover, .info:focus-visible { color: var(--accent); }
.info:focus-visible { outline: 2px solid var(--accent); }
#tip {
  position: fixed; z-index: 50; max-width: 280px; padding: 8px 10px; border-radius: 8px;
  background: var(--text); color: var(--page); font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 4px 16px rgba(0,0,0,.18); pointer-events: none; white-space: normal; text-transform: none; letter-spacing: 0; font-weight: 400;
}

/* "How to read this" captions and "Why?" links */
.howto { font-size: 12.5px; color: var(--text-2); margin: 8px 0 0; }
.howto strong { color: var(--text); font-weight: 600; }
.why { font-size: 12px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.breakdown { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.facts .breakdown, .kpi .breakdown { white-space: normal; }

/* Decision log: highlight the entry a "Why?" link points to */
article:target { outline: 2px solid var(--accent); outline-offset: 2px; }

.note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 6px 10px; margin: 8px 0 0; }

/* Small "?" questions next to charts and tables */
.faq-mini { margin: 10px 0 0; display: grid; gap: 4px; }
.faq-mini details { font-size: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.faq-mini summary { cursor: pointer; padding: 6px 10px; color: var(--text-2); list-style: none; display: flex; gap: 8px; align-items: baseline; }
.faq-mini summary::-webkit-details-marker { display: none; }
.faq-mini summary:hover { color: var(--text); }
.faq-mini details[open] summary { color: var(--text); font-weight: 600; }
.faq-mini p { margin: 0; padding: 0 10px 8px 34px; color: var(--text-2); line-height: 1.5; }
.q-mark {
  flex: none; width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.why-account { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--highlight) 9%, var(--surface)); font-size: 14px; line-height: 1.55; }

/* Questions page */
.faq-group h2 { margin-top: 28px; }
.faq-full details { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin-bottom: 6px; }
.faq-full summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
.faq-full details > div { padding: 0 14px 12px; color: var(--text-2); }
.faq-full details:target { outline: 2px solid var(--accent); }

.credit-bar { background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.credit-bar .inner { max-width: 1120px; margin: 0 auto; padding: 6px 16px; }
.credit-bar strong { color: var(--text); }

/* "How this works" long-form page */
.doc-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; align-items: start; }
.toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; font-size: 13px; }
.toc summary { font-weight: 700; cursor: pointer; margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 4px 0; }
.toc a { color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }
.doc { max-width: 780px; min-width: 0; }
.doc section { padding-top: 8px; margin-bottom: 36px; scroll-margin-top: 12px; }
.doc h2 { margin-top: 12px; font-size: 22px; }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc p, .doc li { line-height: 1.65; }
.doc .table-wrap { margin: 10px 0 14px; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; background: var(--surface-2); border-radius: 6px; padding: 8px 12px; overflow-x: auto; }
.back-top { display: inline-block; font-size: 12px; margin-top: 4px; }
.flowsteps { padding-left: 22px; }
.flowsteps li { margin: 6px 0; padding-left: 8px; border-left: 3px solid var(--c); }
@media (max-width: 900px) {
  .doc-layout { grid-template-columns: 1fr; gap: 12px; }
  .toc { position: static; max-height: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
}

.plan-list { margin: 0; padding-left: 16px; }
.plan-list li { margin: 2px 0; }

footer { max-width: 1120px; margin: 0 auto; padding: 0 16px 32px; font-size: 12px; color: var(--muted); }

@media (max-width: 600px) {
  .why { white-space: normal; }
  h1 { font-size: 22px; }
  .chart { height: 380px; }
  .kpi .value { font-size: 24px; }
}
