/* ==========================================================================
   UUID Benchmark Dashboard — Editorial Monochrome
   IBM Plex Serif (display) + JetBrains Mono (data)
   Full-bleed rules & background bands · FT-inspired layout structure
   No radius · No shadows · Only color comes from benchmark data.
   ========================================================================== */

/* --- 1. Custom Properties (Design Tokens) -------------------------------- */
:root {
  --bg:             #ffffff;
  --bg-off:         #f7f7f7;
  --bg-dark:        #eeeeee;
  --border:         #cccccc;
  --border-strong:  #333333;
  --text:           #111111;
  --text-mid:       #444444;
  --text-muted:     #888888;
  --text-faint:     #bbbbbb;

  --font-serif:     "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-mono:      "JetBrains Mono", "Courier New", Courier, monospace;
  --max-width:      min(1440px, calc(100vw - 48px));
  --touch-target:   44px;

  /* Spacing scale (4px increments) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* Key type colors */
  --key-sequential:      #78716c;
  --key-objectid:        #a16207;
  --key-uuidv1:          #be123c;
  --key-uuidv4:          #1d4ed8;
  --key-uuidv7:          #047857;
  --key-ulid:            #7e22ce;
  --key-ulid-monotonic:  #a855f7;

  /* Database colors */
  --db-postgres:   #336791;
  --db-mysql:      #00758f;
  --db-mongodb:    #116149;
  --db-cassandra:  #1287B1;

}

/* --- 2. Reset & Base ----------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

select {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 5px 8px;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 20px;
}

select:focus {
  outline: 1px solid var(--border-strong);
  outline-offset: -1px;
}

a { color: var(--text-muted); text-decoration: none; }
a:hover, a:active { color: var(--text); }

/* --- 3. Full-Bleed Band System ------------------------------------------- */
/* FT-inspired: decoration (borders, backgrounds) bleeds to viewport edges.
   Content stays constrained inside .band-content. */

.band {
  width: 100%;
  background: var(--bg);
}

.band--off {
  background: var(--bg-off);
}

.band--header {
  border-bottom: 1px solid var(--border-strong);
}

.band--nav {
  border-bottom: 1px solid var(--border);
}

.band--footer {
  border-top: 1px solid var(--border-strong);
}

.band--border-bottom {
  border-bottom: 1px solid var(--border);
}

.band--border-top {
  border-top: 1px solid var(--border);
}

.band-content {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* --- 4. Page Shell ------------------------------------------------------- */

/* Header */
.site-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.site-brand {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}

.site-divider {
  color: var(--border);
  font-weight: 300;
  font-size: 18px;
}

.site-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Navigation */
.main-nav {
  display: flex;
  gap: 0;
}

.nav-tab {
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
}

.nav-tab:hover,
.nav-tab:active {
  color: var(--text-mid);
}

.nav-tab.active {
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

.nav-tab.active::before {
  content: '';
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  margin-right: 6px;
  flex-shrink: 0;
}

.nav-tab:first-child { padding-left: 0; }

/* Footer */
.site-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 14px;
  padding-bottom: 14px;
  font-size: 10px;
  color: var(--text-faint);
}

.footer-link {
  color: var(--text-faint);
}

.footer-link:hover,
.footer-link:active {
  color: var(--text-muted);
}

/* View panels */
.view-panel[hidden] {
  display: none;
}

/* --- 5. Summary View ----------------------------------------------------- */

/* Methodology banner */
.methodology-banner {
  padding: 10px 0;
  font-size: 11px;
  color: var(--text-muted);
}

.methodology-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.methodology-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 6px;
  margin-left: 8px;
}

.methodology-toggle::before {
  content: '';
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.methodology-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.methodology-toggle:hover,
.methodology-toggle:active {
  color: var(--text);
}

.methodology-detail {
  padding: 12px 0;
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.6;
}

.methodology-detail h3 {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-top: 12px;
  margin-bottom: 4px;
}

.methodology-detail h3:first-child {
  margin-top: 0;
}

.methodology-detail p {
  margin-bottom: 6px;
}

.methodology-detail code {
  background: var(--bg-off);
  padding: 1px 4px;
  font-size: 11px;
}

/* Methodology grid */
.method-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border);
}

.method-cell {
  background: var(--bg);
  padding: 12px 14px;
}

.method-cell h3 {
  margin-top: 0;
}

.method-dl {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.method-dl > div {
  display: flex;
  gap: 8px;
  line-height: 1.5;
}

.method-dl dt {
  flex-shrink: 0;
  width: 80px;
  color: var(--text-muted);
  font-size: 11px;
}

.method-dl dd {
  font-size: 11px;
  color: var(--text-mid);
}

/* Section labels — editorial serif */
.section-label {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text);
  margin-bottom: 16px;
}

/* KPI Cards */
.kpi-section {
  padding: 20px 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-off);
  padding: 18px;
  cursor: pointer;
  transition: background 0.15s;
}

.kpi-card:hover,
.kpi-card:active {
  background: var(--bg-dark);
}

.kpi-header {
  margin-bottom: 6px;
}

.kpi-icon {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.kpi-hero {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-context {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.kpi-spark {
  width: 100px;
  margin-top: auto;
}

.kpi-spark canvas {
  display: block;
  height: 36px;
  width: 100px;
}

.kpi-spark-labels {
  display: flex;
  justify-content: space-around;
  margin-top: 2px;
}

.kpi-spark-labels span {
  font-size: 8px;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.5px;
}

/* Database cards */
.db-section {
  padding: 20px 0;
}

.db-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.db-card {
  background: var(--bg);
  padding: 16px;
  border: none;
}

.db-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.db-card[data-db="postgres"] .db-name  { color: var(--db-postgres); }
.db-card[data-db="mysql"] .db-name     { color: var(--db-mysql); }
.db-card[data-db="mongodb"] .db-name   { color: var(--db-mongodb); }
.db-card[data-db="cassandra"] .db-name { color: var(--db-cassandra); }

.db-arch,
.db-tool {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.db-explore {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 0;
  margin-top: 6px;
}

.db-explore::before {
  content: '';
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  flex-shrink: 0;
}

.db-explore:hover,
.db-explore:active {
  color: var(--text);
}

/* Legend section */
.legend-section {
  padding: 16px 0 20px;
}

.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}

/* --- 6. Explorer View ---------------------------------------------------- */

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 0;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group[hidden] {
  display: none;
}

.filter-group label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Filter toggle (mobile only) */
.filter-toggle {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--sp-3) 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.filter-toggle-icon {
  display: inline-block;
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.filter-toggle[aria-expanded="true"] .filter-toggle-icon {
  transform: rotate(90deg);
}

.filter-toggle:hover,
.filter-toggle:active {
  color: var(--text);
}

/* Filter groups wrapper (desktop: flows inline; mobile: moved into modal) */
.filter-modal-groups {
  display: contents;
}

/* --- Filter Bottom-Sheet Modal ------------------------------------------- */

.filter-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1010;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.filter-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.filter-modal {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  background: var(--bg);
  border-top: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 250ms ease;
}

.filter-modal-overlay.active .filter-modal {
  transform: translateY(0);
}

.filter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-modal-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}

.filter-modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: color 120ms ease, border-color 120ms ease;
}

.filter-modal-close:hover,
.filter-modal-close:active {
  color: var(--text);
  border-color: var(--border-strong);
}

.filter-modal-body {
  padding: var(--sp-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.filter-modal-body .filter-group {
  width: 100%;
}

.filter-modal-body .filter-group select {
  width: 100%;
}

/* Explorer sub-tabs */
.explorer-tabs {
  display: flex;
  gap: 0;
  padding-top: 2px;
}

.explorer-tab {
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  min-height: 38px;
  display: flex;
  align-items: center;
}

.explorer-tab:hover,
.explorer-tab:active {
  color: var(--text-mid);
}

.explorer-tab.active {
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

.explorer-tab:first-child { padding-left: 0; }

/* Chart grid */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border);
  margin-top: 0;
}

.chart-panel {
  background: var(--bg);
  padding: 14px;
  position: relative;
  min-height: 200px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-metric-select {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  padding-right: 14px;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}

.panel-metric-select:hover,
.panel-metric-select:active {
  color: var(--text-mid);
}

.panel-metric-select:focus {
  outline: 1px solid var(--border-strong);
  outline-offset: 2px;
}

.panel-unit {
  font-size: 11px;
  color: var(--text-muted);
}

.panel-expand {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-faint);
  padding: 2px 4px;
  line-height: 1;
}

.panel-expand:hover,
.panel-expand:active {
  color: var(--text-muted);
}

.panel-chart {
  position: relative;
  height: 250px;
}

.panel-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- Chart Modal Overlay -------------------------------------------------- */

.chart-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.chart-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.chart-modal {
  width: min(92vw, 1360px);
  height: min(78vh, 720px);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  transform: scale(0.96);
  transition: transform 200ms ease;
}

.chart-modal-overlay.active .chart-modal {
  transform: scale(1);
}

.chart-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chart-modal-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}

.chart-modal-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

.chart-modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: color 120ms ease, border-color 120ms ease;
}

.chart-modal-close:hover,
.chart-modal-close:active {
  color: var(--text);
  border-color: var(--border-strong);
}

.chart-modal-body {
  flex: 1;
  padding: 16px;
  position: relative;
  min-height: 0;
}

.chart-modal-body canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Panel empty / N/A state */
.chart-panel.panel-empty .panel-chart {
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-na {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

.panel-na-dash {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

/* Mobile show all metrics toggle */
.show-all-metrics {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-top: -1px;
}

.show-all-metrics::after {
  content: '';
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  flex-shrink: 0;
}

.show-all-metrics:hover,
.show-all-metrics:active {
  color: var(--text);
  background: var(--bg-off);
}

.show-all-metrics[hidden] {
  display: none;
}

/* Annotation section */
.annotation-section {
  padding: 14px 0;
}

.annotation-section[hidden] {
  display: none;
}

.annotation-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.annotation-icon {
  font-size: 12px;
  color: var(--text-muted);
}

.annotation-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.annotation-nav {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  overflow: hidden;
}

.annotation-prev,
.annotation-next {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  transition: background 0.15s, color 0.15s;
}

.annotation-prev::before {
  content: '';
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M4 0L0 3L4 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M4 0L0 3L4 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  flex-shrink: 0;
}

.annotation-next::after {
  content: '';
  width: 4px;
  height: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 6'%3E%3Cpath d='M0 0L4 3L0 6Z'/%3E%3C/svg%3E") no-repeat center / contain;
  flex-shrink: 0;
}

.annotation-prev:hover,
.annotation-prev:active,
.annotation-next:hover,
.annotation-next:active {
  color: var(--text);
  background: var(--bg-off);
}

.annotation-prev:disabled,
.annotation-next:disabled {
  color: var(--text-faint);
  cursor: default;
  background: transparent;
}

.annotation-progress {
  font-size: 11px;
  color: var(--text-faint);
  padding: 4px 8px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  line-height: 1;
}

.annotation-finding {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 4px;
}

.annotation-explanation {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.5;
}

.annotation-none {
  font-size: 12px;
  color: var(--text-faint);
  font-style: normal;
}

/* No data state */
.no-data {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

.no-data[hidden] {
  display: none;
}

/* Metric info popover */
.metric-info-popover {
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 12px;
  max-width: 320px;
  z-index: 100;
  font-size: 11px;
  line-height: 1.5;
}

.metric-info-popover[hidden] {
  display: none;
}

.popover-definition {
  color: var(--text);
  margin-bottom: 6px;
}

.popover-measurement {
  color: var(--text-mid);
  white-space: pre-line;
}

.popover-close {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 2px;
}

.popover-close:hover,
.popover-close:active {
  color: var(--text);
}

.metric-info-btn {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
  vertical-align: middle;
}

.metric-info-btn:hover,
.metric-info-btn:active {
  color: var(--text);
}

/* --- 7. Raw Data View ---------------------------------------------------- */

.raw-filter-bar {
  margin-bottom: 0;
}

.table-scroll {
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  margin-top: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: var(--bg-off);
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table th.num {
  text-align: right;
}

.data-table th.sort-active {
  color: var(--text);
}

.sort-indicator {
  font-size: 9px;
  margin-left: 4px;
  color: var(--text-faint);
}

.sort-active .sort-indicator {
  color: var(--text);
}

.data-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:nth-child(even) {
  background: var(--bg-off);
}

.data-table tbody tr:hover,
.data-table tbody tr:active {
  background: var(--bg-dark);
}

/* Conditional formatting — monochrome only */
.cell-best {
  font-weight: 700;
  color: var(--border-strong);
}

.cell-worst {
  color: var(--text-muted);
}

.table-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- Raw Data Card Layout (Mobile) --------------------------------------- */

.raw-data-cards {
  display: none;
}

.raw-card {
  border: 1px solid var(--border);
  margin-top: -1px;
}

.raw-card-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 var(--sp-2);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-off);
  border-bottom: 1px solid var(--border);
}

.raw-card-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  grid-row: 1 / -1;
}

.raw-card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.raw-card-context {
  grid-column: 2;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.raw-card-body {
  padding: 0;
}

.raw-card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--sp-2) var(--sp-4);
  font-size: 13px;
  min-height: var(--touch-target);
  border-bottom: 1px solid var(--bg-dark);
}

.raw-card-row:last-child {
  border-bottom: none;
}

.raw-card-label {
  color: var(--text-muted);
}

.raw-card-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.raw-card-value.cell-best {
  font-weight: 700;
  color: var(--border-strong);
}

.raw-card-value.cell-worst {
  color: var(--text-muted);
}

/* --- 8. Animations ------------------------------------------------------- */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.view-panel {
  animation: fade-in 200ms ease both;
}

/* --- 9. Responsive: Tablet (768px+) ------------------------------------- */

@media (min-width: 768px) {
  .method-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

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

  .chart-panel .panel-chart {
    height: 270px;
  }

  .show-all-metrics {
    display: none;
  }
}

/* --- 10. Responsive: Desktop (1024px+) ---------------------------------- */

@media (min-width: 1024px) {
  .site-header {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .site-brand {
    font-size: 20px;
  }

  .chart-panel .panel-chart {
    height: 290px;
  }

  .kpi-hero {
    font-size: 34px;
  }

  .section-label {
    font-size: 20px;
  }
}

/* --- 11. Responsive: Large Display (1800px+) ----------------------------- */

@media (min-width: 1800px) {
  body {
    font-size: 13px;
  }

  select {
    font-size: 13px;
  }

  .site-brand {
    font-size: 22px;
  }

  .site-subtitle {
    font-size: 12px;
  }

  .nav-tab {
    font-size: 12px;
  }

  .section-label {
    font-size: 22px;
  }

  .kpi-hero {
    font-size: 38px;
  }

  .kpi-label {
    font-size: 12px;
  }

  .kpi-context {
    font-size: 12px;
  }

  .kpi-spark-labels span {
    font-size: 9px;
  }

  .db-name {
    font-size: 15px;
  }

  .db-arch, .db-tool {
    font-size: 12px;
  }

  .db-explore {
    font-size: 12px;
  }

  .legend-strip {
    font-size: 12px;
  }

  .filter-group label {
    font-size: 12px;
  }

  .explorer-tab {
    font-size: 12px;
  }

  .panel-metric-select {
    font-size: 12px;
  }

  .panel-unit {
    font-size: 12px;
  }

  .chart-panel .panel-chart {
    height: 300px;
  }

  .annotation-finding {
    font-size: 16px;
  }

  .annotation-explanation {
    font-size: 13px;
  }

  .data-table {
    font-size: 13px;
  }

  .data-table th {
    font-size: 12px;
  }

  .methodology-line {
    font-size: 12px;
  }

  .methodology-toggle {
    font-size: 12px;
  }

  .methodology-detail {
    font-size: 13px;
  }

  .methodology-detail h3 {
    font-size: 12px;
  }

  .method-dl dt {
    font-size: 12px;
    width: 90px;
  }

  .method-dl dd {
    font-size: 12px;
  }
}

/* --- 12. Reduced Motion -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- 13. Responsive: Mobile (<768px) — Typography & Touch Targets -------- */

@media (max-width: 767px) {
  body {
    font-size: 13px;
  }

  /* Interactive UI text: 14px minimum for tappable elements */
  .nav-tab,
  .explorer-tab,
  .methodology-toggle,
  .db-explore,
  .show-all-metrics,
  .annotation-prev,
  .annotation-next,
  .filter-group label {
    font-size: 14px;
  }

  select {
    font-size: 14px;
  }

  /* Section labels */
  .section-label {
    font-size: 18px;
  }

  /* KPI hero */
  .kpi-hero {
    font-size: 28px;
  }

  /* KPI context text */
  .kpi-context {
    font-size: 13px;
  }

  /* KPI label */
  .kpi-label {
    font-size: 13px;
  }

  /* Spark chart labels — minimum readable */
  .kpi-spark-labels span {
    font-size: 10px;
  }

  /* Legend strip */
  .legend-strip {
    font-size: 13px;
  }

  /* Annotation text */
  .annotation-finding {
    font-size: 14px;
  }

  .annotation-explanation {
    font-size: 13px;
  }

  /* Footer */
  .site-footer {
    font-size: 12px;
  }

  /* Methodology detail */
  .methodology-line {
    font-size: 13px;
  }

  .method-dl dt,
  .method-dl dd {
    font-size: 13px;
  }

  /* Panel metric select */
  .panel-metric-select {
    font-size: 13px;
  }

  .panel-unit {
    font-size: 13px;
  }

  /* DB card text */
  .db-name {
    font-size: 14px;
  }

  .db-arch,
  .db-tool {
    font-size: 13px;
  }

  /* Touch targets: 44px minimum height */
  .nav-tab {
    min-height: var(--touch-target);
    padding: var(--sp-3) var(--sp-4);
  }

  .explorer-tab {
    min-height: var(--touch-target);
    padding: var(--sp-3) var(--sp-4);
  }

  .methodology-toggle {
    min-height: var(--touch-target);
    padding: var(--sp-2) var(--sp-3);
  }

  .db-explore {
    min-height: var(--touch-target);
    padding: var(--sp-2) 0;
  }

  select {
    min-height: var(--touch-target);
    padding: var(--sp-2) var(--sp-3);
    padding-right: var(--sp-5);
  }

  .annotation-prev,
  .annotation-next {
    min-height: var(--touch-target);
    padding: var(--sp-2) var(--sp-3);
  }

  .annotation-progress {
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
  }

  .panel-expand {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .panel-metric-select {
    min-height: var(--touch-target);
  }

  .show-all-metrics {
    min-height: var(--touch-target);
  }

  .chart-modal-close {
    min-height: var(--touch-target);
    padding: var(--sp-2) var(--sp-3);
  }

  .popover-close {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .kpi-card {
    padding: var(--sp-4);
  }

  /* Filter modal: toggle + chips visible, inline groups hidden */
  .filter-toggle {
    display: flex;
  }

  .filter-modal-groups {
    display: none;
  }

  .filter-bar {
    flex-direction: column;
    gap: 0;
  }

  /* Raw data: cards instead of table */
  .table-scroll {
    display: none;
  }

  .table-footer {
    display: none;
  }

  .raw-data-cards {
    display: block;
  }
}

/* --- DB grid single-column on narrow screens ----------------------------- */

@media (max-width: 480px) {
  .db-grid {
    grid-template-columns: 1fr;
  }

}

/* --- 14. Responsive: Small Mobile (<=400px) ------------------------------ */

@media (max-width: 400px) {
  .kpi-icon {
    display: block;
    margin-right: 0;
    margin-bottom: 4px;
  }

  .kpi-label {
    display: block;
  }
}
