/* ============================================================
   CCX Design System — Institutional Document Style
   NYS 1115 Waiver | 18 NYCRR §521 | 42 CFR Part 2
   Version: 2.4.2-NY  |  Data: 2026.04
   ============================================================

   Color System
   --ivory      #F8F6F2  (page background)
   --navy       #0B1F33  (headings, primary brand)
   --gold       #C6A86B  (accent, buttons)
   --border     #DCDCDC  (panel borders)
   --text-soft  #4A5568  (body text)

   Typography
   Headings : Georgia, 'Times New Roman', serif
   Body     : system-ui, -apple-system, sans-serif  (renders as Inter/SF on most systems)
   Mono     : 'SFMono-Regular', SFMono, Menlo, Consolas, monospace
   ============================================================ */

/* ── CSS Custom Properties ────────────────────────────────── */

:root {
  --ivory:        #F8F6F2;
  --navy:         #0B1F33;
  --gold:         #C6A86B;
  --gold-dark:    #A8893A;
  --border:       #DCDCDC;
  --text-soft:    #4A5568;
  --text-muted:   #718096;
  --white:        #FFFFFF;
  --off-white:    #F2F0EC;
  --panel-shadow: 0 1px 4px rgba(11,31,51,0.08), 0 4px 16px rgba(11,31,51,0.06);
  --panel-bg:     #FFFFFF;   /* bento card surface — alias of --white */
  --panel-border: #DCDCDC;   /* bento card border  — alias of --border */

  --risk-stable: #2E7D51;
  --risk-stable-bg: #EAF6EE;
  --risk-amber:  #92600A;
  --risk-amber-bg: #FFF4E0;
  --risk-high:   #B91C1C;
  --risk-high-bg: #FEE2E2;

  --font-serif: Georgia, 'Times New Roman', 'Book Antiqua', Palatino, serif;
  --font-sans:  system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:  'SFMono-Regular', SFMono, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --container-max: 1160px;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space:     1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
}

/* ── Reset ────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family:      var(--font-sans);
  font-size:        1rem;
  line-height:      1.6;
  color:            var(--text-soft);
  background-color: var(--ivory);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family:  var(--font-serif);
  font-weight:  400;
  color:        var(--navy);
  margin:       0 0 0.6em;
  line-height:  1.25;
}

h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); }
h3 { font-size: 1.15rem; }

p {
  margin: 0 0 0.875rem;
  color:  var(--text-soft);
}

p:last-child { margin-bottom: 0; }

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

a:hover {
  color: var(--gold-dark);
}

ul, ol {
  margin:       0 0 0.875rem;
  padding-left: 1.5rem;
  color:        var(--text-soft);
}

li { margin-bottom: 0.3rem; }

pre {
  font-family: var(--font-mono);
  font-size:   0.875rem;
  white-space: pre-wrap;
  word-break:  break-all;
}

code, .mono {
  font-family: var(--font-mono);
  font-size:   0.875em;
}

sub { font-size: 0.75em; }

/* ── Accessibility Utilities ──────────────────────────────── */

.visually-hidden {
  position: absolute;
  width:    1px;
  height:   1px;
  padding:  0;
  margin:   -1px;
  overflow: hidden;
  clip:     rect(0, 0, 0, 0);
  white-space: nowrap;
  border:   0;
}

/* ── Layout ───────────────────────────────────────────────── */

.container {
  max-width: var(--container-max);
  margin:    0 auto;
  padding:   0 var(--space-lg);
}

main.container {
  padding-top:    var(--space-xl);
  padding-bottom: var(--space-2xl);
  display:        flex;
  flex-direction: column;
  gap:            var(--space-lg);
}

/* ── Site Header ──────────────────────────────────────────── */

.site-header {
  position:         sticky;
  top:              0;
  z-index:          1000;
  background-color: var(--navy);
  border-bottom:    1px solid rgba(255,255,255,0.08);
}

.header-inner {
  display:         flex;
  align-items:     center;
  gap:             var(--space-lg);
  padding-top:     0.75rem;
  padding-bottom:  0.75rem;
}

.brand {
  font-family:     var(--font-serif);
  font-size:       1.1rem;
  font-weight:     400;
  color:           var(--gold);
  text-decoration: none;
  letter-spacing:  0.08em;
  text-transform:  uppercase;
  white-space:     nowrap;
}

.nav-links {
  display:    flex;
  gap:        var(--space);
  list-style: none;
  margin:     0;
  padding:    0;
  flex:       1;
}

.nav-links a {
  font-size:       0.875rem;
  font-family:     var(--font-sans);
  color:           rgba(255,255,255,0.75);
  text-decoration: none;
  letter-spacing:  0.02em;
  padding:         0.25rem 0;
  border-bottom:   2px solid transparent;
  transition:      color 120ms, border-color 120ms;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color:        var(--gold);
  border-color: var(--gold);
}

.header-meta {
  display:    flex;
  align-items: center;
  gap:        0.4rem;
  white-space: nowrap;
}

.meta-label {
  font-size:   0.75rem;
  font-family: var(--font-sans);
  color:       rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin:      0;
}

.meta-value {
  font-size: 0.8rem;
  color:     rgba(255,255,255,0.7);
}

/* ── Run Meta Bar ─────────────────────────────────────────── */

.run-meta {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
  padding:     0.6rem var(--space);
  background:  var(--white);
  border:      1px solid var(--border);
  border-radius: var(--radius);
  font-size:   0.8rem;
}

.run-meta .meta-label { color: var(--text-muted); margin: 0; }

/* ── Panels ───────────────────────────────────────────────── */

.panel {
  background:    var(--white);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       var(--space-xl);
  box-shadow:    var(--panel-shadow);
}

.panel-flat {
  background:    var(--white);
  border:        1px solid var(--border);
  border-radius: var(--radius);
}

.eyebrow {
  font-family:    var(--font-sans);
  font-size:      0.72rem;
  font-weight:    600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color:          var(--gold-dark);
  margin-bottom:  0.4rem;
}

.panel-note {
  font-size:    0.875rem;
  color:        var(--text-muted);
  margin-bottom: var(--space);
}

/* ── Controls Grid ────────────────────────────────────────── */

.controls-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap:                   var(--space);
  margin-bottom:         var(--space);
}

.control-group,
label {
  display:       flex;
  flex-direction: column;
  gap:           0.35rem;
  font-size:     0.875rem;
  font-weight:   500;
  color:         var(--navy);
}

.range-hint {
  font-size:   0.75rem;
  font-weight: 400;
  color:       var(--text-muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance:         none;
  width:              100%;
  height:             6px;
  background:         var(--border);
  border-radius:      3px;
  cursor:             pointer;
  border:             none;
  padding:            0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width:        18px;
  height:       18px;
  border-radius: 50%;
  background:   var(--navy);
  cursor:       pointer;
  border:       2px solid var(--white);
  box-shadow:   0 1px 4px rgba(11,31,51,0.3);
}

input[type="number"],
input[type="text"],
select,
textarea {
  font-family:   var(--font-sans);
  font-size:     0.9rem;
  color:         var(--navy);
  background:    var(--white);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:       0.5rem 0.75rem;
  width:         100%;
  transition:    border-color 120ms;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
  outline:       none;
  border-color:  var(--navy);
  box-shadow:    0 0 0 3px rgba(11,31,51,0.1);
}

.persona-display {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
  margin-top:  var(--space-sm);
  font-size:   0.85rem;
}

.persona-chip {
  display:          inline-block;
  background:       var(--navy);
  color:            var(--gold);
  font-size:        0.75rem;
  font-weight:      600;
  text-transform:   uppercase;
  letter-spacing:   0.07em;
  padding:          0.2rem 0.65rem;
  border-radius:    999px;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  appearance:     none;
  display:        inline-flex;
  align-items:    center;
  justify-content: center;
  font-family:    var(--font-sans);
  font-size:      0.875rem;
  font-weight:    600;
  border:         1px solid transparent;
  border-radius:  var(--radius);
  padding:        0.6rem 1.25rem;
  min-height:     40px;
  cursor:         pointer;
  text-decoration: none;
  transition:     background 120ms, border-color 120ms, transform 120ms, box-shadow 120ms;
}

.btn:focus-visible {
  outline:    none;
  box-shadow: 0 0 0 3px rgba(11,31,51,0.2);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background:   var(--navy);
  color:        var(--white);
  border-color: var(--navy);
}

.btn-primary:hover {
  background:   #122c48;
  border-color: #122c48;
}

.btn-secondary {
  background:   var(--white);
  color:        var(--navy);
  border-color: var(--border);
}

.btn-secondary:hover {
  background:   var(--off-white);
  border-color: var(--navy);
}

.btn-gold {
  background:   var(--gold);
  color:        var(--navy);
  border-color: var(--gold);
  font-weight:  700;
}

.btn-gold:hover {
  background:   var(--gold-dark);
  border-color: var(--gold-dark);
}

.btn-alert {
  background:   transparent;
  color:        var(--risk-high);
  border-color: rgba(185,28,28,0.5);
}

.btn-alert:hover {
  background:   var(--risk-high-bg);
}

.actions-row {
  display:   flex;
  flex-wrap: wrap;
  gap:       var(--space-sm);
  margin-top: var(--space);
}

/* ── KPI Cards (Exposure Board) ───────────────────────────── */

.kpi-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap:                   var(--space);
  margin-top:            var(--space);
}

.kpi-card {
  background:    var(--ivory);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       var(--space-lg);
  display:       flex;
  flex-direction: column;
  gap:           0.35rem;
}

.kpi-card--audit { border-left: 3px solid var(--risk-amber); }
.kpi-card--total { border-left: 3px solid var(--navy); }

.kpi-label {
  font-size:      0.78rem;
  font-weight:    600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color:          var(--text-muted);
  margin:         0;
}

.kpi-value {
  font-size:   1.75rem;
  font-weight: 700;
  color:       var(--navy);
  margin:      0.2rem 0 0;
  line-height: 1.1;
}

.kpi-value--range {
  font-size: 1.2rem;
}

.kpi-band-label {
  font-size:  0.72rem;
  color:      var(--text-muted);
  margin:     0.5rem 0 0;
  font-weight: 500;
}

.kpi-band {
  font-size:  0.95rem;
  color:      var(--text-soft);
  margin:     0;
}

.kpi-source {
  font-size: 0.75rem;
  color:     var(--text-muted);
  margin:    0.5rem 0 0;
}

.kpi-formula {
  font-family: var(--font-mono);
  font-size:   0.72rem;
  color:       var(--text-muted);
  margin:      0.2rem 0 0;
  padding-top: 0.4rem;
  border-top:  1px solid var(--border);
}

.kpi-disclaimer {
  font-size:    0.72rem;
  font-style:   italic;
  color:        var(--risk-amber);
  margin:       0.25rem 0 0;
}

.kpi-note {
  font-size: 0.72rem;
  color:     var(--text-muted);
  margin:    0.25rem 0 0;
}

.source-tag {
  display:          inline-block;
  font-family:      var(--font-sans);
  font-size:        0.68rem;
  font-weight:      700;
  text-transform:   uppercase;
  letter-spacing:   0.06em;
  padding:          0.15rem 0.5rem;
  border-radius:    999px;
  background:       var(--off-white);
  color:            var(--text-muted);
  border:           1px solid var(--border);
}

.source-tag--audit {
  background: var(--risk-amber-bg);
  color:      var(--risk-amber);
  border-color: rgba(146,96,10,0.2);
}

.source-tag--scn {
  background: rgba(11,31,51,0.06);
  color:      var(--navy);
  border-color: rgba(11,31,51,0.15);
}

/* ── Fidelity Grid (Heatmap) ──────────────────────────────── */

.grid-section {
  position: relative;
}

.fidelity-grid {
  display:               grid;
  grid-template-columns: repeat(25, 1fr);
  gap:                   4px;
  width:                 100%;
  margin:                var(--space-sm) 0;
}

.node {
  width:         100%;
  aspect-ratio:  1 / 1;
  border-radius: 2px;
  background:    var(--border);
  cursor:        default;
  transition:    transform 80ms;
}

.node:hover {
  transform: scale(1.3);
  z-index:   1;
  position:  relative;
}

.node.stable {
  background: var(--risk-stable);
  opacity:    0.85;
}

.node.medium {
  background: #D97706;
  opacity:    0.85;
}

.node.high {
  background: var(--risk-high);
  opacity:    0.85;
}

.legend {
  margin-top: var(--space-sm);
}

.legend h3 {
  font-size:     0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.4rem;
}

.legend-list {
  list-style:  none;
  padding:     0;
  margin:      0 0 0.5rem;
  display:     flex;
  flex-wrap:   wrap;
  gap:         0.75rem;
}

.legend-list li {
  display:     flex;
  align-items: center;
  gap:         0.4rem;
  font-size:   0.8rem;
  margin:      0;
}

.legend-chip {
  display:       inline-block;
  width:         14px;
  height:        14px;
  border-radius: 2px;
  flex-shrink:   0;
}

.legend-chip.stable { background: var(--risk-stable); }
.legend-chip.medium { background: #D97706; }
.legend-chip.high   { background: var(--risk-high); }

.legend-range {
  font-size: 0.72rem;
  color:     var(--text-muted);
}

.legend-note {
  font-size: 0.75rem;
  color:     var(--text-muted);
  margin:    0;
}

#loading {
  display:         none;
  text-align:      center;
  padding:         var(--space);
  color:           var(--text-muted);
  font-size:       0.875rem;
}

/* ── Interpretation Block ─────────────────────────────────── */

.interpretation-block {
  display:        flex;
  flex-direction: column;
  gap:            var(--space);
}

.interpretation-fixed,
.interpretation-persona {
  padding:       var(--space);
  background:    var(--ivory);
  border:        1px solid var(--border);
  border-radius: var(--radius);
}

.interp-heading {
  font-family:    var(--font-sans);
  font-size:      0.75rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--navy);
  margin-bottom:  0.4rem;
}

.interp-list {
  margin:      0;
  padding-left: 1.2rem;
}

.interp-list li {
  font-size:     0.9rem;
  color:         var(--text-soft);
  margin-bottom: 0.35rem;
}

/* ── Scenario Block ───────────────────────────────────────── */

.scenario-panel { border-left: 4px solid var(--gold); }

.scenario-block h3 {
  font-size:    1.1rem;
  margin-bottom: var(--space-sm);
}

.scenario-block p {
  font-size:     0.9rem;
  margin-bottom: 0.6rem;
}

.scenario-action-title {
  font-size:      0.75rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color:          var(--navy);
  margin:         var(--space) 0 0.4rem;
}

.scenario-actions {
  font-size:   0.875rem;
  margin:      0 0 var(--space-sm);
  padding-left: 1.25rem;
}

.scenario-disclaimer {
  font-size:  0.75rem;
  font-style: italic;
  color:      var(--text-muted);
  margin:     var(--space-sm) 0 0;
  padding:    0.75rem;
  background: var(--off-white);
  border:     1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ── Status Badges ────────────────────────────────────────── */

.status {
  display:        inline-flex;
  align-items:    center;
  border-radius:  999px;
  padding:        0.3rem 0.75rem;
  font-size:      0.75rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.verified {
  background:   rgba(46,125,81,0.1);
  color:        var(--risk-stable);
  border:       1px solid rgba(46,125,81,0.3);
}

.compromised {
  background:   var(--risk-high-bg);
  color:        var(--risk-high);
  border:       1px solid rgba(185,28,28,0.3);
  font-size:    0.8rem;
}

.awaiting {
  background:   var(--risk-amber-bg);
  color:        var(--risk-amber);
  border:       1px solid rgba(146,96,10,0.3);
}

/* ── Status Grid (Audit page) ─────────────────────────────── */

.status-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap:                   var(--space);
  padding:               var(--space);
  background:            var(--ivory);
  border:                1px solid var(--border);
  border-radius:         var(--radius);
  margin:                var(--space) 0;
}

.status-grid > div .meta-label {
  color:         var(--text-muted);
  margin-bottom: 0.25rem;
}

/* ── Results Panel (Audit page) ───────────────────────────── */

.results-panel {
  margin-top:    var(--space);
  padding:       var(--space-lg);
  background:    var(--ivory);
  border:        1px solid var(--border);
  border-radius: var(--radius);
}

.results-panel.hidden { display: none; }

.results-panel h3 {
  font-size:     1rem;
  margin-bottom: var(--space-sm);
}

.result-row {
  display:     flex;
  align-items: baseline;
  gap:         0.75rem;
  margin:      0.4rem 0;
}

.result-label {
  font-size:  0.875rem;
  color:      var(--text-muted);
  min-width:  200px;
}

.result-value {
  font-size:   1rem;
  font-weight: 700;
  color:       var(--navy);
}

.result-disclaimer {
  font-size:  0.75rem;
  font-style: italic;
  color:      var(--text-muted);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

/* ── Results Table (StateBridge summary) ─────────────────── */

.results-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       0.875rem;
}

.results-table th,
.results-table td {
  padding:       0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align:    left;
}

.results-table th {
  font-weight:    600;
  color:          var(--text-muted);
  width:          200px;
  background:     var(--off-white);
}

.results-table td {
  font-weight: 600;
  color:        var(--navy);
  font-family: var(--font-mono);
}

/* ── Immutable Audit Log ──────────────────────────────────── */

.ledger-wrap {
  overflow:      auto;
  border:        1px solid var(--border);
  border-radius: var(--radius);
  margin-top:    var(--space-sm);
}

.ledger-table {
  width:            100%;
  border-collapse:  collapse;
  table-layout:     auto;
  font-size:        0.82rem;
}

.ledger-table caption {
  font-size:   0.75rem;
  color:       var(--text-muted);
  text-align:  left;
  padding:     0.4rem 0.75rem;
  caption-side: top;
}

.ledger-table thead th {
  position:       sticky;
  top:            0;
  z-index:        3;
  background:     var(--navy);
  color:          rgba(255,255,255,0.85);
  font-size:      0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding:        0.6rem 0.75rem;
  font-weight:    600;
  text-align:     left;
  white-space:    nowrap;
}

.ledger-table td {
  padding:       0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color:         var(--text-soft);
}

.ledger-table td.mono {
  word-break:   break-all;
  overflow-wrap: anywhere;
  color:         var(--text-muted);
  font-size:     0.75rem;
}

/* ── WORM Output ──────────────────────────────────────────── */

.worm-formula {
  padding:       var(--space);
  background:    var(--navy);
  border-radius: var(--radius);
  margin-bottom: var(--space);
}

.worm-formula .formula-label {
  font-size:      0.72rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--gold);
  margin-bottom:  0.4rem;
}

.worm-formula pre {
  color:  rgba(255,255,255,0.85);
  margin: 0.25rem 0 0;
}

.worm-output {
  font-family:   var(--font-mono);
  font-size:     0.78rem;
  color:         var(--text-soft);
  background:    var(--off-white);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       var(--space-sm);
  max-height:    320px;
  overflow-y:    auto;
  margin-top:    var(--space-sm);
}

.worm-output .block,
.worm-output .ledger-entry {
  padding:       0.3rem 0;
  border-bottom: 1px solid var(--border);
  word-break:    break-all;
}

.worm-output .block:last-child,
.worm-output .ledger-entry:last-child {
  border-bottom: none;
}

.ledger-full {
  max-height: 240px;
}

/* ── Network Summary Bar ──────────────────────────────────── */

.summary-bar {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   var(--space);
  margin-top:            var(--space);
}

.summary-item {
  padding:       var(--space);
  background:    var(--ivory);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  text-align:    center;
}

.summary-label {
  font-size:      0.72rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color:          var(--text-muted);
  margin-bottom:  0.4rem;
}

.summary-value {
  font-size:   1.5rem;
  font-weight: 700;
  color:       var(--navy);
  margin:      0;
}

/* Ensure the grid container has a layout */
#networkGrid {
  display: grid;
  grid-template-columns: repeat(25, 1fr); /* Adjust based on your node count */
  gap: 2px;
  width: 100%;
  min-height: 200px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 4px;
}

/* Ensure individual nodes are visible */
.node {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 2px;
  transition: transform 0.2s ease;
}

/* Color encoding for risk tiers */
.node.high   { background-color: #ff4d4d; } /* High Audit Exposure */
.node.medium { background-color: #ffaa00; } /* Documentation Risk */
.node.stable { background-color: #00cc66; } /* Stable */

/* ── Node Table ───────────────────────────────────────────── */

.table-shell {
  overflow-x: auto;
  margin-top: var(--space-sm);
}

#nodeList {
  width:            100%;
  border-collapse:  collapse;
  font-size:        0.82rem;
}

#nodeList caption {
  font-size:   0.75rem;
  color:       var(--text-muted);
  text-align:  left;
  padding:     0.4rem 0.75rem;
  caption-side: top;
}

#nodeList thead th {
  background:     var(--navy);
  color:          rgba(255,255,255,0.85);
  font-size:      0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding:        0.6rem 0.75rem;
  text-align:     left;
  white-space:    nowrap;
  position:       sticky;
  top:            0;
}

#nodeList td {
  padding:       0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color:         var(--text-soft);
  font-family:   var(--font-mono);
  font-size:     0.8rem;
}

.tier-stable { color: var(--risk-stable); font-weight: 600; font-family: var(--font-sans); }
.tier-amber  { color: var(--risk-amber);  font-weight: 600; font-family: var(--font-sans); }
.tier-high   { color: var(--risk-high);   font-weight: 600; font-family: var(--font-sans); }

/* ── Inquiry Form ─────────────────────────────────────────── */
/* INQUIRY STACK: SOVEREIGN REFACTOR */
.inquiry-stack {
  background: linear-gradient(165deg, #0a1428 0%, var(--navy) 100%);
  padding: 5rem 2rem;
  border-top: 1px solid rgba(198, 168, 107, 0.2);
  color: var(--ivory);
  -webkit-font-smoothing: antialiased;
}

.inquiry-container {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 5rem;
  align-items: center;
}

/* FIX: The "Vanishing Word" & Title Logic */
.inquiry-title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--ivory) !important; /* Force visibility */
}

.inquiry-title span {
  color: var(--gold) !important; /* The "Second Word" Fix */
  font-style: italic;
}

.inquiry-lead {
  font-size: 1.1rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 2.5rem;
}

/* TRUST INDICATORS */
.trust-indicators {
  display: flex;
  gap: 2rem;
}

.indicator {
  border-left: 2px solid var(--gold);
  padding-left: 1rem;
}

.indicator strong {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.indicator span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* FORM ELEMENTS: GLASS DESIGN */
.form-group {
  margin-bottom: 1.5rem;
}

.inquiry-form label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* ── Defensive override: label & input visibility in inquiry form ─────────── */
/* Specificity override for Inquiry Form Legibility */
/* --- Identity Triad Selector --- */
.identity-triad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.id-card {
  cursor: pointer;
  position: relative;
}

.id-card input {
  display: none; /* Hide the native radio circle */
}

.card-inner {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
}

.card-title {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: #ffffff; /* Explicitly white for visibility on dark bg */
}

.card-desc {
  display: block;
  font-size: 0.7rem;
  line-height: 1.3;
  opacity: 0.6;
  color: #ffffff;
}

/* Active State Logic */
.id-card input:checked + .card-inner {
  background: rgba(0, 123, 255, 0.1);
  border-color: #007bff;
  box-shadow: 0 0 15px rgba(0, 123, 255, 0.2);
}

.id-card input:checked + .card-inner .card-title {
  color: #007bff; /* Title turns blue when selected */
}

.inquiry-form input,
.inquiry-form textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.3) !important; /* raised from 0.15 for visibility */
  border-radius: 4px;
  padding: 1rem;
  color: var(--ivory);
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.inquiry-form input:focus,
.inquiry-form textarea:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 15px rgba(198, 168, 107, 0.15);
}

/* Placeholder Fix */
::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.9rem;
}

.btn-submit {
  width: 100%;
  background: var(--gold);
  color: var(--navy);
  border: none;
  padding: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.btn-submit:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

/* RESPONSIVE MAPPING */
@media (max-width: 768px) {
  .inquiry-container { grid-template-columns: 1fr; gap: 3rem; }
  .inquiry-title { font-size: 2rem; }
}
/* ── Methodology Specific ─────────────────────────────────── */

.hero { border-top: 4px solid var(--navy); }

.notice-block {
  padding:       var(--space);
  background:    var(--off-white);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  margin-top:    var(--space);
}

.notice-block p { margin: 0; font-size: 0.875rem; }

.disclaimer-block,
.citation-block {
  padding:       var(--space);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space);
  background:    var(--ivory);
}

.disclaimer-block h3,
.citation-block h3 {
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.formula-block {
  padding:       var(--space);
  background:    var(--navy);
  border-radius: var(--radius);
  margin:        var(--space) 0;
  text-align:    center;
}

.formula-label {
  font-size:      0.72rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--gold);
  margin-bottom:  0.4rem;
  margin-top:     0;
}

.formula-display {
  font-family:  var(--font-mono);
  font-size:    1.1rem;
  color:        var(--ivory);
  margin:       0;
}

.param-table {
  width:            100%;
  border-collapse:  collapse;
  font-size:        0.85rem;
  margin:           var(--space) 0;
}

.param-table caption {
  font-size:   0.72rem;
  color:       var(--text-muted);
  text-align:  left;
  margin-bottom: 0.4rem;
  caption-side: top;
}

.param-table th {
  background:     var(--off-white);
  color:          var(--navy);
  font-size:      0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding:        0.5rem 0.75rem;
  text-align:     left;
  border-bottom:  2px solid var(--border);
  font-weight:    700;
}

.param-table td {
  padding:       0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color:         var(--text-soft);
  vertical-align: top;
}

/* ── No State Message ─────────────────────────────────────── */

.no-state-msg {
  padding:       var(--space);
  background:    var(--off-white);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  color:         var(--text-muted);
  font-size:     0.875rem;
  text-align:    center;
}

/* ── Actions Panel ────────────────────────────────────────── */

.actions-panel {
  display:     flex;
  align-items: center;
  gap:         var(--space-sm);
}

/* ── Site Footer ──────────────────────────────────────────── */

.site-footer {
  background:    var(--navy);
  color:         rgba(255,255,255,0.6);
  padding:       var(--space-lg) 0;
  margin-top:    var(--space-xl);
}

.footer-inner {
  display:        flex;
  flex-direction: column;
  gap:            0.4rem;
}

.footer-inner p {
  font-size: 0.8rem;
  color:     rgba(255,255,255,0.55);
  margin:    0;
}

.footer-inner a {
  color: var(--ivory);
}

.footer-inner nav {
  display:    flex;
  flex-wrap:  wrap;
  gap:        var(--space);
  margin-bottom: 0.5rem;
}

.footer-inner nav a {
  color:           rgba(255,255,255,0.7);
  font-size:       0.8rem;
  text-decoration: none;
}

.footer-inner nav a:hover { color: var(--gold); }

.footer-align,
.footer-integrity,
.footer-formula,
.footer-anchors {
  font-size: 0.75rem;
  color:     rgba(255,255,255,0.45);
}
/* ── Smooth Scroll Behavior ── */
html {
  scroll-behavior: smooth;
}

/* ── Footer Button Styling ── */
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 4rem 0;
  border-top: 1px solid var(--panel-border);
}

.footer-handshake-btn {
  padding: 1rem 2.5rem;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
  border-radius: 4px;
  background: var(--gold);
  color: var(--navy);
  text-decoration: none;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.footer-handshake-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.footer-info {
  text-align: center;
  opacity: 0.6;
}

.footer-copyright {
  font-size: 0.7rem;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.btn-success {
  background-color: #2ecc71 !important;
  color: white !important;
}

.btn-error {
  background-color: #e74c3c !important;
  color: white !important;
}

.status-compromised {
  background-color: var(--risk-high); /* Institutional Red */
  color: white;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
}

.status-valid {
  background-color: #2ecc71; /* Institutional Green */
  color: white;
}
/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1024px) {
  .fidelity-grid {
    grid-template-columns: repeat(13, 1fr);
  }
}

@media (max-width: 768px) {
  .container { padding: 0 var(--space); }

  main.container {
    padding-top:    var(--space);
    padding-bottom: var(--space-xl);
  }

  .fidelity-grid {
    grid-template-columns: repeat(9, 1fr);
  }

  .bento-stack {
    grid-template-columns: 1fr;
  }

  .bento-full {
    grid-column: span 1;
  }

  .summary-bar {
    grid-template-columns: 1fr;
  }

  .inquiry-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .fidelity-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-links { gap: var(--space-sm); }
  .nav-links a { font-size: 0.8rem; }

  .btn { width: 100%; }

  .actions-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .header-inner { flex-wrap: wrap; gap: var(--space-sm); }
  .header-meta  { display: none; }
}

/* ── KPI Provenance Info Button & Tooltip ──────────────────────────────────── */

.kpi-info-btn {
  position:        relative;
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  background:      transparent;
  border:          1px solid rgba(154, 208, 255, 0.35);
  border-radius:   50%;
  color:           var(--accent);
  cursor:          pointer;
  font-size:       0.72rem;
  line-height:     1;
  margin-left:     0.35rem;
  padding:         0.1rem 0.28rem;
  vertical-align:  middle;
  white-space:     nowrap;
}

.kpi-info-btn:focus-visible {
  outline:        2px solid var(--accent);
  outline-offset: 2px;
}

.kpi-tooltip {
  display:       none;
  position:      absolute;
  bottom:        calc(100% + 6px);
  left:          50%;
  transform:     translateX(-50%);
  width:         220px;
  background:    var(--surface-2, #1e2630);
  border:        1px solid rgba(154, 208, 255, 0.25);
  border-radius: var(--radius);
  color:         var(--text-muted);
  font-size:     0.72rem;
  font-weight:   400;
  line-height:   1.45;
  padding:       0.5rem 0.65rem;
  pointer-events:none;
  text-align:    left;
  white-space:   normal;
  z-index:       100;
}

.kpi-info-btn:hover .kpi-tooltip,
.kpi-info-btn:focus-visible .kpi-tooltip {
  display: block;
}

/* KaTeX formula blocks in methodology.html */
.katex-formula {
  display:    block;
  overflow-x: auto;
  padding:    0.5rem 0;
  text-align: center;
}

.katex-formula .katex { font-size: 1.1rem; }
/* ── Sovereign Bento Stack ────────────────────────────────── */
:root {
  /* Refined Palette: Moving from 'Flat' to 'Dimensional' */
  --ink:          #1A1D21;   /* Deep Slate for high-authority text */
  --ink-muted:    #4A4F58;
  --paper-bg:     #FAFAFA;   /* Institutional off-white */
  --gold-warm:    #B38E4D;   /* Calibrated Gold for legibility */
  --border-auth:  #E1E4E8;   /* Subtle, crisp boundaries */
}

@keyframes trust-pulse {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.bento-stack {
  display:               grid;
  /* Use minmax(0, 1fr) to prevent content from 'pushing' the column width */
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap:                   2rem;
  margin:                4rem 0;
  align-items:           stretch; /* Ensures cards in a row stay the same height */
}

/* Force the main card to respect the 1.6fr ratio */
.bento-main {
  grid-column: 1;
}

/* Force the side card to respect the 1fr ratio */
.bento-side {
  grid-column: 2;
}

/* Responsive adjustment: Stack on small screens */
@media (max-width: 900px) {
  .bento-stack {
    grid-template-columns: 1fr;
  }
  .bento-main, .bento-side {
    grid-column: 1;
  }
}

.bento-card {
  background:      var(--white);
  border:          1px solid var(--border-auth);
  border-radius:   12px;
  padding:         2.5rem;
  position:        relative;
  overflow:        visible; /* Changed from hidden to prevent tag clipping */
  display:         flex;
  flex-direction:  column;
  transition:      all 0.3s ease;
}

/* ── Tags & Chips (The Overlap Fix) ───────────────────────── */

.bento-tags {
  display:        flex;
  flex-wrap:      wrap;
  /* The first value is vertical gap, the second is horizontal */
  gap:            0.75rem 0.5rem; 
  margin-top:     1.5rem;
  width:          100%;
}

.tag {
  display:        inline-flex;
  align-items:    center;
  white-space:    nowrap; /* Prevents text from wrapping inside a tiny tag */
  font-size:      0.7rem;
  font-weight:    600;
  padding:        0.4rem 0.8rem;
  line-height:    1; /* Clean vertical centering */
  background:     var(--paper-bg);
  color:          var(--ink);
  border:         1px solid var(--border-auth);
  border-radius:  4px;
}
.tag:hover {
  background:     var(--gold-warm);
  color:          var(--white);
  border-color:   var(--gold-warm);
}
/* Topology list — workflow positioning */
.topology-list {
  list-style: none;
  padding:    0;
  margin:     0 0 0.75rem;
}

.topology-list li {
  font-size:     0.9rem;
  padding:       0.35rem 0;
  border-bottom: 1px solid var(--panel-border);
  color:         var(--text-soft);
  margin:        0;
}

.topology-list li:last-child { border-bottom: none; }

/* Boundary disclaimer — "CCX is not an EHR or Billing System" */
.boundary-note {
  font-size:   0.78rem;
  font-style:  italic;
  color:       var(--text-muted);
  margin:      0.75rem 0 0;
  padding-top: 0.5rem;
  border-top:  1px solid var(--panel-border);
}

/* Stakeholder matrix — flex columns inside .bento-full */
.stakeholder-flex {
  display:   flex;
  gap:       2.5rem;
  flex-wrap: wrap;
}

.stakeholder {
  flex:       1 1 200px;
  min-width:  0;
}

.stakeholder-label {
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--gold);
  margin:         0 0 0.4rem;
}

.stakeholder p {
  font-size: 0.9rem;
  margin:    0;
}

/* Panel h2: Navy/Gold institutional palette */
.panel h2 {
  color:       var(--navy);
  border-left: 3px solid var(--gold);
  padding-left: 0.75rem;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 0.01em;
}

/*
 * Fiduciary Footer — 4-column statutory grid.
 *
 * Col 1 (.footer-brand)     1.5fr  Navy wordmark + Gold tagline
 * Col 2 (.footer-statutory)  1fr   Methodology / 18 NYCRR §521 links
 * Col 3 (.footer-model-meta) 1fr   Version + Timestamp metadata
 * Col 4 (.footer-seal)       1fr   Logic Verified SHA-256 badge
 */
.app-footer {
  width:                 100%;
  border-top:            1px solid var(--panel-border);
  padding:               3rem;
  box-sizing:            border-box;
  display:               grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap:                   2rem;
  align-items:           start;
  color:                 var(--text-muted);
  font-size:             0.85rem;
  background:            var(--ivory);
}

/* Col 1 — Brand: Navy wordmark, Gold tagline */
.app-footer .footer-brand {
  display:        flex;
  flex-direction: column;
  gap:            0.5rem;
}

.app-footer .footer-brand .brand-wordmark {
  font-family:    var(--font-serif);
  font-size:      1rem;
  color:          var(--navy);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin:         0;
}

.app-footer .footer-brand .brand-tagline {
  font-size:  0.75rem;
  color:      var(--gold);
  margin:     0;
}

/* Col 2 — Statutory Links: Methodology / 18 NYCRR §521 */
.app-footer .footer-statutory {
  display:        flex;
  flex-direction: column;
  gap:            0.4rem;
}

.app-footer .footer-statutory .statutory-heading {
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--text-muted);
  margin:         0 0 0.4rem;
}

.app-footer .footer-statutory a {
  color:           var(--text-muted);
  font-size:       0.82rem;
  text-decoration: none;
}

.app-footer .footer-statutory a:hover {
  color:           var(--gold);
  text-decoration: underline;
}

/* Backward-compatible alias — existing .footer-links markup still resolves */
.app-footer .footer-links {
  display:        flex;
  flex-direction: column;
  gap:            0.4rem;
}

.app-footer .footer-links a {
  color:           var(--text-muted);
  text-decoration: none;
}

.app-footer .footer-links a:hover {
  color:           var(--gold);
  text-decoration: underline;
}

/* Col 3 — Model Metadata: Version + Timestamp */
.app-footer .footer-model-meta {
  display:        flex;
  flex-direction: column;
  gap:            0.4rem;
}

.app-footer .footer-model-meta .meta-heading {
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--text-muted);
  margin:         0 0 0.4rem;
}

.app-footer .footer-model-meta .meta-row {
  display:     flex;
  gap:         0.4rem;
  align-items: baseline;
  font-size:   0.78rem;
}

.app-footer .footer-model-meta .meta-key {
  color:       var(--text-muted);
  flex-shrink: 0;
}

.app-footer .footer-model-meta .meta-val {
  font-family: var(--font-mono);
  color:       var(--navy);
  font-size:   0.75rem;
}

/* Backward-compatible alias — existing .footer-meta markup still resolves */
.app-footer .footer-meta {
  display:        flex;
  flex-direction: column;
  gap:            0.4rem;
}

/* Col 4 — Logic Verified Seal: SHA-256 badge */
.app-footer .footer-seal {
  display:        flex;
  flex-direction: column;
  gap:            0.5rem;
  align-items:    flex-start;
}

.app-footer .footer-seal .seal-badge {
  display:       inline-flex;
  align-items:   center;
  gap:           0.4rem;
  border:        1px solid var(--panel-border);
  border-radius: 6px;
  padding:       0.4rem 0.75rem;
  background:    var(--ivory);
}

.app-footer .footer-seal .seal-label {
  font-size:      0.68rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--gold);
}

.app-footer .footer-seal .seal-hash {
  font-family:  var(--font-mono);
  font-size:    0.65rem;
  color:        var(--text-muted);
  word-break:   break-all;
  margin:       0;
}

.app-footer .footer-seal .seal-status {
  font-size:  0.72rem;
  color:      var(--text-muted);
  margin:     0;
}

/* Responsive: collapse to 2-col at tablet, 1-col at mobile */
@media (max-width: 1024px) {
  .app-footer {
    grid-template-columns: 1.5fr 1fr 1fr;
  }
  .app-footer .footer-seal {
    grid-column: span 3;
    flex-direction: row;
    align-items:    center;
    border-top:     1px solid var(--panel-border);
    padding-top:    1rem;
    margin-top:     0.5rem;
  }
}

@media (max-width: 768px) {
  .app-footer {
    grid-template-columns: 1fr 1fr;
    padding: 2rem var(--space);
  }
  .app-footer .footer-seal {
    grid-column: span 2;
  }
}

@media (max-width: 480px) {
  .app-footer {
    grid-template-columns: 1fr;
  }
  .app-footer .footer-seal {
    grid-column: span 1;
  }
}

/* SCN list item highlight — 1px gold left border when active */
.highlight-SCN {
  border-left:  1px solid var(--gold);
  padding-left: 0.6rem;
  background:   rgba(198, 168, 107, 0.06);
  transition:   border-color 0.2s ease, background 0.2s ease;
}

/* CBO list item highlight — 1px gold left border when active */
.highlight-CBO {
  border-left:  1px solid var(--gold);
  padding-left: 0.6rem;
  background:   rgba(198, 168, 107, 0.06);
  transition:   border-color 0.2s ease, background 0.2s ease;
}
