:root {
  --bg: #eef4fb;
  --bg-strong: #e3ecf7;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --ink: #17243b;
  --muted: #64748b;
  --line: #d5e1ef;
  --accent: #3b82f6;
  --accent-deep: #1d4ed8;
  --accent-soft: #e8f1ff;
  --olive: #0f766e;
  --shadow: 0 18px 48px rgba(45, 76, 120, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(125, 173, 255, 0.2) 0, transparent 28%),
    radial-gradient(circle at 86% 10%, rgba(91, 203, 211, 0.13) 0, transparent 24%),
    linear-gradient(180deg, #f8fbff 0, var(--bg) 100%);
}

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
}

.sidebar {
  padding: 32px 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0, rgba(243, 248, 254, 0.95) 100%);
  border-right: 1px solid rgba(148, 163, 184, 0.28);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  backdrop-filter: blur(14px);
}

.content {
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view-stack,
.sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
}

.hero-note {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 52ch;
}

.hero-stats {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
}

.hero-stats strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat-label,
.eyebrow,
label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 11px;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  color: var(--muted);
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 38px;
  line-height: 0.98;
}

h2 {
  font-size: 31px;
  line-height: 1.08;
}

h3 {
  font-size: 19px;
  margin-bottom: 10px;
}

.intro {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.58;
  font-size: 15px;
}

.related-dashboard-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--accent-deep);
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 13px;
  font-weight: 700;
  text-decoration-color: rgba(29, 78, 216, 0.34);
  text-underline-offset: 4px;
}

.related-dashboard-link:hover,
.related-dashboard-link:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
}

.mode-switch-button {
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mode-switch-button[aria-pressed="true"] {
  color: var(--accent-deep);
  background: var(--panel-solid);
  box-shadow: 0 3px 12px rgba(45, 76, 120, 0.12);
}

.mode-switch-button:focus-visible,
.source-button:focus-visible,
.swap-button:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.28);
  outline-offset: 2px;
}

.controls,
.meta,
.detail-panel {
  padding: 18px;
}

.controls {
  display: grid;
  gap: 10px;
}

select,
input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.46);
  background: var(--panel-solid);
  color: var(--ink);
  font-size: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

select:focus,
input[type="text"]:focus,
textarea:focus {
  outline: 2px solid rgba(59, 130, 246, 0.18);
  border-color: var(--accent);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  min-height: 74px;
  resize: vertical;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.compare-source-card {
  display: grid;
  gap: 10px;
  padding: 17px;
}

.compare-source-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 2px;
}

.compare-source-heading strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.compare-source-letter {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-weight: 800;
}

.compare-source-letter-target {
  background: rgba(15, 118, 110, 0.12);
  color: var(--olive);
}

.compare-source-actions,
.comparison-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.source-button,
.swap-button {
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-radius: 13px;
  padding: 9px 11px;
  background: var(--panel-solid);
  color: var(--ink);
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.source-button {
  flex: 1;
}

.source-button-primary {
  border-color: rgba(59, 130, 246, 0.3);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.swap-button {
  width: 100%;
  background: rgba(248, 251, 255, 0.9);
}

.source-feedback {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.source-help {
  margin: -1px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.source-feedback-error {
  color: #a43f2d;
}

.meta dl,
.detail-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 8px 12px;
}

.meta dt,
.detail-grid dt {
  color: var(--muted);
  font-size: 13px;
}

.meta dd,
.detail-grid dd {
  margin: 0;
  font-weight: 700;
}

.chart-panel {
  padding: 18px;
  min-height: 760px;
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.chart-toolbar-actions {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.chart-range {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-radius: 999px;
  background: rgba(237, 244, 252, 0.88);
}

.chart-range-button {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.chart-range-button[aria-pressed="true"] {
  background: var(--panel-solid);
  color: var(--accent-deep);
  box-shadow: 0 2px 8px rgba(45, 76, 120, 0.12);
}

.chart-range-button:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.28);
  outline-offset: 1px;
}

.toolbar-copy strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
  align-items: flex-end;
}

.legend-controls,
.legend-chip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-panel {
  padding: 18px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.table-toolbar-modal {
  margin-bottom: 18px;
}

.table-button {
  border: 1px solid rgba(148, 163, 184, 0.46);
  background: var(--panel-solid);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  cursor: pointer;
}

.table-button-secondary {
  background: rgba(248, 251, 255, 0.96);
}

.table-scroll {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0, rgba(242, 247, 253, 0.9) 100%);
  max-height: 420px;
}

.table-scroll-modal {
  max-height: calc(100vh - 150px);
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  text-align: left;
  white-space: nowrap;
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(240, 246, 253, 0.98);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
}

.data-table tbody tr:nth-child(even) td {
  background: rgba(247, 250, 254, 0.72);
}

.table-title-cell {
  min-width: 320px;
  white-space: normal;
  line-height: 1.45;
}

.table-empty {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 24px;
}

.comparison-hero {
  border-color: rgba(59, 130, 246, 0.34);
}

.comparison-alerts {
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 18px;
  box-shadow: none;
}

.comparison-alert {
  padding-left: 18px;
  position: relative;
  color: #785b24;
  font-size: 13px;
  line-height: 1.45;
}

.comparison-alert::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.45em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c78a22;
}

.comparison-alert-error {
  color: #9b3022;
}

.comparison-alert-error::before {
  background: #c34c38;
}

.comparison-table-panel {
  min-height: 610px;
}

.comparison-table-scroll {
  max-height: calc(100vh - 270px);
  min-height: 460px;
}

.comparison-table th:nth-child(n + 3),
.comparison-table td:nth-child(n + 3) {
  text-align: right;
}

.comparison-table .comparison-summary-row td {
  font-weight: 800;
  background: rgba(59, 130, 246, 0.08);
}

.comparison-group-cell {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comparison-missing {
  color: #94a3b8;
}

.diff-positive {
  color: #227252;
  font-weight: 800;
}

.diff-negative {
  color: #ad3e2d;
  font-weight: 800;
}

.diff-data-bar {
  position: relative;
  isolation: isolate;
  --diff-bar-origin: 18%;
}

.diff-data-bar::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: var(--diff-bar-left);
  width: var(--diff-bar-width);
  min-width: 2px;
  border-radius: 2px;
}

.diff-data-bar::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: var(--diff-bar-origin);
  width: 1px;
  background: rgba(100, 116, 139, 0.42);
}

.diff-positive.diff-data-bar::before {
  border: 1px solid rgba(34, 197, 94, 0.58);
  background: linear-gradient(90deg, rgba(74, 201, 122, 0.58), rgba(134, 239, 172, 0.28));
}

.diff-negative.diff-data-bar::before {
  border: 1px solid rgba(239, 68, 68, 0.68);
  background: linear-gradient(90deg, rgba(252, 165, 165, 0.42), rgba(239, 68, 68, 0.7));
}

.comparison-actions {
  justify-content: flex-end;
}

.comparison-actions .table-button[aria-pressed="true"] {
  border-color: rgba(59, 130, 246, 0.38);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(248, 251, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.34);
  color: var(--ink);
  font-size: 12px;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  cursor: pointer;
}

button.legend-chip,
.legend-action {
  appearance: none;
}

.legend-chip-hidden {
  opacity: 0.45;
  background: rgba(237, 244, 252, 0.86);
}

.legend-action {
  border: 1px solid rgba(148, 163, 184, 0.46);
  background: var(--panel-solid);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  cursor: pointer;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.chart-frame {
  width: 100%;
  height: 720px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0, rgba(242, 247, 253, 0.9) 100%);
  border: 1px solid rgba(148, 163, 184, 0.28);
  overflow: hidden;
}

.chart-panel:fullscreen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 22px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.98);
}

.chart-panel:fullscreen .chart-frame {
  height: calc(100vh - 110px);
}

#chart {
  width: 100%;
  height: 100%;
  display: block;
}

.axis,
.grid {
  stroke: rgba(100, 116, 139, 0.24);
  stroke-width: 1;
}

.grid {
  stroke-dasharray: 4 7;
}

.series-path {
  fill: none;
  stroke-width: 3.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-path.secondary {
  opacity: 0.84;
}

.point {
  cursor: pointer;
  transition: opacity 120ms ease;
}

.point-core {
  stroke-width: 2.5;
  transition: opacity 140ms ease;
}

.point-halo {
  fill-opacity: 0.16;
  opacity: 0;
  transition: opacity 140ms ease;
}

.point.active .point-halo,
.point:hover .point-halo {
  opacity: 1;
}

#chart.dense-points .point-core {
  opacity: 0.64;
}

#chart.dense-points .point.active .point-core,
#chart.dense-points .point:hover .point-core {
  opacity: 1;
}

.tick,
.value-label,
.tooltip-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

.tooltip-card {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(148, 163, 184, 0.58);
  stroke-width: 1;
}

.tooltip-title {
  fill: var(--ink);
  font-size: 12px;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-weight: 700;
}

.tooltip-value {
  fill: var(--accent-deep);
  font-size: 14px;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-weight: 700;
}

.empty {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

.table-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
}

.table-modal.hidden {
  display: none;
}

.table-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 36, 48, 0.42);
  backdrop-filter: blur(8px);
}

.table-modal-sheet {
  position: relative;
  width: min(1400px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  padding: 22px;
  border-radius: 28px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 26px 80px rgba(30, 58, 95, 0.22);
}

body.modal-open {
  overflow: hidden;
}

.detail-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.22);
  text-decoration: none;
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 13px;
}

a {
  color: var(--accent);
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  font-family: "IBM Plex Mono", "Menlo", monospace;
}

@media (max-width: 1080px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  }
}

@media (max-width: 900px) {
  .content {
    padding: 18px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-toolbar {
    flex-direction: column;
  }

  .chart-legend {
    justify-content: flex-start;
    align-items: flex-start;
  }

  .legend-controls,
  .legend-chip-list {
    justify-content: flex-start;
  }

  .chart-toolbar-actions {
    width: 100%;
    flex-direction: column;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .comparison-actions {
    justify-content: flex-start;
  }

  .comparison-table-scroll {
    max-height: none;
  }

  .table-modal-sheet {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
    padding: 16px;
  }
}
