/* R19 material system. The approved #ai .r18-dialogue remains untouched.
   Outer glass belongs to a working object; rows and text remain inside it. */
html[data-r18-system] {
  --r19-ink: #fbf3e9;
  --r19-muted: #d0c2d3;
  --r19-accent: #efca8d;
  --r19-glass: rgba(40, 33, 45, .78);
  --r19-layer: rgba(204, 180, 216, .095);
  --r19-layer-strong: rgba(204, 180, 216, .15);
  --r19-line: rgba(224, 200, 230, .22);
  --r19-rim: rgba(255, 247, 239, .11);
  --r19-shadow: rgba(18, 10, 26, .13);
  --r19-radius: 18px;
  --r19-glass-background: linear-gradient(135deg, rgba(237, 213, 242, .055), transparent 58%), var(--r19-glass);
}
html[data-r18-system][data-theme="light"] {
  --r19-ink: #302439;
  --r19-muted: #625165;
  --r19-accent: #76532d;
  --r19-glass: rgba(255, 250, 246, .76);
  --r19-layer: rgba(107, 69, 124, .065);
  --r19-layer-strong: rgba(107, 69, 124, .11);
  --r19-line: rgba(104, 73, 119, .20);
  --r19-rim: rgba(255, 255, 255, .62);
  --r19-shadow: rgba(62, 35, 74, .055);
  --r19-glass-background: linear-gradient(135deg, rgba(255, 255, 255, .38), transparent 58%), var(--r19-glass);
}

/* Family tokens keep labels, chart keys, citations and semantic states intact. */
html[data-r18-system] :is(.r18-clarification, .r18-deployment) {
  --r18-ui-ink: var(--r19-ink);
  --r18-ui-muted: var(--r19-muted);
  --r18-ui-accent: var(--r19-accent);
  --r18-ui-base: var(--r19-glass);
  --r18-ui-panel: var(--r19-layer);
  --r18-ui-layer: var(--r19-layer-strong);
  --r18-ui-line: var(--r19-line);
}
[data-r18-system] .r17a-scene {
  --r17-paper: var(--r19-glass);
  --r17-secondary: var(--r19-layer);
  --r17-ink: var(--r19-ink);
  --r17-muted: var(--r19-muted);
  --r17-line: var(--r19-line);
  --r17-accent: #c8b0df;
  --r17-other: #8b739d;
  --r17-remember: var(--r19-layer-strong);
  --r17-remember-ink: var(--r19-accent);
}
html[data-r18-system] .r17k-workspace {
  --k-ink: var(--r19-ink);
  --k-muted: var(--r19-muted);
  --k-surface: var(--r19-glass);
  --k-secondary: var(--r19-layer);
  --k-line: var(--r19-line);
}
html[data-r18-system] .r12c-report {
  --c-ink: var(--r19-ink);
  --c-muted: var(--r19-muted);
  --c-line: var(--r19-line);
}
[data-r18-system][data-theme="light"] .r12c-report {
  --c-lilac: #79548e;
  --c-gold: #ad7d36;
}

/* Inventory: primary product objects, reports, architecture, service outputs. */
[data-r18-system] :is(
  .r17a-scene, .r17k-workspace, .r18-clarification,
  .r18-deployment > .r17k-mode, .r12c-report,
  .r18-pilot-report, .r8-bi-report,
  .r12s-team-work, .r12s-project, .r12a-how,
  .staff-benefit-art, .staff-role-dev, .staff-role-fde,
  .staff-fork-origin, .staff-start-proof,
  .r10c-fact, .r19-start-results
) {
  color: var(--r19-ink);
  background: var(--r19-glass-background) !important;
  border: 1px solid var(--r19-line) !important;
  border-radius: var(--r19-radius) !important;
  box-shadow: inset 0 1px 0 var(--r19-rim), 0 14px 40px var(--r19-shadow) !important;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

/* Plain company-format cards share the approved material, not opaque posters. */
[data-r18-system="home"] #formats .r8-formats-body > article {
  color: var(--r19-ink) !important;
  background: var(--r19-glass-background) !important;
  border: 1px solid var(--r19-line);
  border-radius: var(--r19-radius) !important;
  box-shadow: inset 0 1px 0 var(--r19-rim), 0 14px 40px var(--r19-shadow);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
[data-r18-system="home"] #formats .r8-formats-body > article :is(h3, a) { color: var(--r19-ink) !important; }
[data-r18-system="home"] #formats .r8-formats-body > article > p { color: var(--r19-muted) !important; }

/* Nested material is lighter, with one blur on the outer object only. */
[data-r18-system] :is(
  .r18-map-company, .r18-map-terminal, .r18-clarification-memory,
  .r17k-reader, .r17a-report-brief,
  .r12s-client-window, .r12s-client-message, .r12s-manager-message,
  .r8s-team-output, .staff-search-paper, .staff-review-ticket,
  .r8-reading, .nv-dash-panel, .nv-bi-table-wrap, .nv-ticket
) {
  background: var(--r19-layer) !important;
  color: var(--r19-ink);
  border-color: var(--r19-line) !important;
  box-shadow: inset 0 1px 0 var(--r19-rim) !important;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
[data-r18-system] :is(.r12s-client-window, .staff-search-paper, .staff-review-ticket, .r8-reading, .nv-dash-panel) {
  border-radius: 12px !important;
}
[data-r18-system] .r17k-workspace-bar { background: transparent; }
[data-r18-system] .r18-map-node svg { background: var(--r19-layer-strong); }
[data-r18-system] .r18-map-node:last-child svg { color: var(--r19-accent); }
[data-r18-system] .r18-map-company { border-color: var(--r19-line); }
[data-r18-system] .r18-clarification-result { background: var(--r19-layer); }

/* Service illustrations use the same surface and readable theme-aware ink. */
[data-r18-system] :is(.r12s-team-work, .r12s-project, .r12a-how) {
  color: var(--r19-ink) !important;
}
[data-r18-system] :is(.r12s-team-work, .r12s-project) :is(h3, strong, .r12s-client-message p, .r12s-manager-message > p) {
  color: var(--r19-ink) !important;
  -webkit-text-fill-color: currentColor;
}
[data-r18-system] :is(.r12s-team-work, .r12s-project) :is(p, small, header, figcaption, .r12s-manager-window > header > span, .r12s-client-message > span, .r12s-manager-message > span) {
  color: var(--r19-muted);
}
[data-r18-system] :is(.r12s-team-work, .r12s-project) :is(header, figcaption, article) { border-color: var(--r19-line); }
[data-r18-system] .r12s-scene::after { opacity: .035; }

[data-r18-system] .r18-pilot-report {
  --report-ink: var(--r19-ink);
  --report-muted: var(--r19-muted);
  --report-rule: var(--r19-line);
}
[data-r18-system] .r18-pilot-report :is(h3, .r18-pilot-total strong, .r18-pilot-total > span) { color: var(--r19-ink); }
[data-r18-system] .r18-pilot-report :is(small, figcaption, .r18-pilot-exception, .r18-pilot-chart span) { color: var(--r19-muted); }
[data-r18-system] .r18-pilot-report :is(.r18-pilot-total p, .r18-pilot-exception strong) { color: var(--r19-accent); }

/* Staff diagrams remain diagrams: changed materials, no added decoration. */
html[data-staff-detail] {
  --staff-surface: var(--r19-glass);
  --staff-object: var(--r19-layer-strong);
  --staff-line: var(--r19-line);
  --staff-art-ink: var(--r19-ink);
  --staff-art-muted: var(--r19-muted);
  --staff-accent: var(--r19-accent);
}
[data-r18-system] :is(.staff-benefit-art, .staff-role-dev, .staff-role-fde) :is(strong, p, h3) { color: var(--r19-ink); }
[data-r18-system] :is(.staff-review-ticket header, .staff-review-ticket small, .staff-work-art > span, .staff-load-art > span) { color: var(--r19-muted); }
[data-r18-system] .staff-review-ticket { color: var(--r19-ink); }
[data-r18-system] .staff-review-ticket :is(.staff-ticket-heading, .staff-ticket-check > span) { color: var(--r19-muted); }
[data-r18-system] .staff-review-ticket .staff-ticket-check p { color: var(--r19-ink); }
[data-r18-system] .staff-review-ticket .staff-ticket-result { border-color: var(--r19-line); }
[data-r18-system] .staff-review-ticket .staff-ticket-result span { color: var(--r19-accent); }
[data-r18-system] .staff-load-line span { border-color: var(--r19-accent); }
[data-r18-system] .staff-search-paper { transform: none; }
[data-r18-system] .staff-role-ai { border-radius: var(--r19-radius); }

/* Full report: counteract older forced dark-theme dashboard paint. */
[data-r18-system] .r8-bi-report :is(.nv-dash-panel h3, .nv-bi-heading h2, .nv-dash-value strong) {
  color: var(--r19-ink) !important;
  -webkit-text-fill-color: currentColor !important;
}
[data-r18-system] .r8-bi-report :is(.nv-bi-heading p, .nv-bi-heading span, .nv-dash-panel p, .nv-chart-legend) { color: var(--r19-muted) !important; }
[data-r18-system] .r8-bi-report .nv-dash-panel { border-color: var(--r19-line) !important; }

/* Fallback keeps the same translucent rim on browsers without backdrop blur. */
@supports not (backdrop-filter: blur(1px)) {
  html[data-r18-system] { --r19-glass: rgba(40, 33, 45, .94); }
  html[data-r18-system][data-theme="light"] { --r19-glass: rgba(255, 250, 246, .94); }
}
@media (prefers-reduced-transparency: reduce) {
  html[data-r18-system] { --r19-glass: #28212d; --r19-layer: #372d3d; }
  html[data-r18-system][data-theme="light"] { --r19-glass: #fffaf6; --r19-layer: #f1e9f3; }
}

[data-r18-system] .r12a-how { --a-ink: var(--r19-ink); --a-sub: var(--r19-muted); --a-gold: var(--r19-accent); --a-line: var(--r19-line); }
[data-r18-system] .r12a-how :is(.r12a-how-answer, .r12a-how-sources > div) { background: var(--r19-layer); border-color: var(--r19-line); color: var(--r19-ink); }

/* The detailed case has older high-specificity colours; keep all report text
   on the same ink tokens when its canvas changes to the light glass variant. */
[data-r18-system] .r9-case-page .r8-bi-report {
  --ui-ink: var(--r19-ink);
  --ui-muted: var(--r19-muted);
  --ui-bg: var(--r19-glass);
  --ui-wash: var(--r19-layer);
  --ui-accent: var(--r19-accent);
  color: var(--r19-ink);
}
[data-r18-system] .r9-case-page .r8-bi-report :is(.nv-dash-panel, .nv-dash-value strong, .nv-bi-day-bars b, .nv-bi-day, .nv-hbar, .nv-hbar-label, .nv-bi-table-wrap, .nv-bi-table-wrap h3, .nv-ticket) { color: var(--r19-ink) !important; }
[data-r18-system] .r9-case-page .r8-bi-report :is(.nv-dash-value span, .nv-axis-title, .nv-case-chart-axis, .r9-detail-x-axis, .nv-bi-filter) { color: var(--r19-muted) !important; }
[data-r18-system] .r9-case-page .r8-bi-report .nv-bi-heading { border-bottom-color: var(--r19-line); }
[data-r18-system] .r9-case-page .r8-bi-report select { color: var(--r19-ink); background: var(--r19-layer-strong); border-color: var(--r19-line); }
[data-r18-system] .r9-case-page .r8-bi-report select option { color: var(--r19-ink); background: var(--bg, #28212d); }
[data-r18-system] .r9-case-page .r8-bi-report .nv-case-chart-days::before { border-color: var(--r19-line); background-image: linear-gradient(to bottom, var(--r19-line) 1px, transparent 1px); }
[data-r18-system] .r9-case-page .r8-bi-report .nv-hbar-track { background: var(--r19-layer-strong); }
[data-r18-system][data-theme="light"] .r9-case-page .r8-bi-report .nv-bi-day-bars > span { background: linear-gradient(to top, #ad8cbd80, #79548e) !important; }
[data-r18-system][data-theme="light"] .r9-case-page .r8-bi-report .nv-bi-day-bars > span + span { background: linear-gradient(to top, #c19d6880, #ad7d36) !important; }

[data-r18-system] .r9-case-page .r12c-cv { background: transparent !important; }
[data-r18-system] .r9-case-page .r12c-cv .r8-reading {
  color: var(--r19-ink);
  background: var(--r19-glass-background) !important;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
[data-r18-system] .r9-case-page .r12c-cv .r8-reading :is(h3, .r8-reading-count) { color: var(--r19-ink); }
[data-r18-system] .r9-case-page .r12c-cv .r8-reading :is(p, .r8-print-key, .r8-reading-result > span) { color: var(--r19-muted); }
[data-r18-system] .r9-case-page .r12c-cv .r8-reading-count strong { color: var(--r19-accent); }
[data-r18-system] .r9-case-page .r12c-cv .r8-reading-result { border-color: var(--r19-line); }

/* Late R13 mounts replace the earlier R12 service illustration nodes. These
   selectors intentionally target the final DOM, not their source templates. */
html[data-r18-system] :is(.r13s-team, .r13s-project-flow, .r13d-integration) {
  --r13s-ink: var(--r19-ink);
  --r13s-muted: var(--r19-muted);
  --r13s-ground: var(--r19-glass);
  --r13s-track: var(--r19-layer);
  --r13s-gold: var(--r19-accent);
  color: var(--r19-ink);
  background: var(--r19-glass-background) !important;
  border: 1px solid var(--r19-line);
  border-radius: var(--r19-radius);
  box-shadow: inset 0 1px 0 var(--r19-rim), 0 14px 40px var(--r19-shadow);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
html[data-r18-system] .r13s-team { padding: clamp(24px, 3vw, 40px); }
html[data-r18-system] .r13s-team-solution {
  padding: clamp(22px, 2.4vw, 32px);
  border: 1px solid var(--r19-line);
  border-radius: 12px;
  background: var(--r19-layer);
  box-shadow: inset 0 1px 0 var(--r19-rim);
}
html[data-r18-system] .r13s-solution-strata > span {
  color: var(--r19-ink);
  background: var(--r19-layer-strong);
  border: 1px solid var(--r19-line);
  border-left: 3px solid var(--r13s-lilac);
  border-radius: 8px;
}
html[data-r18-system] .r13s-solution-strata > span:nth-child(2) { border-left-color: var(--r13s-teal); }
html[data-r18-system] .r13s-solution-strata > span:nth-child(3) { border-left-color: var(--r13s-gold); }
html[data-r18-system] .r13s-project-flow figcaption { border-top: 1px solid var(--r19-line); }
html[data-r18-system] .r13d-integration .r13d-engine {
  padding: 18px 12px;
  border: 1px solid var(--r19-line);
  border-radius: 12px;
  background: var(--r19-layer);
}
html[data-r18-system] .r13d-integration .r13d-engine svg { color: var(--r19-accent); }
html[data-r18-system] .r13d-integration :is(.r13d-inputs, .r13d-outputs) > strong { border-color: var(--r19-line); }
html[data-r18-system] .r13d-integration :is(.r13d-inputs > span, .r13d-outputs > span, .r13d-engine small) { color: var(--r19-muted); opacity: 1; }

/* Role panels share glass in both themes; their source once forced pale FDE
   captions independently of the panel's surface. Keep photography separate. */
html[data-r18-system][data-staff-detail] :is(.staff-role-dev, .staff-role-fde) :is(.staff-role-origin > span, .staff-fde-answer > span) {
  color: var(--r19-muted);
}
html[data-r18-system][data-staff-detail] :is(.staff-role-dev, .staff-role-fde) :is(.staff-role-origin > strong, .staff-fde-answer > strong, .staff-role-flow > span) {
  color: var(--r19-ink);
}
html[data-r18-system][data-staff-detail] .staff-fde-answer { border-inline-start-color: var(--r19-accent); }

/* R13 process audit: recurrence/reports and non-RAG human/request mounts are
   replaced by R17/R18. RAG intentionally keeps this human-review figure. */
html[data-r18-system] .r13p-scene.r13p-human {
  --p-ink: var(--r19-ink);
  --p-muted: var(--r19-muted);
  --p-line: var(--r19-line);
  --p-paper: var(--r19-layer-strong);
  --p-paper-ink: var(--r19-ink);
  --p-accent: var(--r19-accent);
  color: var(--r19-ink);
  background: var(--r19-glass-background) !important;
  border: 1px solid var(--r19-line);
  border-radius: var(--r19-radius);
  box-shadow: inset 0 1px 0 var(--r19-rim), 0 14px 40px var(--r19-shadow);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
html[data-r18-system] .r13p-human .r13p-ticket {
  color: var(--r19-ink);
  background: var(--r19-layer);
  border: 1px solid var(--r19-line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: inset 0 1px 0 var(--r19-rim);
}
html[data-r18-system] .r13p-human .r13p-ticket > header { flex-wrap: wrap; gap: 8px 16px; }
html[data-r18-system] .r13p-human .r13p-phone {
  color: var(--r19-ink);
  background: var(--r19-layer-strong);
  border-color: var(--r19-line);
  box-shadow: inset 0 1px 0 var(--r19-rim), 0 14px 32px var(--r19-shadow);
  /* Existing 5px bezel, 35px radius, notch and home indicator stay intact. */
}
html[data-r18-system] .r13p-human :is(.r13p-phone-signal, .r13p-phone-body > header small, .r13p-review-field > span, .r13p-phone-status, .r13p-field-focus del) {
  color: var(--r19-muted);
}
html[data-r18-system] .r13p-human .r13p-review-field { border-color: var(--r19-line); }
html[data-r18-system] .r13p-human .r13p-field-focus b { color: var(--r19-accent); }
html[data-r18-system] .r13p-human .r13p-phone-home { background: var(--r19-muted); }
@media (max-width: 650px) {
  html[data-r18-system] .r13p-human .r13p-phone { max-width: 100%; }
  html[data-r18-system] .r13p-human .r13p-ticket dl > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    align-items: start;
  }
}

/* Legacy BI labels consume nv tokens rather than the newer ui family. Scope
   this bridge to the report; the categorical/chart gold remains unchanged. */
html[data-r18-system] .r8-bi-report {
  --nv-ink: var(--r19-ink);
  --nv-muted: var(--r19-muted);
  --nv-gold-ink: var(--r19-accent);
}
html[data-r18-system] .r8-bi-report .r8-bi-records {
  color: var(--r19-accent);
}
/* Older r12-cases.css forces these four labels with !important, bypassing
   the nv token bridge. Match the actual final descendants at higher scope. */
html[data-r18-system] .r9-case-page .r8-bi-report .nv-bi-heading label,
html[data-r18-system] .r9-case-page .r8-bi-report .nv-dash-pair span,
html[data-r18-system] .r9-case-page .r8-bi-report .nv-bi-bar > span,
html[data-r18-system] .r9-case-page .r8-bi-report .nv-bi-bar > b {
  color: var(--r19-muted) !important;
}
