@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
  --bg: #161616;
  --panel: #1a1a1a;
  --panel-2: #111214;
  --border: #2a2a2a;
  --border-strong: #3a4b44;
  --text: #d7d7d7;
  --text-soft: #c2c7cc;
  --muted: #a9aeb3;
  --muted-2: #8f9499;
  --brand: #7fc9a8;
  --accent: #ffd76b;
  --warn: #f0a055;
  --danger: #d97070;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
}

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

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  max-width: none;
  min-height: 100vh;
  padding: 24px 28px 80px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" 1, "calt" 1;
}

h1 {
  color: #f0f0f0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.12;
  margin: 0 0 6px;
}

h2.part {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 42px 0 8px;
}

h3.sec,
.chart-title,
.section-h {
  color: #e6e6e6;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 6px;
}

p.sub {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  margin-bottom: 12px;
  max-width: 1080px;
}

p.sub b,
p.intro b,
.reading-guide b {
  color: var(--text);
  font-weight: 600;
}

p.intro,
p.section-sub {
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 10px;
  max-width: 1080px;
}

code,
.mono,
.tag,
.tagcell,
td.num,
th.num,
td.lead,
th.lead,
.badge,
.toolbar select,
.toolbar input[type=text],
.toolbar button,
select,
input[type=text],
button {
  font-family: var(--mono);
}

code {
  background: #20201a;
  border-radius: 4px;
  color: #cbb86b;
  font-size: 12.5px;
  padding: 1px 5px;
}

.hl,
.ok {
  color: var(--brand);
}

.warn {
  color: var(--warn);
}

.ok,
.warn,
.hl,
.ours {
  font-weight: 600;
}

.ours {
  color: var(--accent);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

[data-tip] {
  border-bottom: 1px dotted #6a7d74;
  cursor: help;
  position: relative;
}

[data-tip][data-tip-unstyled="1"] {
  border-bottom: 0;
}

[data-tip]:hover::after {
  background: #0c0d0f;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  bottom: calc(100% + 7px);
  box-shadow: var(--shadow);
  color: #e3e6ea;
  content: attr(data-tip);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 400;
  left: 0;
  letter-spacing: 0;
  line-height: 1.5;
  max-width: 320px;
  padding: 8px 11px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  white-space: normal;
  width: max-content;
  z-index: 50;
}

[data-tip]:focus-visible::after {
  background: #0c0d0f;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  bottom: calc(100% + 7px);
  box-shadow: var(--shadow);
  color: #e3e6ea;
  content: attr(data-tip);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 400;
  left: 0;
  letter-spacing: 0;
  line-height: 1.5;
  max-width: 320px;
  padding: 8px 11px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  white-space: normal;
  width: max-content;
  z-index: 50;
}

[data-tip]:hover::before {
  border: 5px solid transparent;
  border-top-color: var(--border-strong);
  bottom: calc(100% + 2px);
  content: '';
  left: 9px;
  pointer-events: none;
  position: absolute;
  z-index: 51;
}

[data-tip]:focus-visible::before {
  border: 5px solid transparent;
  border-top-color: var(--border-strong);
  bottom: calc(100% + 2px);
  content: '';
  left: 9px;
  pointer-events: none;
  position: absolute;
  z-index: 51;
}

th[data-tip] {
  border-bottom: 1px dotted #555;
}

.shared-tooltips-ready [data-tip]:hover::after,
.shared-tooltips-ready [data-tip]:hover::before,
.shared-tooltips-ready [data-tip]:focus-visible::after,
.shared-tooltips-ready [data-tip]:focus-visible::before {
  content: none !important;
  display: none !important;
}

#dashboard-shell-tooltip {
  background: #0c0d0f;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: #e3e6ea;
  display: none;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 400;
  left: 0;
  line-height: 1.5;
  max-width: min(420px, calc(100vw - 20px));
  padding: 8px 11px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  top: 0;
  width: max-content;
  z-index: 20000;
}

#dashboard-shell-tooltip .hdr {
  border-bottom: 1px solid var(--border);
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  padding-bottom: 4px;
  text-transform: uppercase;
}

#dashboard-shell-tooltip .tip-body {
  display: grid;
  gap: 4px;
}

#dashboard-shell-tooltip .tip-line {
  break-inside: avoid;
  color: #e3e6ea;
  white-space: normal;
}

#dashboard-shell-tooltip.many-lines {
  max-width: min(620px, calc(100vw - 20px));
}

#dashboard-shell-tooltip.many-lines .tip-body {
  column-count: 2;
  column-gap: 18px;
  display: block;
}

#dashboard-shell-tooltip.many-lines .hdr {
  column-span: all;
}

.xnav {
  align-items: center;
  backdrop-filter: blur(10px);
  background: rgba(17, 17, 17, 0.96);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: -24px -28px 18px;
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 999;
}

.xnav-group {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 12px;
  position: relative;
}

.xnav-group::before {
  background: var(--border);
  content: '';
  height: 18px;
  left: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
}

.xnav-group-label {
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-right: 2px;
  text-transform: uppercase;
}

.xnav-link {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--brand);
  display: inline-flex;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  min-height: 30px;
  padding: 0 10px;
  text-decoration: none;
  white-space: nowrap;
}

.xnav-link:hover {
  background: #1f2522;
  border-color: #263430;
  text-decoration: none;
}

.xnav-link[aria-current="page"] {
  background: #25312c;
  border-color: #345245;
  color: #f3f6f4;
}

.xnav-sep {
  color: #4f5552;
  display: none;
  font-size: 11px;
  user-select: none;
}

@media (max-width: 720px) {
  .xnav {
    align-items: stretch;
  }

  .xnav-group {
    padding-left: 0;
    width: 100%;
  }

  .xnav-group::before {
    display: none;
  }
}

#nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

#hw-badge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
  margin-left: auto;
  padding: 4px 11px;
}

.meta-bar,
.toolbar,
#filter-bar,
#curves-filter,
#chart-mode-bar,
#scatter-controls,
#run-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.meta-bar,
.toolbar,
#filter-bar,
#curves-filter,
#chart-mode-bar,
#run-legend {
  margin-bottom: 14px;
}

.f-field,
#curves-filter .f-field,
#filter-bar > div,
#scatter-controls > div {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

label,
#filter-bar label,
#curves-filter label,
#scatter-controls label,
#run-legend .chip-label,
#chart-mode-bar .chip-label {
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 12px;
}

select,
input[type=text],
button,
.legend-btn,
.legend-btn-misc,
#scatter-render-btn,
#curves-filter .f-reset {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  color: #c7c7c7;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 9px;
}

select:focus,
input[type=text]:focus,
button:focus-visible,
.legend-btn:focus-visible,
.legend-btn-misc:focus-visible,
#scatter-render-btn:focus-visible,
#curves-filter .f-reset:focus-visible {
  outline: 1px solid var(--brand);
  outline-offset: 1px;
}

button:hover,
.legend-btn:hover,
.legend-btn-misc:hover,
#scatter-render-btn:hover,
#curves-filter .f-reset:hover {
  border-color: #4a4a4a;
  color: #e5e5e5;
}

.badge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  padding: 4px 10px;
}

.badge.ok {
  border-color: var(--brand);
  color: var(--brand);
}

.badge.warn {
  border-color: var(--warn);
  color: var(--warn);
}

.badge.note {
  border-color: #555;
  color: #aaa;
}

.section,
#scatter-section,
#viz-cards-section,
#topology-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 22px;
  padding: 18px 20px 20px;
}

.chart-box,
#scatter-plot {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px 6px 4px;
}

.tbl-wrap,
#summary-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  font-size: 12.5px;
  white-space: nowrap;
  width: 100%;
}

.dashboard-spatial #summary-table {
  font-size: 11.5px;
}

.dashboard-spatial #summary-table th,
.dashboard-spatial #summary-table td {
  font-family: var(--mono);
}

.dashboard-spatial #summary-table th {
  padding: 4px 12px 4px 0;
}

.dashboard-spatial #summary-table td {
  padding: 3px 12px 3px 0;
}

thead tr {
  border-bottom: 1px solid #333;
}

th {
  color: #9aa0a6;
  font-family: var(--sans);
  font-weight: 500;
  padding: 7px 14px 7px 0;
  text-align: left;
  vertical-align: bottom;
}

td {
  color: #c2c2c2;
  padding: 6px 14px 6px 0;
  vertical-align: middle;
}

tr:hover td {
  background: #212121;
}

th.num,
td.num,
td.lead {
  padding-right: 18px;
  text-align: right;
}

th.lead {
  color: #cbb86b;
  font-weight: 700;
}

td.lead {
  font-size: 14.5px;
  font-weight: 700;
}

th[data-col],
th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}

th[data-col]:hover,
th[data-sort-key]:hover {
  color: #ddd;
}

th[data-col]::after {
  color: #444;
  content: ' ↕';
  font-size: 9px;
}

th[data-col].sort-asc::after {
  color: var(--brand);
  content: ' ↑';
}

th[data-col].sort-desc::after {
  color: var(--brand);
  content: ' ↓';
}

.legend-note,
#summary-line,
#status,
#subtitle,
#footer,
.cap,
#table-note,
#fair-cap-notice {
  color: var(--muted-2);
  font-family: var(--sans);
}

#status,
#summary-line {
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 12px;
  min-height: 1em;
}

#status.err,
#scatter-error {
  color: var(--danger);
}

.takeaway,
.reading-guide {
  background: #14201b;
  border-left: 3px solid #2c5a44;
  border-radius: 0 6px 6px 0;
  color: #d6e3dd;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  margin: 10px 0;
  padding: 10px 14px;
}

.caveat {
  background: #1d1a14;
  border-left: 3px solid #4a3a18;
  border-radius: 0 6px 6px 0;
  color: #d2d2d2;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  margin: 10px 0;
  padding: 10px 14px;
}

.custom-hover {
  background: #0c0d0f;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
  color: #e3e6ea;
  display: none;
  font-family: var(--mono);
  font-size: 11px;
  min-width: 250px;
  padding: 7px 12px;
  pointer-events: none;
  position: fixed;
  z-index: 10000;
}

.custom-hover .hdr {
  border-bottom: 1px solid var(--border);
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
  padding-bottom: 4px;
  text-transform: uppercase;
}

.custom-hover .row {
  align-items: center;
  break-inside: avoid;
  display: flex;
  gap: 10px;
  margin: 2px 0;
}

.custom-hover .row .dot {
  border-radius: 50%;
  flex: none;
  height: 8px;
  width: 8px;
}

.custom-hover .row .tag {
  color: #ccc;
  flex: 1;
  min-width: 120px;
}

.custom-hover .row .val {
  color: #fff;
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}

.custom-hover .row.leader .tag,
.custom-hover .row.leader .val {
  color: var(--brand);
}

.hoverlayer .legend,
.hoverlayer .hoverlabel {
  display: none !important;
}

@media (max-width: 900px) {
  .chart-row,
  .curve-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  body {
    padding: 20px 16px 64px;
  }

  h1 {
    font-size: 24px;
  }

  h2.part {
    font-size: 20px;
    margin-top: 34px;
  }

  .xnav {
    gap: 4px;
    margin: -20px -16px 16px;
    padding: 10px 12px;
  }

  .xnav-link {
    font-size: 11.5px;
    min-height: 28px;
    padding: 0 8px;
  }

  .xnav-sep {
    display: none;
  }

  .section,
  #scatter-section,
  #viz-cards-section,
  #topology-section {
    padding: 14px;
  }
}
