/* "Studio Warm" look — a warm paper/cream surface, a near-black top bar, an
   amber/gold brand accent, serif headings (DM Serif Display, matching
   datawithfanny.com) paired with a plain sans body (Inter) and monospace
   for technical identifiers (IBM Plex Mono). Fraunces, the original
   heading font from the first design round, is kept only for the big
   score numbers (.score-value) — those read fine in a more decorative
   serif; running text in it didn't. Palette and font choices are original;
   nothing here reproduces another product's logo, layout, or components. */
:root {
  --ink: #201a14;
  --bg: #f7f1e6;
  --paper: #fffdf9;
  --muted: #8c7f68;
  --border: #ecdfc7;
  --topbar: #1c1510;
  --accent: #b8862c;       /* amber/gold — primary brand accent */
  --accent-dark: #8f6720;
  --critical: #b23b3b;
  --warning: #c67a1f;
  --cleanup: #a79c86;
  --manual: #3d6b8a;       /* blue — "needs a human look", per Fanny */

  /* Identity colors for the Account/Container/Type/Workspace summary
     cards, so the four are distinguishable at a glance (per Fanny) —
     reuses the accent + manual colors above, plus two new warm/earthy
     tones (clay, olive) that stay in the same family. */
  --meta-account: var(--accent);
  --meta-container: #a8572e;
  --meta-type: var(--manual);
  --meta-workspace: #6f7a4a;
}

* { box-sizing: border-box; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
}

/* Headings use DM Serif Display, not Fraunces — per Fanny, Fraunces' more
   decorative letterforms "didn't fit" and she wanted something "regular,"
   inspired by datawithfanny.com's own fonts (DM Serif Display + DM Sans).
   Fraunces stays in use just for the big score numbers below (.score-value)
   — those are plain digits, unaffected by this. DM Serif Display ships only
   at weight 400 (no 600), hence the different font-weight here. */
h1, h2 { font-family: "DM Serif Display", serif; font-weight: 400; letter-spacing: -0.01em; color: var(--ink); }

.topbar {
  padding: 1rem 1.5rem;
  background: var(--topbar);
  border-bottom: 1px solid #000;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.topbar-link:hover { color: #fff; }

.brand {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  color: #fff;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-right: 0.55rem;
  border-radius: 6px;
  background: var(--accent);
  color: #0c1210;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.85rem;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }

p.error { color: var(--critical); }

.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

.button:hover { background: var(--accent-dark); }

.button.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
}

.button.secondary:hover { border-color: var(--accent); color: var(--accent-dark); }

.nav-actions {
  display: flex;
  gap: 0.85rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

label.field {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.1rem 0;
}

.field-label {
  flex: 0 0 110px;
  font-weight: 600;
  color: var(--ink);
}

select {
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.6rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

button#run-audit {
  width: 100%;
  padding: 0.55rem 0.6rem;
  font-size: 1rem;
  font-family: inherit;
  border-radius: 6px;
}

button#run-audit {
  margin-top: 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  max-width: 200px;
  font-weight: 600;
  font-family: inherit;
}

button#run-audit:hover { background: var(--accent-dark); }

button#run-audit:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.overall-score { font-size: 1.1rem; }

/* table-layout: fixed is load-bearing here, not cosmetic: with the default
   auto layout, a single unbreakable run anywhere in a row (a long cvt_...
   id, a long confirm-button label like "Treat 'Tiktok BE&NL' as a platform
   name — fixes all 8") can force that whole column — and with it the
   table, since a table's own width isn't capped by its parent's max-width —
   wider than the page, pushing the Severity column off-screen and putting
   a horizontal scrollbar on the whole report. Fixed layout + the
   overflow-wrap rules below force every cell to wrap within its own
   percentage share instead, however long its content gets. Per Fanny,
   after the findings-grouping change made button labels longer: "still an
   issue with the tags tab" (screenshot showed exactly this — Severity
   column scrolled out of view). */
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 0.75rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: top;
}

/* Column widths, scoped per table by class rather than a bare
   `table th:nth-child`: this app's report page has two different tables
   (PII scan, tracking-spec draft) with different column counts, and an
   unscoped nth-child rule silently applied the wrong percentages to
   whichever table happened to have a matching column count — exactly what
   made "Seen in events" cramped to 11% while "Total occurrences" sat at an
   unused 41%, per Fanny's screenshot. */

/* PII scan table: Severity / Field name / Source / Matched term(s) /
   Total occurrences / Seen in events. "Seen in events" gets by far the
   most room since it's a comma list of every event a field showed up in;
   "Total occurrences" is just a short number, so its header is allowed to
   wrap onto two lines in exchange for giving that space to the events list. */
.pii-table th:nth-child(1), .pii-table td:nth-child(1) { width: 12%; }
.pii-table th:nth-child(2), .pii-table td:nth-child(2) { width: 13%; }
.pii-table th:nth-child(3), .pii-table td:nth-child(3) { width: 18%; }
.pii-table th:nth-child(4), .pii-table td:nth-child(4) { width: 11%; }
.pii-table th:nth-child(5), .pii-table td:nth-child(5) { width: 12%; }
.pii-table th:nth-child(6), .pii-table td:nth-child(6) { width: 34%; }

/* Safety net for this table specifically: with six fairly tight columns,
   a plain-text value longer than expected (an unusually long matched term,
   a "SEVERITY"-style header word with no space to break at) would
   otherwise visually bleed into the next column instead of wrapping,
   exactly what happened before these widths were tuned. `code` cells
   already had this; this extends it to the table's plain-text cells too. */
.pii-table th, .pii-table td { overflow-wrap: anywhere; }

/* Tracking-spec table: Event / Parameters observed. Originally sized
   assuming event names are short — wrong per Fanny's screenshot: GA4 event
   names from dynamic-remarketing-style naming (e.g.
   "10€_already_reached_when_starting_group") run 30-40+ characters with no
   spaces to wrap at, so without room AND overflow-wrap they visually
   bled into the parameters column next to them (the "overlapping wording"
   she saw). Widened, and given the same overflow-wrap safety net as the
   PII table. */
.spec-table th:nth-child(1), .spec-table td:nth-child(1) { width: 32%; }
.spec-table th:nth-child(2), .spec-table td:nth-child(2) { width: 68%; }
.spec-table th, .spec-table td { overflow-wrap: anywhere; }

th {
  color: #4a4030;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f1e9d8;
}

code {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f1e9d8;
  color: var(--ink);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
  /* A tag/variable name or a cvt_... template id has no spaces to wrap at,
     so it's the one place in the findings table a genuinely unbreakable
     run can still force the fixed-width columns wider than the page —
     scoped to <code> only (not every table cell) so short fixed-vocabulary
     text like the Severity badge or a rule id isn't forced into an ugly
     mid-word break just because it sits in the same row. */
  overflow-wrap: anywhere;
}

code.suggestion {
  background: #f3e6c6;
  color: var(--accent-dark);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  /* A fixed vocabulary of short words (critical/warning/cleanup/manual) —
     never needs to wrap, and a mid-word break here (e.g. "CRITI"/"CAL")
     reads as broken rather than compact. The Severity column is sized to
     fit "CRITICAL" on one line. */
  white-space: nowrap;
}

.badge.critical { background: #f6dbd6; color: var(--critical); }
.badge.warning { background: #f5e2c4; color: #8a5415; }
.badge.cleanup { background: #ede6d8; color: #6b6354; }
.badge.manual { background: #dcebf4; color: var(--manual); }

/* A faint left-edge tint on each row so severity is scannable without
   reading every badge — subtle on purpose, the badge stays the clear signal. */
tr.critical { box-shadow: inset 3px 0 0 var(--critical); }
tr.warning { box-shadow: inset 3px 0 0 var(--warning); }
tr.cleanup { box-shadow: inset 3px 0 0 var(--cleanup); }
tr.manual { box-shadow: inset 3px 0 0 var(--manual); }

/* Export row — per Fanny: "can we also add a functionnality for exporting
   the result?" — an Excel workbook (everything, one tab per section) plus
   a plain CSV per section, sitting right above the tabs so it's visible no
   matter which tab is open, same reasoning as the account/container meta
   cards above it. */
.export-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0 0;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.export-bar .button {
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
}

.export-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.export-csv-group {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.export-csv-group a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

.export-csv-group a:hover { text-decoration: underline; }

/* Report tabs */

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 1.5rem 0 0;
  flex-wrap: wrap;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 0.9rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.tab-count {
  display: inline-block;
  background: #f3e6c6;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  margin-left: 0.3rem;
}

.tab-panel { padding-top: 1.5rem; }

/* Summary tab */

.summary-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meta-item {
  background: var(--paper);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

/* Color-code the four summary cards (Account/Container/Type/Workspace) so
   they're distinguishable at a glance, per Fanny — relies on the fixed
   order they're rendered in in report.html. */
.meta-item:nth-child(1) {
  border-left-color: var(--meta-account);
  background: color-mix(in srgb, var(--meta-account) 6%, var(--paper));
}
.meta-item:nth-child(1) .meta-label { color: var(--meta-account); }

.meta-item:nth-child(2) {
  border-left-color: var(--meta-container);
  background: color-mix(in srgb, var(--meta-container) 6%, var(--paper));
}
.meta-item:nth-child(2) .meta-label { color: var(--meta-container); }

.meta-item:nth-child(3) {
  border-left-color: var(--meta-type);
  background: color-mix(in srgb, var(--meta-type) 6%, var(--paper));
}
.meta-item:nth-child(3) .meta-label { color: var(--meta-type); }

.meta-item:nth-child(4) {
  border-left-color: var(--meta-workspace);
  background: color-mix(in srgb, var(--meta-workspace) 6%, var(--paper));
}
.meta-item:nth-child(4) .meta-label { color: var(--meta-workspace); }

.meta-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.meta-value {
  font-weight: 600;
  font-size: 1rem;
  word-break: break-word;
  color: var(--ink);
}

/* The GTM-XXXXXXX container id, shown alongside the container's name — per
   Fanny: "I would like also to add the container ID next to the container
   name." A separate line, de-emphasized and monospace, since it's an
   identifier to copy/reference, not part of the readable name itself. */
.meta-sub {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* Project/dataset identity now reuses .summary-meta/.meta-item (below) —
   the same component the GTM Naming Auditor uses for its Account/
   Container/Type/Workspace chips above its tabs — instead of a one-off
   .report-identity component, per Fanny: "let's try to be coherent here
   and have the same way to organize things" between the two tools. */

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.score-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1rem;
  text-align: center;
}

.score-card--overall {
  background: var(--topbar);
  border-color: var(--topbar);
}

.score-card--overall .score-value,
.score-card--overall .score-label {
  color: #fff;
}

.score-value {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
}

.score-label {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.summary-hint {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.action-points {
  margin-top: 1.5rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 1.1rem 1.3rem;
}

.action-points h2 { margin: 0 0 0.6rem; font-size: 1rem; }

.action-points ul {
  margin: 0;
  padding-left: 1.2rem;
}

.action-points li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.action-points li:last-child { margin-bottom: 0; }

/* Findings table: severity filter + sortable columns */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.filter-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 0.2rem;
}

.filter-btn {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.filter-btn:hover { border-color: var(--accent); color: var(--ink); }

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover { color: var(--ink); }

th.sortable::after {
  content: "⇅";
  margin-left: 0.3rem;
  font-size: 0.75em;
  color: var(--border);
}

th.sortable.sort-asc::after { content: "↑"; color: var(--accent-dark); }
th.sortable.sort-desc::after { content: "↓"; color: var(--accent-dark); }

.clean-heading { margin-top: 1.5rem; }

/* "Nothing flagged" — still show the full element list for review, one per
   row rather than a multi-column grid (easier to scan a long list). */
ul.clean-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  max-width: 560px;
}

ul.clean-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.clean-type {
  flex: 0 0 auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: #f3e6c6;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* A grouped finding row — several entities flagged for the exact same
   judgment call (same rule + confirm_value), collapsed into one row with
   an expandable member list instead of one row per entity. Per Fanny: "the
   tags one is getting quite large, can we make it fit within one page
   normally" — see scoring.group_findings_for_display. */
.group-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-dark);
  list-style: none;
}

.group-details summary::-webkit-details-marker { display: none; }

.group-details summary::before {
  content: "▸ ";
  font-size: 0.8em;
}

.group-details[open] summary::before { content: "▾ "; }

.group-members {
  margin: 0.4rem 0 0;
  padding-left: 0.1rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.group-members li { font-size: 0.85rem; }

.group-note {
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

/* "Treat as a platform name" inline action on an ambiguous PLATFORM-segment
   casing finding — see report.html's accept-platform-btn. */
.ambiguous-action {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.accept-platform-btn {
  background: #fff;
  border: 1px solid var(--manual);
  color: var(--manual);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  /* Buttons don't line-wrap by default the way plain text does — a long
     label (especially now that grouped findings append "— fixes all N")
     would otherwise force this button, and the whole table, wider than the
     page. See the table-layout comment above. */
  white-space: normal;
  text-align: left;
  max-width: 100%;
}

.accept-platform-btn:hover { background: #eaf3fc; }
.accept-platform-btn:disabled { opacity: 0.6; cursor: default; }

.accept-platform-status {
  font-size: 0.78rem;
  color: var(--muted);
}

.accept-platform-status.saved { color: var(--accent-dark); font-weight: 600; }

/* Naming guide page — plain prose/lists rather than tables, since this is
   documentation, not audit output. */
.guide { max-width: 760px; }
.guide h2 { margin-top: 2.25rem; }
.guide h2:first-of-type { margin-top: 1.5rem; }
.guide p, .guide li { line-height: 1.55; color: var(--ink); }
.guide ul, .guide ol { padding-left: 1.3rem; }
.guide li { margin-bottom: 0.5rem; }
.guide .rubric-format {
  background: #f1e9d8;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0.75rem 0;
}
.guide .rubric-format code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

.build-footer {
  text-align: center;
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", monospace;
}

.build-footer a {
  color: var(--muted);
  text-decoration: underline;
}

.build-footer a:hover {
  color: inherit;
}
