/* Ogólna przestrzeń między elementami */
.stats-tab {
  padding: 80px;
}

/* Pasek nawigacji (przyciski zakładek) — jeśli nieużywane, można skasować */
.stats-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5em;
  padding: 1em 0;
  border-bottom: 2px solid #eee;
}

.stats-tab-button {
  background-color: #f3f4f6;
  border: 1px solid #ccc;
  padding: 0.5em 1.2em;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: background-color 0.2s;
}

.stats-tab-button:hover {
  background-color: #e0e7ff;
}

.stats-tab-button.active {
  background-color: #4338ca;
  color: white;
  border-color: #4338ca;
}

/* Styl dla kafelków z liczbami */
.stats-metric-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5em;
  margin-top: 2em;
}

.stats-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.2em 2em;
  min-width: 180px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: 0.3s;
}

.stats-box:hover {
  background-color: #f3f4f6;
  transform: scale(1.02);
}

.stats-box h3 {
  font-size: 1.2em;
  margin-bottom: 0.3em;
  font-weight: 600;
  color: #374151;
}

.stats-box .value {
  font-size: 1.8em;
  font-weight: 700;
  color: #111827;
}

/* ─────────────── Podstawowe: rozbudowany dashboard ─────────────── */

.basic-dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-top: 1.2rem;
}
.basic-mini-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.basic-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.basic-card__header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}

.basic-card__header p {
  margin: 0.35rem 0 0;
  font-size: 0.93rem;
  line-height: 1.55;
  color: #64748b;
}

.basic-insights {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.basic-insight {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  line-height: 1.6;
  color: #334155;
}

.basic-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.basic-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

.basic-stat__label {
  font-size: 0.86rem;
  color: #64748b;
}

.basic-stat__value {
  margin-top: 0.2rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #111827;
}

.basic-stat__meta {
  margin-top: 0.2rem;
  font-size: 0.84rem;
  color: #64748b;
}

.basic-meta-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.basic-meta-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid #eef2f7;
}

.basic-meta-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.basic-meta-label {
  font-weight: 600;
  color: #64748b;
}

.basic-meta-value {
  color: #111827;
  word-break: break-word;
}

.basic-bars {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.95rem;
}

.basic-bar__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 0.75rem;
  align-items: center;
}

.basic-bar__main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
}

.basic-bar-label {
  display: inline-block;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #334155;
  font-weight: 600;
}

.basic-bar-tag {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.basic-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #eef2ff;
  overflow: hidden;
  position: relative;
}

.basic-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #4338ca);
}

.basic-bar-val {
  text-align: right;
  white-space: nowrap;
  font-size: 0.9rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.basic-bar-muted {
  color: #64748b;
}

.basic-empty {
  margin-top: 0.9rem;
  color: #64748b;
}

@media (max-width: 1280px) {
  .basic-dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .basic-mini-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .basic-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .basic-profile-grid {
    grid-template-columns: 1fr;
  }

  .basic-meta-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .basic-bar__row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .basic-bar-val {
    text-align: left;
  }
}

/* Styl dla tabel */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5em;
}

#cooccurrenceResults .stats-table {
  margin-top: 0.5em; /* ciaśniej niż globalne 1.5em */
}


.stats-table th,
.stats-table td {
  border: 1px solid #ddd;
  padding: 0.6em 1em;
  text-align: left;
}

.stats-table th {
  background-color: #f3f4f6;
  font-weight: 600;
  color: #111827;
}

.stats-table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

/* Styl eksportu */
.export-btn {
  margin-top: 1em;
  background-color: #2563eb;
  color: white;
  border: none;
  padding: 0.5em 1.2em;
  border-radius: 6px;
  cursor: pointer;
}

.export-btn:hover {
  background-color: #1d4ed8;
}

/* Zakładki w stopce */
.stats-footer-tabs {
  display: flex;
  justify-content: center;
  gap: 1em;
  margin-top: 0.5em;
}

footer .stats-tab-button {
  background-color: #f9fafb;
  border: 1px solid #ccc;
  padding: 0.4em 1.2em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95em;
  font-family: 'Inter', sans-serif;
}

footer .stats-tab-button.active {
  background-color: #4338ca;
  color: white;
  border-color: #4338ca;
}

/* Layout kolumn */
.tag-stats-container {
  display: flex;
  gap: 2em;
  align-items: flex-start;
  flex-wrap: nowrap;
}

/* Lewa kolumna — sticky (bez scrolla) */
.tag-list-column {
  position: sticky;
  top: 80px;                 /* dopasuj do wysokości headera */
  align-self: flex-start;
  background: white;
  z-index: 10;
  flex: 0 0 22%;
  max-width: 22%;
  min-width: 160px;
  box-shadow: 2px 0 0 rgba(0,0,0,0.04);
}

/* Scroll przeniesiony do wrappera */
.tag-list-scroll {
  max-height: calc(100vh - 100px); /* ≈ top (80) + marginesy */
  overflow-y: auto;
  padding-right: 4px;              /* miejsce na scrollbar */
}


.tag-details-column {
  flex: 1 1 auto;
  min-width: 200px;
  scroll-margin-top: 100px;
  padding-bottom: 120px; /* ✅ DODAJ TO */
}


/* Karty przykładów */
.annotation-card {
  background: #fdfdfd; /* jasny odcień, lekko ciemniejszy niż tło strony */
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1em;
  margin-bottom: 1em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); /* subtelny cień */
}
.annotation-header { font-size: 0.9em; color: #555; margin-bottom: 0.3em; }

.annotation-subheader {
  font-size: 0.9em;
  color: #555;
  margin: 0.6em 0 0.3em;
}


.annotation-segment { margin-bottom: 0.95em; font-style: italic; }

.stats-annotation-card {
  background: #fdfdfd;
}

.stats-card-header-icons {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stats-difficulty-badge {
  font-size: 1.05em;
  line-height: 1;
}

.stats-expert-open-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 1.02em;
  line-height: 1;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.stats-expert-open-btn:hover {
  opacity: 1;
}

.stats-expert-open-btn:active {
  transform: translateY(1px);
}

.stats-segment-translation,
.stats-annotation-translation {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0.15em 0 0.8em;
  color: #475569;
  font-size: 0.95em;
}

.stats-annotation-block {
  margin-top: 1.05em;
  padding: 1em 1.05em;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.stats-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 0.8em;
}

.stats-tag-i18n-chip {
  background: #eef2ff;
  color: #334155;
  border: 1px solid #c7d2fe;
}

.stats-annotation-text {
  font-size: 1em;
  color: #111827;
  line-height: 1.55;
}

.stats-relation-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0.85em;
}

.stats-relation-chip {
  float: none !important;
  margin-left: 0 !important;
  margin-top: 0 !important;

  background-color: #f0f0f0;
  color: #333;
  padding: 0.3em 0.6em;
  border-radius: 1em;
  font-size: 0.9em;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.22em;
  white-space: nowrap;
  border: 1px solid #d6dde8;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.stats-relation-chip .rel-id-badge {
  display: inline-block;
  font-size: 0.75em;
  line-height: 1.2;
  padding: 0.05em 0.55em;
  margin-right: 0.3em;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  vertical-align: middle;
}

.stats-relation-chip .rel-arrow {
  font-weight: 600;
  margin-left: 4px;
  margin-right: 0.18em;
}

.stats-relation-chip .rel-peer-id {
  display: inline-block;
  font-size: 0.78em;
  line-height: 1;
  color: #8795a8;
  font-weight: 600;
  letter-spacing: 0.01em;
  vertical-align: middle;
}

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

.annotation-rationale-toggle.stats-rationale-open {
  margin-left: 0.12em;
}


/* ─────────────────────────────────────────────
   Wspólna skórka tabel po lewej (Tagi + Relacje)
   ───────────────────────────────────────────── */

.list-table {
  width: 100%;
  table-layout: fixed;         /* stabilny układ bez falowania */
  border-collapse: separate;   /* pozwala ładnie zaokrąglić */
  border-spacing: 0;
  border-radius: 10px;
  overflow: hidden;            /* maskuje rogi */
  font-size: 15px;             /* typografia jak w Relacjach */
}

.list-table th,
.list-table td {
  border: 1px solid #e5e7eb;   /* delikatniejsza siatka */
  padding: 0.65em 1em;
}

.list-table th {
  background: #f3f4f6;
  font-weight: 600;
  color: #111827;              /* kolor nagłówka jak w Relacjach */
}

/* pełny wiersz klikalny + hover/active/focus */
.list-table tbody tr {
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}

.list-table tbody tr:hover td { background: #f3f6ff; }
.list-table tbody tr.active td { background: #e8edff; border-color: #c7d2fe; }
.list-table tbody tr:focus-visible td {
  outline: 2px solid #93c5fd;
  outline-offset: -2px;
}

/* komórki: nazwa + liczba (ta sama szerokość w Tagach i Relacjach) */
.list-name {
  color: #2563eb;
  font-weight: 500;
  overflow-wrap: break-word;
  word-break: normal;
}
.list-count {
  width: 96px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* (opcjonalnie) węższa kolumna po lewej */
.tag-list-column, {
  flex: 0 0 22%;
  max-width: 22%;
  min-width: 200px;
}

/* Tagi potrzebują wyraźnie więcej miejsca niż relacje */
.tag-stats-container .tag-list-column {
  flex: 0 0 460px;
  max-width: 460px;
  min-width: 460px;
}

.relation-stats-container {
  display: flex;
  gap: 2em;
  align-items: flex-start;
  flex-wrap: nowrap;
}

/* lewa kolumna */
.relation-list-column {
  position: sticky;
  top: 80px;
  align-self: flex-start;
  background: white;
  z-index: 10;
  flex: 0 0 420px;
  max-width: 420px;
  min-width: 420px;
  box-shadow: 2px 0 0 rgba(0,0,0,0.04);
}

.relation-list-scroll {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 4px;
}


/* prawa kolumna */
.relation-details-column {
  flex: 1 1 auto;
  min-width: 280px;
  scroll-margin-top: 100px;
}

/* Strzałka kierunku w karcie relacji */
.rel-direction {
  text-align: center;
  color: #6b7280;
  margin: 0.4em 0 0.6em;
  font-weight: 600;
}

/* delikatne wyszarzenie notki, gdy brak ID anotacji */
.annot-muted {
  color: #6b7280;
  font-style: italic;
}

/* opcjonalny, neutralny badge */
.inline-tag.muted {
  background-color: #eef2ff;
  color: #334155;
}

/* Połączenie między członami relacji */
.rel-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.6em 0;
  color: #6b7280; /* neutralny szary */
  font-size: 1.2em;
  font-weight: 600;
  gap: 0.5em;
}

.rel-line {
  flex: 1;
  height: 1px;
  background-color: #d1d5db; /* jasna szarość */
}

.rel-arrow {
  flex: 0;
  font-size: 1.3em;
  color: #374151; /* ciemniejszy akcent */
}
.rel-connector.labeled {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.6rem 0;
  color: #374151;
}
.rel-connector.labeled .rel-line {
  flex: 1;
  height: 1px;
  background-color: #e5e7eb;
}
.rel-connector.labeled .rel-arrow {
  font-size: 1.2em;
  font-weight: 600;
  color: #374151;
}

/* Styl dla dropdownów w zakładce Współwystępowanie */
#coTag1, #coTag2 {
  appearance: none;              /* usuń natywną strzałkę */
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.4em 1.8em 0.4em 0.8em;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  background-size: 0.8em;
}

#coTag1:hover, #coTag2:hover {
  border-color: #6366f1;
}

#coTag1:focus, #coTag2:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Styl dla przycisku Policz */
#countCooccurrenceBtn {
  background: #eef4fb;
  border: 1px solid #cddff5;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #0b3a67;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

#countCooccurrenceBtn:hover {
  background: #e1edfa;
  border-color: #80bfff;
  color: #083256;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.12);
}

#oneTagReport .stats-table td,
#oneTagReport .stats-table th { white-space: nowrap; }

#oneTagSelect {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.4em 1.8em 0.4em 0.8em;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  background-size: 0.8em;
}
#oneTagSelect:hover { border-color: #6366f1; }
#oneTagSelect:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.list-rank {
  width: 36px;
  text-align: right;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.list-pct {
  width: 90px;
  text-align: right;
  color: #374151;
  font-variant-numeric: tabular-nums;
}
/* ─── Tagi: szerokości kolumn (nr / etykieta / Nb. / %) ─── */
.list-table {
  table-layout: fixed;          /* stabilne szerokości */
}

/* lokalnie dla zakładki Tagi */
#tab-tags .list-table th:nth-child(1),
#tab-tags .list-table td:nth-child(1) {
  width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#tab-tags .list-table th:nth-child(2),
#tab-tags .list-table td:nth-child(2) {
  width: 100%;
}

#tab-tags .list-table th:nth-child(3),
#tab-tags .list-table td:nth-child(3) {
  width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#tab-tags .list-table th:nth-child(4),
#tab-tags .list-table td:nth-child(4) {
  width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* trochę ciaśniejsze komórki, żeby zyskać miejsce */
.list-table th,
.list-table td {
  padding: 0.55em 0.8em;
}

@media (max-width: 1100px) {
  #tab-tags .list-table th:nth-child(1),
  #tab-tags .list-table td:nth-child(1) { width: 32px; }

  #tab-tags .list-table th:nth-child(2),
  #tab-tags .list-table td:nth-child(2) { width: 100%; }

  #tab-tags .list-table th:nth-child(3),
  #tab-tags .list-table td:nth-child(3) { width: 60px; }

  #tab-tags .list-table th:nth-child(4),
  #tab-tags .list-table td:nth-child(4) { width: 56px; }

  #tab-relations .list-table th:nth-child(1),
  #tab-relations .list-table td:nth-child(1) { width: 32px; }

  #tab-relations .list-table th:nth-child(2),
  #tab-relations .list-table td:nth-child(2) { width: 100%; }

  #tab-relations .list-table th:nth-child(3),
  #tab-relations .list-table td:nth-child(3) { width: 60px; }

  #tab-relations .list-table th:nth-child(4),
  #tab-relations .list-table td:nth-child(4) { width: 56px; }
}

/* ───────────────  ASOCJACJE (stylowanie)  ─────────────── */

#assocPanel { padding: 0.75rem 0; }

.assoc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  margin: 6px 0 14px;
}

/* spójne selecty jak w „Współwystępowaniu” */
#assocTagA, #assocTagB {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 1.9rem 0.45rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6em center;
  background-size: .8em;
  min-width: 320px;            /* szerokość zbliżona do selectów w Tagach */
}
#assocTagA:hover, #assocTagB:hover { border-color: #6366f1; }
#assocTagA:focus, #assocTagB:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99,102,241,.3);
}

/* przycisk „Policz” – jak w Twoich lekkich przyciskach */
#assocBtn {
  background: #eef4fb;
  border: 1px solid #cddff5;
  border-radius: 8px;
  padding: .45rem .95rem;
  font-size: .95rem;
  font-family: 'Inter', sans-serif;
  color: #0b3a67;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}
#assocBtn:hover {
  background: #e1edfa;
  border-color: #80bfff;
  color: #083256;
  box-shadow: 0 0 0 2px rgba(0,123,255,.12);
}

/* kafelki metryk (N, nA, nB, nAB itd.) */
#assocMetrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 12px 0 6px;
}
.assoc-metric {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.assoc-metric .label { font-size: .92rem; color: #475569; }
.assoc-metric .value {
  margin-top: 2px;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.2;
  color: #111827;
}

/* tabela wynikowa z miarami */
#assocResults .stats-table {
  margin-top: 10px;
}
#assocResults .stats-table th,
#assocResults .stats-table td {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
#assocResults .stats-table th:first-child,
#assocResults .stats-table td:first-child {
  text-align: left;            /* pierwsza kolumna – nazwa miary */
  width: 40%;
}

#assocHeatmap table td {
  min-width: 40px;
  text-align: right;
  font-weight: 500;
  transition: background 0.3s;
}
#assocHeatmap table th {
  position: sticky;
  top: 0;
  background: #f0f4ff;
  z-index: 1;
}

#assocPctHeatmap table td {
  min-width: 40px;
  text-align: right;
  font-weight: 500;
  transition: background 0.3s;
}
#assocPctHeatmap table th {
  position: sticky;
  top: 0;
  background: #f0f4ff;
  z-index: 1;
}

/* ——— Kolejność tagów ——— */
.order-tool-card {
  margin-top: 1rem;
}

.order-controls-grid {
  margin-top: 0.25rem;
}

.order-controls-grid .stats-tool-field {
  min-width: 0;
}

.order-field-help {
  margin-top: 0.45rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #64748b;
}

.order-field-help strong {
  color: #334155;
  font-weight: 600;
}

.order-field-help code {
  display: inline-block;
  padding: 0.08rem 0.38rem;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 0.82rem;
}

.order-controls-grid .stats-filter-input {
  height: 42px;
}

.order-summary-wrap {
  margin-top: 1.1rem;
}

.order-summary-boxes {
  margin-top: 0;
}

.order-summary-boxes .stats-box {
  min-width: 170px;
}

.order-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.order-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.78rem;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
}

.order-matrix-wrap {
  margin-top: 1.2rem;
}

.order-matrix-scroll {
  overflow: auto;
  max-width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.order-matrix-table {
  margin-top: 0;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

.order-matrix-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

.order-matrix-table thead th:first-child {
  z-index: 2;
}

.order-matrix-table td,
.order-matrix-table th {
  border: 1px solid #e5e7eb;
}

.order-cell {
  min-width: 110px;
  text-align: right !important;
  vertical-align: top;
  padding: 0.45rem !important;
}

.order-cell-btn {
  width: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: inherit;
}

.order-cell-btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
  border-radius: 12px;
}

.order-cell-box {
  min-height: 62px;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  border: 1px solid transparent;
}

.order-cell-box:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

.order-cell-box.is-active {
  border-color: #6366f1;
  box-shadow: inset 0 0 0 1px #6366f1, 0 4px 12px rgba(79, 70, 229, 0.16);
}

.order-cell-main {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.order-cell-sub {
  margin-top: 0.22rem;
  font-size: 0.76rem;
  color: #475569;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.order-top-transitions {
  margin-top: 1.25rem;
}

.order-top-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.order-top-table-wrap {
  overflow: auto;
}

.order-top-table {
  margin-top: 0.6rem;
}

.order-top-table tbody tr {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.order-top-table tbody tr:hover td {
  background: #f6f8ff;
}

.order-top-row.is-active td {
  background: #eef2ff !important;
  border-color: #c7d2fe;
}

.order-top-table td:nth-child(1),
.order-top-table td:nth-child(4),
.order-top-table td:nth-child(5),
.order-top-table td:nth-child(6),
.order-top-table td:nth-child(7),
.order-top-table th:nth-child(1),
.order-top-table th:nth-child(4),
.order-top-table th:nth-child(5),
.order-top-table th:nth-child(6),
.order-top-table th:nth-child(7) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.order-examples {
  margin-top: 1.25rem;
}

.order-examples-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.order-examples-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.order-examples-selected {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.order-example-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #312e81;
  font-weight: 700;
  font-size: 0.92rem;
}

.order-example-count {
  color: #475569;
  font-size: 0.92rem;
  font-weight: 600;
}

.order-example-list {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  margin-top: 0.95rem;
}

.order-example-item {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fcfcfd;
  padding: 0.95rem 1rem;
}

.order-example-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.order-example-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
}

.order-example-pill--kind {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.order-example-pill--index {
  background: #f1f5f9;
  border-color: #dbeafe;
  color: #475569;
}

.order-example-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.order-example-endpoint {
  min-width: 0;
}

.order-example-endpoint-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
}

.order-example-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 1.2rem;
  font-weight: 700;
  padding-top: 3.2rem;
}

.order-example-mini {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: #64748b;
}

.order-examples-more {
  margin-top: 0.9rem;
  color: #64748b;
  font-size: 0.88rem;
}

.order-explainer {
  margin-top: 0.9rem;
  line-height: 1.55;
  max-width: 980px;
}

.muted { color:#6b7280; }

@media (max-width: 980px) {
  .order-matrix-table {
    min-width: 720px;
  }

  .order-cell {
    min-width: 96px;
  }

  .order-cell-main {
    font-size: 0.95rem;
  }

  .order-cell-sub {
    font-size: 0.72rem;
  }

  .order-example-grid {
    grid-template-columns: 1fr;
  }

  .order-example-arrow {
    padding-top: 0;
    transform: rotate(90deg);
  }
}






/* ==== Entropia ==== */
.entropy-intro-card,
.entropy-note-card,
.entropy-interpretation-card {
  margin-top: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.entropy-card-title {
  margin: 0 0 0.65rem 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: #111827;
}

.entropy-intro-card p,
.entropy-note-card p,
.entropy-interpretation-card p {
  margin: 0.55rem 0;
  line-height: 1.6;
  color: #475569;
}

.entropy-intro-card code,
.entropy-note-card code,
.entropy-interpretation-card code {
  display: inline-block;
  padding: 0.08rem 0.38rem;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 0.84rem;
}

.entropy-kpi-help {
  margin-top: 1rem;
}

.entropy-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.entropy-kpi-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.95rem 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.entropy-kpi-card h4 {
  margin: 0 0 0.45rem 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: #111827;
}

.entropy-kpi-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #475569;
}

.entropy-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.entropy-legend-item {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

.entropy-legend-range {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.3rem;
}

.entropy-legend-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #475569;
}

.entropy-legend-note {
  margin-top: 0.9rem;
  color: #475569;
  line-height: 1.55;
}

/* ==== Entropia: prosty wykres słupkowy Top 10 ==== */
.bar-chart{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.bar{
  display:flex;
  align-items:center;
  gap:10px;
}

.bar__label{
  width:280px;           /* zwęź/poszerz jeśli potrzeba */
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:14px;
  color:#334155;
}

.bar__track{
  flex:1;
  height:14px;
  background:#eef2f7;
  border-radius:999px;
  position:relative;
}

.bar__fill{
  position:absolute;
  inset:0 auto 0 0;      /* left:0; top:0; bottom:0 */
  width:0%;
  border-radius:999px;
  background:linear-gradient(90deg,#6366f1,#22c1c3);
}

.bar__value{
  width:110px;           /* miejsce na wartość */
  text-align:right;
  font-variant-numeric:tabular-nums;
  color:#0f172a;
  font-size:13px;
}

/* ─── Pozycja w dokumencie ───────────────────────── */
.pos-intro-card,
.pos-summary-card {
  margin-top: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.pos-controls {
  margin: 1rem 0 0.75rem;
}

.pos-field {
  max-width: 560px;
}

.pos-field label {
  display: block;
  margin: 0 0 0.38rem;
  font-weight: 600;
  color: #374151;
}

#posTagSelect {
  appearance: none;
  width: 100%;
  min-width: 0;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.55rem 2.2rem 0.55rem 0.9rem;
  font-size: 0.96rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 0.8em;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

#posTagSelect:hover {
  border-color: #6366f1;
  background-color: #fcfcff;
}

#posTagSelect:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99,102,241,.3);
}

/* jeśli zadziała select2, też ma wyglądać dobrze */
.pos-controls .select2-container {
  width: 100% !important;
  max-width: 560px;
}

.pos-controls .select2-container .select2-selection--single {
  height: 44px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
}

.pos-controls .select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 42px;
  padding-left: 0.9rem;
  color: #111827;
  font-size: 0.96rem;
}

.pos-controls .select2-container .select2-selection--single .select2-selection__arrow {
  height: 42px;
  right: 8px;
}

.pos-controls .select2-container--default.select2-container--focus .select2-selection--single,
.pos-controls .select2-container--default .select2-selection--single:hover {
  border-color: #6366f1;
}

.pos-summary-card {
  padding: 0.8rem 1rem;
}

.pos-summary-card p {
  margin: 0.35rem 0;
}

.pos-bars {
  display: grid;
  gap: 0.55rem;
}

.pos-bars--flat {
  margin-top: 0.8rem;
  padding: 0.1rem 0 0.2rem;
}

.pos-bar-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 96px;
  gap: 0.65rem;
  align-items: center;
}

.pos-bar-label {
  color: #374151;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.88rem;
}

.pos-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #eef2ff;
  overflow: hidden;
  position: relative;
}

.pos-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg,#6366f1,#4338ca);
}

.pos-bar-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  font-size: 0.88rem;
}

.pos-bar-label {
  color:#374151;
  font-weight: 600;
  white-space: nowrap;
}

.pos-bar-track {
  height: 14px;
  border-radius: 999px;
  background: #eef2ff;
  overflow: hidden;
  position: relative;
}

.pos-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg,#6366f1,#4338ca);
}

.pos-bar-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  font-size: 0.92rem;
}

.pos-bar-val .muted {
  color:#6b7280;
}

.pos-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

@media (max-width: 860px) {
  .pos-bar-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .pos-bar-val {
    text-align: left;
  }

  #posTagSelect {
    min-width: 240px;
    width: 100%;
  }
}

#speakerStats .num,
#tagBySpeakerTable .num,
#speakerByTagTable .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#tab-speakers .speaker-tool-card + .speaker-tool-card {
  margin-top: 1rem;
}

#tab-speakers .speaker-controls-grid {
  margin-top: 0.75rem;
}

#tab-speakers .speaker-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

#tab-speakers .speaker-table-wrap .stats-table {
  margin-top: 0.5rem;
}

.stats-sortable-table th.is-sortable {
  position: relative;
  cursor: pointer;
  padding-right: 20px;
  user-select: none;
  transition: background-color 0.15s ease;
}

.stats-sortable-table th.is-sortable:hover {
  background-color: #eef2ff;
}

.stats-sortable-table th.sorted-asc::after {
  content: "▲";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72em;
  color: #6366f1;
}

.stats-sortable-table th.sorted-desc::after {
  content: "▼";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72em;
  color: #6366f1;
}

/* Dwie kolumny w karcie "Tagi i relacje per mówca" */
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 1024px) {
  .two-cols { grid-template-columns: 1fr; }
}

/* liczby wyrównane do prawej */
#prsTagTable td.num,
#prsRelTable td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* lekki odstęp pod selectem */
#prsSpeakerSelect {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 1.9rem 0.45rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6em center;
  background-size: .8em;
  min-width: 280px;
}
#prsSpeakerSelect:hover { border-color: #6366f1; }
#prsSpeakerSelect:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99,102,241,.3);
}

#distTagSelect,
#distSpeakerSelect {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 1.9rem 0.45rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6em center;
  background-size: .8em;
  min-width: 280px;
}

#distTagSelect:hover,
#distSpeakerSelect:hover {
  border-color: #6366f1;
}

#distTagSelect:focus,
#distSpeakerSelect:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99,102,241,.3);
}

/* ─────────────── Wyszukiwarka ─────────────── */

.search-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 12px 0 18px;
}

.search-controls label {
  font-weight: 500;
  color: #374151;
  margin-right: 4px;
}

.search-controls select {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 1.9rem 0.45rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  background-size: 0.8em;
}

.search-controls select:hover {
  border-color: #6366f1;
}

.search-controls select:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.search-results {
  margin-top: 1rem;
}

.search-results .result-item {
  background: #fdfdfd;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.8rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.search-results .result-item h4 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  color: #111827;
}

.search-results .result-item p {
  margin: 0.2rem 0;
  color: #374151;
  font-size: 0.9rem;
}

/* Styl dla przycisku Szukaj */
#searchBtn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 0.5em 1.2em;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

#searchBtn:hover {
  background: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* ─── Relacje: szerokości kolumn ─── */
/* ─── Relacje: szerokości kolumn (nr / relacja / Nb. / %) ─── */
#tab-relations .list-table th:nth-child(1),
#tab-relations .list-table td:nth-child(1) {
  width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#tab-relations .list-table th:nth-child(2),
#tab-relations .list-table td:nth-child(2) {
  width: 100%;
}

#tab-relations .list-table th:nth-child(3),
#tab-relations .list-table td:nth-child(3) {
  width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#tab-relations .list-table th:nth-child(4),
#tab-relations .list-table td:nth-child(4) {
  width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Charakterystyka dokumentu */
.doc-info-box {
  margin-top: 2em;
}

.doc-info-box h2 {
  font-size: 1.4em;
  margin-bottom: 0.6em;
  color: #111827;
}

.doc-info-table th {
  width: 220px;
  background: #f3f4f6;
  font-weight: 600;
  color: #374151;
}

.doc-info-table td {
  color: #111827;
}

/* Bufor od dołu, żeby footer nie zasłaniał treści */
.stats-tab {
  padding-bottom: 150px; /* wysokość footera */
}

.section-title {
  font-size: 1.3em;
  font-weight: 600;
  margin: 1.2em 0 0.6em;
  color: #111827;
  display: flex;
  align-items: center;
}

#oneTagReport {
  border-top: 2px solid #eee;
  margin-top: 1.5em;
  padding-top: 1em;
}

#oneTagReport .stats-box .value {
  font-size: 1.5em;
}

.co-summary {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.8em 1em;
  margin: 0.8em 0 1.2em;
  font-size: 0.95em;
}

#tab-cooccrelations h2 {
  margin-top: 1rem;
  margin-bottom: 0.6rem;
}

#tab-cooccrelations .stats-box {
  min-width: 160px;
}

/* Współwystępowanie relacji — lekkie dopieszczenie */
#tab-cooccrelations h2 { margin-top: 0; }
#tab-cooccrelations .cooccurrence-results { margin-top: 12px; }
#tab-cooccrelations .stats-table { margin-top: .5em; }

/* Styl dla dropdownów w zakładce Współwystępowanie relacji */
#coRel1, #coRel2, #oneRelSelect {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.4em 1.8em 0.4em 0.8em;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  background-size: 0.8em;
}

#coRel1:hover, #coRel2:hover, #oneRelSelect:hover {
  border-color: #6366f1;
}

#coRel1:focus, #coRel2:focus, #oneRelSelect:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Przyciski w zakładkach statystyk */
.stats-btn {
  background: #eef4fb;
  border: 1px solid #cddff5;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #0b3a67;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.stats-btn:hover {
  background: #e1edfa;
  border-color: #80bfff;
  color: #083256;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.12);
}

.assoc-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.assoc-top-card {
  margin-bottom: 0.75rem;
}

.assoc-section-card,
.assoc-intro-card {
  background: #fcfcfd;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.assoc-intro-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.assoc-results-block .section-title {
  margin: 0 0 0.7rem;
}

.assoc-results-block .assoc-metric-boxes {
  margin-top: 0.2rem;
  gap: 1rem;
}

.assoc-results-block .stats-box {
  min-width: 170px;
  padding: 1rem 1.2rem;
}

.assoc-results-block .assoc-table {
  table-layout: fixed;
  width: 100%;
  margin-top: 0.5rem;
}

.assoc-results-block .assoc-table th,
.assoc-results-block .assoc-table td {
  vertical-align: top;
}

.assoc-results-block .assoc-table td:nth-child(1) {
  width: 140px;
  white-space: nowrap;
}

.assoc-results-block .assoc-table td:nth-child(2) {
  width: 110px;
}

.assoc-results-block .assoc-table td:nth-child(3) {
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .assoc-results-block .assoc-table td:nth-child(1),
  .assoc-results-block .assoc-table td:nth-child(2) {
    width: auto;
    white-space: normal;
  }
}




/* Tabela asocjacji */
.assoc-table td, .assoc-table th {
  padding: 0.5em 0.75em;
  text-align: left;
  vertical-align: top;
}
.assoc-table td:nth-child(2) {
  font-family: 'Roboto Mono', monospace;
  text-align: right;
  white-space: nowrap;
}
.assoc-table td:nth-child(3) {
  color: #555;
  font-size: 0.9em;
}

.pos-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 1rem 0;
  min-height: 140px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
  font-size: 0.8rem;
  color: #374151;
}

.pos-bar {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.pos-bar-fill {
  width: 100%;
  background: linear-gradient(to top, #6366f1 0%, #a5b4fc 100%);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height .2s;
}

.pos-bar-label {
  margin-top: .4rem;
  line-height: 1.2;
}

.pos-bar-count {
  color: #6b7280;
  font-size: .75em;
}

/* multi-select (relacje AND) */
.search-controls select[multiple] {
  padding-right: 0.8rem;
  background-image: none;
  min-height: 74px;
}

.search-controls input[type="text"],
.search-controls input[type="number"] {
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-controls input[type="text"]:focus,
.search-controls input[type="number"]:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.chip-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  color: #111827;
  cursor: pointer;
  user-select: none;
}
.chip-radio input { accent-color: #2563eb; }

.search-advanced summary {
  cursor: pointer;
  color: #374151;
  font-weight: 600;
  margin-top: 2px;
}

/* Wyniki (nowy markup) */
.search-result {
  background: #fdfdfd;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.9rem 1.05rem;
  margin-bottom: 0.8rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.search-meta {
  font-size: 0.95rem;
  color: #111827;
  margin-bottom: 0.35rem;
}
.search-text {
  font-size: 0.95rem;
  color: #374151;
  margin: 0.15rem 0 0.2rem;
}
.search-ann {
  color: #374151;
  font-size: 0.9rem;
}
.search-rel {
  color: #374151;
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

#searchClearBtn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  padding: 0.5em 1.0em;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}
#searchClearBtn:hover {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

/* ─────────────── Łańcuchy relacji ─────────────── */

.chains-intro-card,
.chains-controls-card,
.chains-legend-card {
  margin-top: 1rem;
}

.chains-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.chains-help-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  line-height: 1.55;
  color: #475569;
}

.chains-help-item strong {
  display: block;
  margin-bottom: 0.3rem;
  color: #111827;
}

.chains-controls-grid {
  margin-top: 0.5rem;
}

.chains-legend-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.95rem 1.05rem;
  color: #475569;
  line-height: 1.55;
}

#chainsRelType,
#chainsMinLength,
#chainsDirection {
  appearance: none;
  background-color: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 1.9rem 0.45rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D'14'%20height%3D'10'%20viewBox%3D'0%200%2014%2010'%20xmlns%3D'http://www.w3.org/2000/svg'%3E%3Cpath%20d%3D'M1%201L7%208L13%201'%20stroke%3D'%236b7280'%20stroke-width%3D'2'%20fill%3D'none'%20stroke-linecap%3D'round'%20/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  background-size: 0.8em;
}

#chainsRelType:hover,
#chainsMinLength:hover,
#chainsDirection:hover {
  border-color: #6366f1;
}

#chainsRelType:focus,
#chainsMinLength:focus,
#chainsDirection:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.chains-path-cell {
  font-family: inherit;
  font-size: 0.95em;
  white-space: normal;
  word-break: break-word;
  color: #1f2937;
  line-height: 1.7;
}

#chainsSummary .stats-box .value {
  font-size: 1.5em;
}

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

.chains-open-btn[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

.chain-node-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  vertical-align: middle;
}

.chain-node-id {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.92em;
  color: #334155;
}

.chain-arrow {
  display: inline-block;
  margin: 0 6px;
  color: #475569;
  font-weight: 600;
}

.chain-sep {
  margin: 0 8px;
  color: #94a3b8;
}

.chains-path-cell {
  font-family: inherit;
  font-size: 0.95em;
  white-space: normal;
  word-break: break-word;
  color: #1f2937;
  line-height: 1.7;
}

.chains-path-cell .inline-tag {
  vertical-align: middle;
}

.stats-relation-card-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9em;
}

.stats-relation-card {
  background: #fdfdfd;
}

.stats-relation-two-col {
  display: flex;
  flex-direction: column;
  gap: 0.9em;
}

.stats-rel-endpoint {
  padding: 0.15em 0;
}

.stats-rel-endpoint-label {
  display: inline-block;
  margin-bottom: 0.45em;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #64748b;
}

.stats-rel-connector {
  margin: 0.2em 0 0.35em;
}

.stats-open-graph-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 1.02em;
  line-height: 1;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.stats-open-graph-btn:hover {
  opacity: 1;
}

.stats-open-graph-btn:active {
  transform: translateY(1px);
}

/* === Stats modal: porządny układ komentarza eksperckiego === */
#statsInfoModal .expert-comment-modal__dialog {
  width: min(1500px, 96vw);
  max-height: min(92vh, 1200px);
}

#statsInfoModal .expert-comment-modal__body {
  padding: 18px 20px 20px;
  line-height: 1.45;
}

#statsInfoModal .expert-comment-row + .expert-comment-row {
  margin-top: 1em;
}

#statsInfoModal .expert-comment-label {
  margin-bottom: 0.3em;
  font-weight: 700;
}

#statsInfoModal .expert-comment-value {
  white-space: normal;
  line-height: 1.58;
}

#statsInfoModal .stats-info-section {
  margin-bottom: 1.1em;
  padding: 0.9em 1em;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

#statsInfoModal .stats-info-section-title {
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.55em;
}

#statsInfoModal .stats-info-segment-text {
  font-size: 1.03em;
  line-height: 1.62;
  color: #111827;
  font-style: italic;
}

#statsInfoModal .stats-info-tagline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.55em;
}

#statsInfoModal .stats-info-ann-text {
  font-size: 1em;
  line-height: 1.58;
  color: #111827;
}

#statsInfoModal .stats-annotation-translation {
  margin: 0.45em 0 0;
}

#statsInfoModal .inline-tag {
  vertical-align: middle;
}

/* ─────────────── Cooccurrence / Cooccrelations refresh ─────────────── */

.stats-cooc-tab {
  padding-top: 72px;
}

.stats-tool-card {
  background: #fcfcfd;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 1.2rem 1.25rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-top: 1rem;
}

.stats-tool-card + .stats-tool-card {
  margin-top: 1.25rem;
}

.stats-tool-card--secondary {
  background: #ffffff;
}

.stats-tool-card__header {
  margin-bottom: 1rem;
}

.stats-tool-card__title {
  margin: 0 0 0.25rem;
  font-size: 1.12rem;
  font-weight: 700;
  color: #111827;
}

.stats-tool-card__desc {
  margin: 0;
  color: #6b7280;
  font-size: 0.94rem;
  line-height: 1.45;
}

.stats-tool-grid {
  display: grid;
  gap: 16px 18px;
  align-items: start;
}

.stats-tool-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-tool-grid--1 {
  grid-template-columns: 1fr;
}

.stats-tool-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.stats-tool-field label {
  font-weight: 600;
  color: #374151;
}

.stats-tool-field--wide {
  max-width: 640px;
}

.stats-filter-input {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.48rem 0.8rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.stats-filter-input::placeholder {
  color: #9ca3af;
}

.stats-filter-input:hover {
  border-color: #6366f1;
}

.stats-filter-input:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

.stats-tool-field select {
  min-width: 0 !important;
  width: 100%;
}

.stats-tool-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 1rem;
}

#cooccurrenceResults,
#cooccurrenceRelResults,
#oneTagReport,
#oneRelReport {
  margin-top: 1rem !important;
}

#tab-cooccurrence .stats-table,
#tab-cooccrelations .stats-table {
  margin-top: 0.75rem;
}

#tab-cooccurrence .stats-metric-boxes,
#tab-cooccrelations .stats-metric-boxes {
  margin-top: 1rem;
}

@media (max-width: 980px) {
  .stats-tool-grid--2 {
    grid-template-columns: 1fr;
  }

  .stats-tool-field--wide {
    max-width: 100%;
  }
}

.stats-searchable-select {
  width: 100%;
}

.stats-tool-field .select2-container {
  width: 100% !important;
}

.stats-tool-field .select2-container--default .select2-selection--single {
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  display: flex;
  align-items: center;
  padding: 0 0.35rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stats-tool-field .select2-container--default .select2-selection--single:hover {
  border-color: #6366f1;
}

.stats-tool-field .select2-container--default.select2-container--focus .select2-selection--single,
.stats-tool-field .select2-container--default.select2-container--open .select2-selection--single {
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

.stats-tool-field .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 40px;
  color: #111827;
  padding-left: 0.35rem;
  padding-right: 2rem;
  font-size: 0.95rem;
}

.stats-tool-field .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
  right: 8px;
}

.select2-dropdown {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

.select2-search--dropdown {
  padding: 0.55rem;
  background: #fff;
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.95rem;
}

.select2-search--dropdown .select2-search__field:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

.select2-results__option {
  font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
}

/* ─────────────── Asocjacje: intro + Select2 ─────────────── */

.assoc-intro-card {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.assoc-intro-card p {
  margin: 0.45rem 0 0;
  color: #374151;
  line-height: 1.58;
}

#tab-assoc .stats-tool-card {
  margin-bottom: 1rem;
}

#tab-assoc .stats-searchable-select {
  width: 100%;
}

#tab-assoc .select2-container {
  width: 100% !important;
}

#tab-assoc .select2-container--default .select2-selection--single {
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  display: flex;
  align-items: center;
  padding: 0 0.35rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#tab-assoc .select2-container--default .select2-selection--single:hover {
  border-color: #6366f1;
}

#tab-assoc .select2-container--default.select2-container--focus .select2-selection--single,
#tab-assoc .select2-container--default.select2-container--open .select2-selection--single {
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

#tab-assoc .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 40px;
  color: #111827;
  padding-left: 0.35rem;
  padding-right: 2rem;
  font-size: 0.95rem;
}

#tab-assoc .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
  right: 8px;
}

/* ======================================================================
   Grouped navigation + general-tag-aware tag exploration
   ====================================================================== */

.stats-tab {
  padding: 46px 64px 130px;
  max-width: 1800px;
  margin: 0 auto;
  box-sizing: border-box;
}

.stats-subnav-shell {
  position: sticky;
  top: 61px;
  z-index: 220;
  padding: 10px 64px 0;
  background: linear-gradient(to bottom, rgba(255,255,255,.98) 72%, rgba(255,255,255,0));
  backdrop-filter: blur(8px);
}

.stats-subnav-shell.is-empty {
  padding-top: 0;
}

.stats-context-nav {
  width: min(100%, 1672px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 7px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 4px 16px rgba(15,23,42,.05);
}

.stats-context-tab {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: .91rem;
  font-weight: 650;
  cursor: pointer;
}

.stats-context-tab:hover {
  background: #f8fafc;
  color: #111827;
}

.stats-context-tab.active {
  background: #eef2ff;
  color: #3730a3;
  box-shadow: inset 0 0 0 1px #c7d2fe;
}

.stats-footer-tabs.stats-main-tabs {
  gap: .6rem;
  margin: 0;
  flex-wrap: nowrap;
}

footer .stats-main-tab {
  min-width: 118px;
  padding: .55rem 1rem;
  border-radius: 10px;
  border-color: #dbe2ea;
  background: rgba(255,255,255,.82);
  color: #334155;
  font-weight: 650;
}

footer .stats-main-tab:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

footer .stats-main-tab.active {
  background: #4338ca;
  color: #fff;
  border-color: #4338ca;
  box-shadow: 0 4px 12px rgba(67,56,202,.2);
}

.stats-page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.stats-page-heading h1 {
  margin: 4px 0 6px;
  color: #0f172a;
  font-size: clamp(1.55rem, 2vw, 2.1rem);
  line-height: 1.15;
}

.stats-page-heading p {
  margin: 0;
  max-width: 760px;
  color: #64748b;
  line-height: 1.6;
}

.stats-eyebrow {
  display: inline-block;
  color: #6366f1;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stats-dataset-chip {
  flex: 0 1 360px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  padding: 8px 13px;
  color: #475569;
  font-size: .88rem;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(125px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats-kpi-card {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  padding: 14px 15px;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}

.stats-kpi-card > span {
  display: block;
  min-height: 32px;
  color: #64748b;
  font-size: .79rem;
  font-weight: 650;
  line-height: 1.25;
}

.stats-kpi-card strong {
  display: block;
  margin-top: 5px;
  color: #0f172a;
  font-size: 1.65rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stats-kpi-card small {
  display: block;
  margin-top: 5px;
  color: #94a3b8;
  font-size: .72rem;
}

.stats-kpi-card--accent {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #f5f3ff, #eef2ff);
}

.stats-kpi-card--accent strong {
  color: #4338ca;
}

.stats-overview-primary {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
}

.stats-overview-rankings {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-overview-meta {
  margin-top: 1rem;
}

.taxonomy-progress {
  height: 9px;
  margin: 18px 0 3px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.taxonomy-progress__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #818cf8, #4f46e5);
}

.basic-stat--warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

/* ---- Tags hub ------------------------------------------------------- */

.stats-page-heading--tags {
  margin-bottom: 16px;
}

.stats-tags-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  max-width: 480px;
}

.stats-tags-summary span {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  padding: 7px 10px;
  color: #64748b;
  font-size: .79rem;
  white-space: nowrap;
}

.stats-tags-summary strong {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.stats-tags-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}

.stats-segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: #f1f5f9;
}

.stats-segmented button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 7px 11px;
  color: #64748b;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
}

.stats-segmented button:hover {
  color: #1e293b;
}

.stats-segmented button.active {
  background: #fff;
  color: #4338ca;
  box-shadow: 0 1px 4px rgba(15,23,42,.12);
}

.stats-tag-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stats-search-field {
  display: flex;
  align-items: center;
  gap: 7px;
  width: min(320px, 34vw);
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  background: #fff;
  padding: 0 10px;
  color: #94a3b8;
}

.stats-search-field:focus-within {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

.stats-search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 8px 0;
  color: #0f172a;
  font: inherit;
  font-size: .88rem;
}

.stats-sort-select {
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  color: #334155;
  font: inherit;
  font-size: .86rem;
}

.tag-stats-container--v2 {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.tag-list-column--v2 {
  position: sticky;
  top: 126px;
  flex: initial;
  max-width: none;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

/* Override legacy fixed-width rules from the original tag statistics layout. */
.tag-stats-container--v2 .tag-list-column--v2 {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  flex: none;
}

.tag-stats-container--v2 .tag-details-column--v2 {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.tag-list-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid #eef2f7;
  color: #64748b;
  font-size: .76rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tag-list-column--v2 .tag-list-scroll {
  max-height: calc(100vh - 260px);
  min-height: 360px;
  overflow-y: auto;
  padding: 5px;
}

.stats-tag-ranking {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.tag-rank-row {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 48px 52px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 8px 8px;
  color: #334155;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.tag-rank-row:hover {
  background: #f8fafc;
}

.tag-rank-row.active {
  background: #eef2ff;
  box-shadow: inset 0 0 0 1px #c7d2fe;
}

.tag-rank-index,
.tag-rank-count,
.tag-rank-pct {
  font-variant-numeric: tabular-nums;
}

.tag-rank-index {
  color: #94a3b8;
  font-size: .76rem;
  text-align: right;
}

.tag-rank-main {
  min-width: 0;
}

.tag-rank-label-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tag-rank-label {
  display: block;
  overflow: hidden;
  color: #1e293b;
  font-size: .87rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.tag-rank-count {
  color: #0f172a;
  font-size: .83rem;
  font-weight: 800;
  text-align: right;
}

.tag-rank-pct {
  color: #64748b;
  font-size: .75rem;
  text-align: right;
}

.tag-rank-bar {
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1f5f9;
}

.tag-rank-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #818cf8;
}

.stats-tag-parent,
.taxonomy-family-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #94a3b8;
  font-size: .69rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-level-badge {
  flex: 0 0 auto;
  min-width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  background: #eef2ff;
  color: #4338ca;
  font-size: .64rem;
  font-weight: 900;
}

.stats-level-badge--missing {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.taxonomy-family {
  margin-bottom: 5px;
  border: 1px solid #eef2f7;
  border-radius: 11px;
  overflow: hidden;
}

.taxonomy-parent-row {
  border-radius: 0;
  background: #fbfcfe;
}

.taxonomy-children {
  border-top: 1px solid #f1f5f9;
  background: #fff;
}

.taxonomy-child-row {
  grid-template-columns: 28px minmax(0, 1fr) 48px 52px;
  border-radius: 0;
  padding-top: 6px;
  padding-bottom: 6px;
}

.taxonomy-child-row .tag-rank-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.taxonomy-child-row .tag-rank-label {
  font-weight: 550;
  font-size: .82rem;
}

.taxonomy-branch {
  flex: 0 0 auto;
  color: #cbd5e1;
  font-size: .86rem;
}

.taxonomy-family--missing {
  border-color: #fed7aa;
}

.tag-details-column--v2 {
  min-height: 520px;
  max-height: none;
  overflow: visible;
  padding: 0;
}

.stats-empty-state {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #fbfdff;
  color: #64748b;
  text-align: center;
  padding: 30px;
}

.stats-empty-state strong {
  color: #334155;
  font-size: 1rem;
}

.stats-empty-state span {
  max-width: 500px;
  font-size: .87rem;
  line-height: 1.55;
}

.stats-empty-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 1.1rem;
  font-weight: 800;
}

.stats-detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
}

.stats-detail-heading h2 {
  margin: 4px 0 2px;
  color: #0f172a;
  font-size: 1.25rem;
}

.stats-detail-heading p {
  margin: 0;
  color: #64748b;
  font-size: .85rem;
}

.stats-general-composition {
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  background: #fff;
  padding: 10px 12px;
}

.stats-general-composition__label {
  display: block;
  margin-bottom: 7px;
  color: #64748b;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stats-general-composition__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-composition-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 360px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  padding: 5px 8px 5px 10px;
  color: #475569;
  font-size: .76rem;
}

.stats-composition-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-composition-chip strong {
  color: #4338ca;
  font-variant-numeric: tabular-nums;
}

.stats-general-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #f5f3ff;
  padding: 3px 7px;
  color: #4f46e5;
  font-size: .72rem;
  font-weight: 700;
}

.stats-general-tag-chip > span {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e0e7ff;
  font-size: .58rem;
  font-weight: 900;
}

.stats-general-tag-chip--missing {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.tag-rank-row[hidden],
.taxonomy-family[hidden],
.taxonomy-child-row[hidden] {
  display: none !important;
}

@media (max-width: 1450px) {
  .stats-kpi-grid { grid-template-columns: repeat(4, minmax(125px, 1fr)); }
  .stats-overview-rankings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1050px) {
  .stats-tab { padding-left: 28px; padding-right: 28px; }
  .stats-subnav-shell { padding-left: 28px; padding-right: 28px; }
  .stats-overview-primary { grid-template-columns: 1fr; }
  .tag-stats-container--v2 { grid-template-columns: 1fr; }
  .tag-list-column--v2 { position: static; }
  .tag-list-column--v2 .tag-list-scroll { max-height: 520px; min-height: 0; }
}

@media (max-width: 760px) {
  .stats-tab { padding: 30px 16px 150px; }
  .stats-subnav-shell { top: 58px; padding-left: 12px; padding-right: 12px; }
  .stats-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-overview-rankings { grid-template-columns: 1fr; }
  .stats-page-heading { flex-direction: column; }
  .stats-dataset-chip { max-width: 100%; flex-basis: auto; }
  .stats-tags-toolbar { align-items: stretch; flex-direction: column; }
  .stats-tag-controls-right { width: 100%; }
  .stats-search-field { width: 100%; }
  .stats-sort-select { flex: 0 0 auto; }
  .stats-segmented { width: 100%; }
  .stats-segmented button { flex: 1 1 0; }
  footer .stats-main-tab { min-width: 0; padding-left: .65rem; padding-right: .65rem; }
  .stats-footer-tabs.stats-main-tabs { overflow-x: auto; justify-content: flex-start; }
}

/* ======================================================================
   Tag exploration enrichment — bilingual labels, filters and context
   ====================================================================== */

.tag-stats-container--v2 {
  grid-template-columns: minmax(410px, 560px) minmax(0, 1fr);
}

.tag-rank-translation {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: #64748b;
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-rank-count--filtered {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  white-space: nowrap;
}

.tag-rank-count--filtered strong {
  color: #4338ca;
  font-size: .86rem;
}

.tag-rank-count--filtered small {
  color: #94a3b8;
  font-size: .67rem;
  font-weight: 650;
}

.taxonomy-parent-row-wrap {
  position: relative;
}

.taxonomy-family-meta--floating {
  position: absolute;
  left: 44px;
  bottom: 8px;
  max-width: calc(100% - 170px);
  pointer-events: none;
}

.taxonomy-parent-row-wrap .tag-rank-row {
  padding-bottom: 27px;
}

.stats-tags-filters {
  display: grid;
  grid-template-columns: auto repeat(4, minmax(150px, 1fr)) auto;
  gap: 9px;
  align-items: end;
  margin: 0 0 16px;
  padding: 10px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fbfcfe;
}

.stats-tags-filters.has-active-filters {
  border-color: #c7d2fe;
  background: #f8f9ff;
}

.stats-filter-title {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 120px;
  color: #475569;
  font-size: .79rem;
  font-weight: 750;
}

.stats-filter-title strong {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e0e7ff;
  color: #4338ca;
  font-size: .69rem;
}

.stats-filter-control {
  min-width: 0;
}

.stats-filter-control > span {
  display: block;
  margin: 0 0 4px 2px;
  color: #64748b;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.stats-filter-control select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #dbe2ea;
  border-radius: 9px;
  background: #fff;
  padding: 7px 9px;
  color: #334155;
  font: inherit;
  font-size: .8rem;
}

.stats-filter-control select:focus {
  outline: 0;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99,102,241,.09);
}

.stats-filter-reset {
  min-height: 36px;
  border: 1px solid #dbe2ea;
  border-radius: 9px;
  background: #fff;
  padding: 7px 11px;
  color: #475569;
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}

.stats-filter-reset:hover:not(:disabled) {
  border-color: #c7d2fe;
  color: #4338ca;
  background: #f5f3ff;
}

.stats-filter-reset:disabled {
  opacity: .45;
  cursor: default;
}

.stats-detail-heading--rich {
  margin-bottom: 10px;
}

.stats-detail-title-en {
  margin-top: 3px;
  color: #64748b;
  font-size: .95rem;
  line-height: 1.35;
}

.stats-detail-general {
  display: inline-flex;
  margin-top: 6px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #f5f3ff;
  padding: 4px 8px;
  color: #4f46e5;
  font-size: .72rem;
  font-weight: 700;
}

.stats-tag-profile-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stats-tag-profile-metrics > div {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 10px 11px;
}

.stats-tag-profile-metrics > div.is-filtered {
  border-color: #c7d2fe;
  background: #f5f3ff;
}

.stats-tag-profile-metrics strong {
  display: block;
  color: #0f172a;
  font-size: 1.1rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stats-tag-profile-metrics span {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: .72rem;
  line-height: 1.25;
}

.stats-tag-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stats-tag-profile-section {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  background: #fff;
  padding: 11px 12px;
}

.stats-tag-profile-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.stats-tag-profile-section__head h3 {
  margin: 0;
  color: #1e293b;
  font-size: .9rem;
}

.stats-tag-profile-section__head > span {
  color: #94a3b8;
  font-size: .68rem;
}

.stats-profile-relations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-profile-relation-chip {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 2px 7px;
  align-items: center;
  border: 1px solid #dbe2ea;
  border-radius: 9px;
  background: #f8fafc;
  padding: 6px 8px;
  color: #334155;
  font-size: .72rem;
}

.stats-profile-relation-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-profile-relation-chip > span {
  color: #4338ca;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stats-profile-relation-chip small {
  grid-column: 1 / -1;
  color: #94a3b8;
  font-size: .64rem;
}

.stats-profile-empty {
  color: #94a3b8;
  font-size: .76rem;
  line-height: 1.45;
}

.stats-hierarchy-role-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.stats-hierarchy-role-metrics span {
  border-radius: 999px;
  background: #f8fafc;
  padding: 5px 8px;
  color: #64748b;
  font-size: .7rem;
}

.stats-hierarchy-role-metrics strong {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.stats-hierarchy-neighbours {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats-hierarchy-neighbours h4 {
  margin: 0 0 6px;
  color: #64748b;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stats-linked-type-list {
  display: grid;
  gap: 4px;
}

.stats-linked-type-list > span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 4px;
}

.stats-linked-type-list > span:first-child {
  border-top: 0;
  padding-top: 0;
}

.stats-linked-type-list > span > strong {
  color: #4338ca;
  font-size: .7rem;
  font-variant-numeric: tabular-nums;
}

.stats-bilingual-tag {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stats-bilingual-tag > strong {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  font-size: .72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bilingual-tag > small {
  min-width: 0;
  overflow: hidden;
  color: #94a3b8;
  font-size: .62rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-composition-chip .stats-bilingual-tag {
  max-width: 260px;
}

.stats-examples-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 9px;
}

.stats-examples-heading h3 {
  margin: 0;
  color: #1e293b;
  font-size: 1rem;
}

.stats-examples-heading span {
  color: #94a3b8;
  font-size: .74rem;
}

.stats-empty-state--compact {
  min-height: 150px;
  margin-bottom: 14px;
}

.stats-card-header-status {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-left: 8px;
  vertical-align: middle;
}

.stats-example-status {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  background: #f8fafc;
  padding: 2px 7px;
  color: #64748b;
  font-size: .66rem;
  font-weight: 700;
}

.stats-example-status--relations {
  border-color: #c7d2fe;
  background: #f5f3ff;
  color: #4f46e5;
}

.stats-example-status--hierarchy {
  border-color: #bae6d3;
  background: #f0fdf4;
  color: #24734a;
}

.stats-general-tag-chip small {
  margin-left: 2px;
  color: #7c83b8;
  font-size: .62rem;
  font-weight: 500;
}

.stats-card-context-block {
  margin-top: 10px;
  border-top: 1px solid #e8edf3;
  padding-top: 9px;
}

.stats-card-context-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: #64748b;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .035em;
}

.stats-card-context-label > span {
  color: #94a3b8;
  font-size: .64rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.stats-card-context-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-relation-link-chip,
.stats-linked-ann-chip {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #dbe2ea;
  border-radius: 9px;
  background: #fff;
  padding: 5px 7px;
  color: #475569;
  font: inherit;
  font-size: .7rem;
  line-height: 1.25;
  cursor: pointer;
}

.stats-relation-link-chip:hover:not(:disabled),
.stats-linked-ann-chip:hover {
  border-color: #a5b4fc;
  background: #f8f9ff;
  color: #3730a3;
}

.stats-relation-link-chip:disabled {
  opacity: .7;
  cursor: default;
}

.stats-relation-link-chip strong,
.stats-linked-ann-chip strong {
  color: #1e293b;
}

.stats-relation-link-chip small,
.stats-linked-ann-chip small {
  color: #94a3b8;
  font-size: .62rem;
}

.stats-relation-link-chip .rel-id-badge {
  border-radius: 999px;
  background: #eef2ff;
  padding: 2px 5px;
  color: #4f46e5;
  font-size: .62rem;
  font-weight: 800;
}

.stats-relation-link-chip .rel-arrow {
  color: #6366f1;
  font-weight: 900;
}

.stats-linked-ann-chip:first-letter {
  color: #22a06b;
}

.stats-linked-preview {
  margin-top: 9px;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  background: #fff;
  padding: 10px 11px;
  box-shadow: 0 4px 14px rgba(15,23,42,.05);
}

.stats-linked-preview[hidden] {
  display: none !important;
}

.stats-linked-preview__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.stats-linked-preview__head > div {
  min-width: 0;
}

.stats-linked-preview__head span,
.stats-linked-preview__head small {
  display: block;
  color: #94a3b8;
  font-size: .65rem;
}

.stats-linked-preview__head strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: #1e293b;
  font-size: .78rem;
}

.stats-linked-preview-close {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #fff;
  color: #64748b;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.stats-linked-preview__meta {
  margin-top: 7px;
  color: #94a3b8;
  font-size: .66rem;
}

.stats-linked-preview__text {
  margin-top: 5px;
  color: #334155;
  font-size: .8rem;
  line-height: 1.5;
}

.stats-linked-preview__translation {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  color: #64748b;
  font-size: .74rem;
  line-height: 1.45;
}

@media (max-width: 1420px) {
  .stats-tags-filters {
    grid-template-columns: repeat(4, minmax(145px, 1fr));
  }
  .stats-filter-title,
  .stats-filter-reset {
    grid-column: span 2;
  }
  .stats-filter-reset {
    justify-self: end;
  }
  .stats-tag-profile-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1050px) {
  .tag-stats-container--v2 {
    grid-template-columns: 1fr;
  }
  .stats-tags-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-filter-title,
  .stats-filter-reset {
    grid-column: auto;
  }
  .stats-tag-profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .stats-tags-filters {
    grid-template-columns: 1fr;
  }
  .stats-tag-profile-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-hierarchy-neighbours {
    grid-template-columns: 1fr;
  }
  .taxonomy-family-meta--floating {
    position: static;
    display: block;
    margin: -20px 12px 8px 45px;
    max-width: none;
  }
}

/* ======================================================================
   Relations hub refresh — relation types, tag pairs, co-occurrence, structures
   ====================================================================== */

.stats-page-heading--relations {
  margin-bottom: 16px;
}

.stats-relations-summary {
  max-width: 620px;
}

.stats-relations-toolbar {
  min-height: 54px;
}

.stats-relations-toolbar .stats-tag-controls-right {
  width: 100%;
  justify-content: flex-end;
}

.stats-relations-toolbar .stats-search-field {
  margin-right: auto;
}

.stats-relations-explorer {
  display: grid;
  grid-template-columns: minmax(390px, 520px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.stats-relation-list-card {
  position: sticky;
  top: 126px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

.stats-relation-list-head {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid #eef2f7;
  color: #64748b;
  font-size: .76rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stats-relation-ranking {
  max-height: calc(100vh - 260px);
  min-height: 360px;
  overflow-y: auto;
  padding: 5px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.stats-relation-rank-row,
.stats-rel-pair-row {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 70px 52px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 9px 8px;
  color: #334155;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.stats-relation-rank-row:hover,
.stats-rel-pair-row:hover {
  background: #f8fafc;
}

.stats-relation-rank-row.active,
.stats-rel-pair-row.active {
  background: #eef2ff;
  box-shadow: inset 0 0 0 1px #c7d2fe;
}

.stats-relation-rank-index,
.stats-relation-rank-count,
.stats-relation-rank-pct {
  font-variant-numeric: tabular-nums;
}

.stats-relation-rank-index {
  color: #94a3b8;
  font-size: .76rem;
  text-align: right;
}

.stats-relation-rank-main {
  min-width: 0;
}

.stats-relation-rank-main strong {
  display: block;
  overflow: hidden;
  color: #1e293b;
  font-size: .87rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-relation-rank-count {
  color: #0f172a;
  font-size: .83rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.stats-relation-rank-count.is-filtered {
  color: #4338ca;
}

.stats-relation-rank-pct {
  color: #64748b;
  font-size: .75rem;
  text-align: right;
}

.stats-relation-rank-bar {
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1f5f9;
}

.stats-relation-rank-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #818cf8;
}

.relation-details-column--v2 {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

.stats-relation-detail-heading {
  margin-bottom: 12px;
}

.stats-relation-profile-metrics {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-bottom: 16px;
}

.stats-relation-examples {
  display: grid;
  gap: 14px;
}

.stats-relation-card {
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}

.stats-relation-card-header {
  padding-bottom: 9px;
  border-bottom: 1px solid #eef2f7;
}

.stats-relation-two-col {
  display: grid;
  grid-template-columns: minmax(0,1fr) 72px minmax(0,1fr);
  gap: 14px;
  align-items: stretch;
}

.stats-rel-endpoint {
  min-width: 0;
  padding: 12px 0 4px;
}

.stats-rel-endpoint-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.stats-rel-endpoint-context {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.stats-hierarchy-mini {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  padding: 3px 7px;
  color: #64748b;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
}

.stats-hierarchy-mini.is-active {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.stats-rel-connector {
  align-self: center;
  margin: 0;
}

.stats-rel-connector .rel-arrow {
  color: #6366f1;
}

/* source → target tag analysis */
.stats-rel-pairs-toolbar {
  align-items: center;
}

.stats-rel-pairs-controls {
  flex-wrap: wrap;
}

.stats-rel-pairs-controls .stats-search-field {
  min-width: 250px;
}

.stats-rel-pair-highlight {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  border: 1px solid #e0e7ff;
  border-radius: 12px;
  background: #f8faff;
  padding: 9px 12px;
  color: #475569;
  font-size: .82rem;
}

.stats-rel-pair-highlight > span {
  color: #64748b;
  font-weight: 700;
}

.stats-rel-pair-highlight > strong {
  min-width: 0;
  overflow: hidden;
  color: #312e81;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-rel-pair-highlight > b {
  margin-left: auto;
  border-radius: 999px;
  background: #e0e7ff;
  padding: 3px 8px;
  color: #4338ca;
  font-variant-numeric: tabular-nums;
}

.stats-rel-pair-row {
  grid-template-columns: 28px minmax(0,1fr) 48px 52px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.stats-rel-pair-main {
  min-width: 0;
}

.stats-rel-pair-flow {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.stats-rel-pair-arrow {
  color: #6366f1;
  font-weight: 900;
}

.stats-rel-pair-label {
  min-width: 0;
}

.stats-rel-pair-label strong,
.stats-rel-pair-label small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-rel-pair-label strong {
  color: #1e293b;
  font-size: .8rem;
  font-weight: 750;
}

.stats-rel-pair-label small {
  margin-top: 2px;
  color: #94a3b8;
  font-size: .66rem;
}

.stats-rel-pair-title span {
  color: #6366f1;
}

.stats-rel-pair-profile-grid {
  grid-template-columns: repeat(3, minmax(0,1fr));
  margin-bottom: 14px;
}

.stats-rel-neighbour-list {
  display: grid;
  gap: 5px;
}

.stats-rel-neighbour-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
  padding: 6px 8px;
  color: #475569;
  text-align: left;
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
}

.stats-rel-neighbour-list button:hover {
  border-color: #c7d2fe;
  background: #f8faff;
}

.stats-rel-neighbour-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-rel-neighbour-list strong {
  color: #4338ca;
  font-variant-numeric: tabular-nums;
}

/* shared visual language for relation co-occurrence and relation structures */
.stats-relations-view-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
  align-items: start;
}

.stats-relation-workbench-card {
  margin-top: 0;
  border-color: #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

.stats-relation-workbench-card + .stats-relation-workbench-card {
  margin-top: 0;
}

.stats-results-surface:empty {
  display: none;
}

.stats-results-surface:not(:empty) {
  margin-top: 16px !important;
  border-top: 1px solid #eef2f7;
  padding-top: 15px;
}

.stats-results-surface .stats-box,
.stats-relation-results-card .stats-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fbfdff;
  box-shadow: none;
}

.stats-tool-grid--3 {
  grid-template-columns: repeat(3, minmax(0,1fr));
}

#tab-chains .stats-tool-card {
  margin-top: 0;
  margin-bottom: 16px;
}

#tab-chains .chains-controls-grid {
  margin-top: 0;
}

#chainsRelType,
#chainsMinLength,
#chainsDirection {
  width: 100%;
  min-width: 0;
  min-height: 42px;
}

.stats-relation-results-card {
  overflow: hidden;
}

.stats-results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stats-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.stats-chains-table-wrap {
  margin-top: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.stats-chains-table-wrap .stats-table {
  margin: 0;
  border: 0;
}

.stats-relation-legend-card {
  margin-top: 0 !important;
  background: #f8fafc;
}

.stats-relation-legend-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
}

.stats-relation-legend-grid > div {
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #fff;
  padding: 10px 12px;
}

.stats-relation-legend-grid strong,
.stats-relation-legend-grid span {
  display: block;
}

.stats-relation-legend-grid strong {
  margin-bottom: 4px;
  color: #334155;
  font-size: .82rem;
}

.stats-relation-legend-grid span {
  color: #64748b;
  font-size: .8rem;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .stats-relations-explorer {
    grid-template-columns: minmax(340px, 440px) minmax(0,1fr);
    gap: 18px;
  }
  .stats-relation-two-col {
    grid-template-columns: 1fr;
  }
  .stats-rel-connector {
    transform: rotate(90deg);
    justify-self: center;
    width: 70px;
  }
  .stats-rel-pair-profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .stats-relations-explorer,
  .stats-relations-view-grid,
  .stats-tool-grid--3 {
    grid-template-columns: 1fr;
  }
  .stats-relation-list-card {
    position: static;
  }
  .stats-relation-ranking {
    max-height: 500px;
    min-height: 0;
  }
  .stats-relation-profile-metrics {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .stats-relation-legend-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .stats-relations-toolbar,
  .stats-rel-pairs-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .stats-relations-toolbar .stats-tag-controls-right,
  .stats-rel-pairs-controls {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }
  .stats-relations-toolbar .stats-search-field,
  .stats-rel-pairs-controls .stats-search-field {
    width: 100%;
    min-width: 0;
  }
  .stats-relation-rank-row,
  .stats-rel-pair-row {
    grid-template-columns: 24px minmax(0,1fr) 58px;
  }
  .stats-relation-rank-pct {
    display: none;
  }
  .stats-rel-pair-flow {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .stats-rel-pair-arrow {
    justify-self: start;
  }
  .stats-rel-pair-highlight {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .stats-rel-pair-highlight > b {
    margin-left: 0;
  }
}

/* ==========================================================
   Speaker hub + refreshed tag sequence / distribution views
   ========================================================== */
.stats-page-heading--speakers,
.stats-page-heading--tags {
  margin-bottom: 18px;
}

.stats-analysis-workbench-card {
  margin-top: 0;
  margin-bottom: 16px;
  border-color: #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

.stats-analysis-results-stack {
  display: grid;
  gap: 16px;
}

.stats-analysis-results-stack > :empty {
  display: none;
}

.stats-analysis-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 11px 13px;
  color: #64748b;
  font-size: .8rem;
  line-height: 1.5;
}

.stats-analysis-note strong {
  flex: 0 0 auto;
  color: #334155;
}

.stats-btn--secondary {
  border-color: #d8dee8;
  background: #fff;
  color: #475569;
}

.stats-btn--secondary:hover {
  border-color: #c7d2fe;
  background: #f8faff;
  color: #4338ca;
}

.stats-tool-card__header--split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.stats-segmented--compact {
  flex: 0 0 auto;
}

.stats-segmented--field {
  width: 100%;
  min-height: 42px;
}

.stats-segmented--field button {
  flex: 1 1 0;
}

/* Tag sequence refresh */
#tab-order .order-summary-wrap,
#tab-order .order-matrix-wrap,
#tab-order .order-top-transitions,
#tab-order .order-examples {
  margin: 0;
}

#tab-order .order-summary-boxes,
#tab-order .order-matrix-card,
#tab-order .order-top-card,
#tab-order .order-examples-card {
  margin-top: 0;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

#tab-order .order-matrix-scroll,
#tab-order .order-top-table-wrap {
  border-color: #e2e8f0;
  border-radius: 11px;
}

/* Document-position refresh */
.stats-position-summary {
  display: grid;
  grid-template-columns: minmax(220px,.75fr) minmax(0,2fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

.stats-position-summary__identity {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid #eef2f7;
  padding-right: 18px;
}

.stats-position-summary__identity strong {
  margin-top: 4px;
  color: #1e293b;
  font-size: 1.08rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stats-position-summary__identity small {
  margin-top: 3px;
  color: #64748b;
  font-size: .75rem;
  font-style: italic;
}

.stats-position-summary__metrics {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 10px;
}

.stats-position-summary__metrics > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
  border: 1px solid #eef2f7;
  border-radius: 11px;
  background: #fbfdff;
  padding: 10px 12px;
}

.stats-position-summary__metrics span {
  color: #64748b;
  font-size: .72rem;
  font-weight: 700;
}

.stats-position-summary__metrics strong {
  margin-top: 5px;
  color: #1e293b;
  font-size: 1rem;
  line-height: 1.3;
}

.stats-position-bins {
  display: grid;
  grid-template-columns: repeat(5,minmax(0,1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stats-position-bin {
  display: grid;
  grid-template-rows: 92px auto auto auto;
  justify-items: center;
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(15,23,42,.035);
}

.stats-position-bin.is-peak {
  border-color: #c7d2fe;
  background: #fafaff;
  box-shadow: 0 0 0 2px rgba(99,102,241,.06);
}

.stats-position-bin__bar {
  display: flex;
  align-items: flex-end;
  width: 28px;
  height: 84px;
  border-radius: 7px;
  background: #eef2f7;
  overflow: hidden;
}

.stats-position-bin__bar i {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 7px 7px 0 0;
  background: #818cf8;
}

.stats-position-bin.is-peak .stats-position-bin__bar i {
  background: #6366f1;
}

.stats-position-bin > strong {
  margin-top: 6px;
  color: #1e293b;
  font-size: .95rem;
}

.stats-position-bin > span {
  color: #4f46e5;
  font-size: .75rem;
  font-weight: 800;
}

.stats-position-bin > small {
  margin-top: 2px;
  color: #94a3b8;
  font-size: .67rem;
}

.stats-position-table-card {
  margin-top: 0;
}

/* Speakers: overview */
.stats-speaker-kpis {
  margin-bottom: 16px;
}

.stats-speaker-card-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-speaker-card {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  padding: 15px;
  color: inherit;
  text-align: left;
  font: inherit;
  box-shadow: 0 1px 4px rgba(15,23,42,.045);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.stats-speaker-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 6px 18px rgba(79,70,229,.09);
  transform: translateY(-1px);
}

.stats-speaker-card__head {
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
}

.stats-speaker-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #eef2ff;
  color: #4338ca;
  font-size: .9rem;
  font-weight: 850;
}

.stats-speaker-avatar--lg {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 1.05rem;
}

.stats-speaker-card__identity {
  min-width: 0;
}

.stats-speaker-card__identity strong,
.stats-speaker-card__identity span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-speaker-card__identity strong {
  color: #1e293b;
  font-size: .9rem;
}

.stats-speaker-card__identity span {
  margin-top: 2px;
  color: #94a3b8;
  font-size: .69rem;
  text-transform: capitalize;
}

.stats-speaker-card__open {
  color: #6366f1;
  font-size: 1.05rem;
  font-weight: 900;
}

.stats-speaker-card__metrics {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 6px;
  margin-top: 13px;
}

.stats-speaker-card__metrics span {
  min-width: 0;
  border: 1px solid #eef2f7;
  border-radius: 9px;
  background: #fbfdff;
  padding: 7px 6px;
  color: #64748b;
  font-size: .61rem;
  text-align: center;
}

.stats-speaker-card__metrics strong {
  display: block;
  margin-bottom: 2px;
  color: #1e293b;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-card__bars {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.stats-speaker-card__bars > div {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 5px 8px;
  align-items: center;
  color: #64748b;
  font-size: .67rem;
}

.stats-speaker-card__bars strong {
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-card__bars > div > div {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.stats-speaker-card__bars i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #818cf8;
}

.stats-speaker-card__foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  border-top: 1px solid #eef2f7;
  padding-top: 9px;
  color: #94a3b8;
  font-size: .65rem;
}

.stats-speaker-tag-distribution-card {
  margin-top: 0;
}

.stats-speaker-ranking {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.stats-speaker-distribution-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 10px;
}

.stats-speaker-distribution-head > span {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef2ff;
  padding: 5px 9px;
  color: #4338ca;
  font-size: .7rem;
}

.stats-speaker-tag-label {
  display: block;
  min-width: 0;
}

.stats-speaker-tag-label strong,
.stats-speaker-tag-label small {
  display: block;
  overflow-wrap: anywhere;
}

.stats-speaker-tag-label strong {
  color: #1e293b;
  font-size: .78rem;
}

.stats-speaker-tag-label small {
  margin-top: 2px;
  color: #94a3b8;
  font-size: .66rem;
  font-style: italic;
}

.stats-speaker-rank-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 72px;
  gap: 12px;
  align-items: center;
  min-width: 0;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
}

.stats-speaker-rank-row--button {
  width: 100%;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.stats-speaker-rank-row--button:hover {
  border-color: #c7d2fe;
  background: #fafaff;
}

.stats-speaker-rank-main {
  min-width: 0;
}

.stats-speaker-rank-main > strong {
  color: #334155;
  font-size: .78rem;
}

.stats-speaker-rank-meta {
  display: block;
  margin-top: 2px;
  color: #94a3b8;
  font-size: .64rem;
}

.stats-speaker-rank-track {
  height: 4px;
  margin-top: 6px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.stats-speaker-rank-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #818cf8;
}

.stats-speaker-rank-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-rank-value strong,
.stats-speaker-rank-value small {
  display: block;
}

.stats-speaker-rank-value strong {
  color: #1e293b;
  font-size: .86rem;
}

.stats-speaker-rank-value small {
  margin-top: 2px;
  color: #6366f1;
  font-size: .65rem;
  font-weight: 750;
}

/* Speaker profile */
.stats-speaker-controls-card {
  margin-top: 0;
  margin-bottom: 16px;
}

.stats-speaker-profile-content,
.stats-speaker-compare-content {
  display: grid;
  gap: 16px;
}

.stats-speaker-profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

.stats-speaker-profile-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.stats-speaker-profile-identity h2 {
  margin: 0;
  color: #1e293b;
  font-size: 1.1rem;
}

.stats-speaker-profile-identity > div > span {
  display: block;
  margin-top: 3px;
  color: #94a3b8;
  font-size: .72rem;
  text-transform: capitalize;
}

.stats-speaker-profile-metrics {
  flex: 1 1 auto;
  margin: 0;
}

.stats-speaker-profile-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 14px;
}

.stats-speaker-profile-grid .stats-tag-profile-section {
  margin: 0;
}

.stats-speaker-mini-metrics {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
  margin-top: 10px;
}

.stats-speaker-mini-metrics span {
  border: 1px solid #eef2f7;
  border-radius: 9px;
  background: #fbfdff;
  padding: 8px 10px;
  color: #64748b;
  font-size: .68rem;
}

.stats-speaker-mini-metrics strong {
  margin-right: 5px;
  color: #1e293b;
}

.stats-speaker-examples-section {
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  padding: 15px;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
}

.stats-speaker-examples {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.stats-speaker-example-card {
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  box-shadow: none;
}

.stats-speaker-example-context {
  display: grid;
  grid-template-columns: 92px minmax(0,1fr);
  gap: 8px;
  align-items: start;
  margin-top: 9px;
  border-top: 1px solid #eef2f7;
  padding-top: 9px;
}

.stats-speaker-example-context > span {
  color: #64748b;
  font-size: .68rem;
  font-weight: 800;
}

.stats-speaker-example-context > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.stats-results-note {
  margin-top: 10px;
  color: #94a3b8;
  font-size: .7rem;
  text-align: center;
}

/* Speaker comparison */
.stats-speaker-compare-hero {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
  gap: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  background: #fff;
  padding: 14px 16px;
}

.stats-speaker-compare-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stats-speaker-compare-name--right {
  justify-content: flex-end;
  text-align: right;
}

.stats-speaker-compare-name strong {
  min-width: 0;
  overflow: hidden;
  color: #1e293b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-speaker-compare-center {
  border-radius: 999px;
  background: #f1f5f9;
  padding: 4px 8px;
  color: #94a3b8;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats-speaker-compare-metrics {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.stats-speaker-compare-metric {
  display: grid;
  grid-template-columns: minmax(120px,1fr) 86px minmax(50px,.6fr) 86px;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid #eef2f7;
}

.stats-speaker-compare-metric:last-child {
  border-bottom: 0;
}

.stats-speaker-compare-metric span {
  color: #64748b;
  font-size: .73rem;
  font-weight: 700;
}

.stats-speaker-compare-metric strong {
  color: #1e293b;
  font-size: .83rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-compare-metric i {
  height: 1px;
  background: #e2e8f0;
}

.stats-speaker-compare-grid {
  display: grid;
  grid-template-columns: minmax(0,1.35fr) minmax(300px,.65fr);
  gap: 14px;
}

.stats-speaker-diff-list {
  display: grid;
  gap: 7px;
}

.stats-speaker-diff-row {
  display: grid;
  grid-template-columns: minmax(190px,1fr) minmax(220px,1.1fr) 70px;
  gap: 10px;
  align-items: center;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  padding: 8px 10px;
}

.stats-speaker-diff-label {
  min-width: 0;
}

.stats-speaker-diff-label > small {
  display: block;
  margin-top: 2px;
  color: #94a3b8;
  font-size: .62rem;
}

.stats-speaker-diff-values {
  display: grid;
  grid-template-columns: 44px minmax(80px,1fr) 44px;
  gap: 6px;
  align-items: center;
  color: #475569;
  font-size: .68rem;
  text-align: center;
}

.stats-speaker-diff-track {
  height: 6px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.stats-speaker-diff-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stats-speaker-diff-track i.is-a { background: #818cf8; }
.stats-speaker-diff-track i.is-b { background: #a78bfa; }

.stats-speaker-diff-delta {
  text-align: right;
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-diff-delta.is-a { color: #4338ca; }
.stats-speaker-diff-delta.is-b { color: #7c3aed; }

.stats-speaker-rel-compare {
  display: grid;
  gap: 6px;
}

.stats-speaker-rel-compare > div {
  display: grid;
  grid-template-columns: minmax(0,1fr) 46px minmax(30px,.4fr) 46px;
  gap: 7px;
  align-items: center;
  border-bottom: 1px solid #eef2f7;
  padding: 7px 0;
}

.stats-speaker-rel-compare > div:last-child { border-bottom: 0; }
.stats-speaker-rel-compare span { min-width: 0; overflow: hidden; color: #475569; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.stats-speaker-rel-compare strong { color: #1e293b; font-size: .78rem; text-align: center; }
.stats-speaker-rel-compare i { height: 1px; background: #e2e8f0; }

.stats-speaker-direct-interactions {
  margin: 0;
}

.stats-speaker-interaction-pair {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px;
}

.stats-speaker-interaction-pair > div {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 5px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #fbfdff;
  padding: 10px 12px;
}

.stats-speaker-interaction-pair strong {
  color: #334155;
  font-size: .75rem;
}

.stats-speaker-interaction-pair span {
  color: #4338ca;
  font-size: 1rem;
  font-weight: 850;
}

.stats-speaker-interaction-pair small {
  grid-column: 1 / -1;
  color: #94a3b8;
  font-size: .66rem;
}

@media (max-width: 1120px) {
  .stats-speaker-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stats-speaker-profile-hero { align-items: flex-start; flex-direction: column; }
  .stats-speaker-profile-metrics { width: 100%; }
  .stats-speaker-compare-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .stats-position-summary { grid-template-columns: 1fr; }
  .stats-position-summary__identity { border-right: 0; border-bottom: 1px solid #eef2f7; padding: 0 0 12px; }
  .stats-position-bins { grid-template-columns: repeat(5,minmax(88px,1fr)); overflow-x: auto; padding-bottom: 4px; }
  .stats-speaker-profile-grid { grid-template-columns: 1fr; }
  .stats-speaker-diff-row { grid-template-columns: 1fr; }
  .stats-speaker-diff-delta { text-align: left; }
}

@media (max-width: 680px) {
  .stats-tool-card__header--split { flex-direction: column; }
  .stats-segmented--compact { width: 100%; }
  .stats-speaker-card-grid { grid-template-columns: 1fr; }
  .stats-speaker-card__metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stats-position-summary__metrics { grid-template-columns: 1fr; }
  .stats-speaker-compare-hero { grid-template-columns: 1fr; }
  .stats-speaker-compare-name--right { justify-content: flex-start; text-align: left; }
  .stats-speaker-compare-center { justify-self: start; }
  .stats-speaker-compare-metric { grid-template-columns: minmax(0,1fr) 58px 18px 58px; }
  .stats-speaker-interaction-pair { grid-template-columns: 1fr; }
  .stats-speaker-example-context { grid-template-columns: 1fr; }
}
.stats-speaker-rel-compare strong small {
  display: block;
  margin-top: 1px;
  color: #94a3b8;
  font-size: .58rem;
  font-weight: 700;
}

/* ========================================================================== */
/* Advanced analyses refresh: associations + entropy                          */
/* ========================================================================== */
.stats-advanced-analysis-view {
  --advanced-accent: #6d5bd0;
}

.stats-page-heading--advanced {
  align-items: flex-start;
  gap: 1rem;
}

.stats-page-heading--advanced h1 {
  margin-bottom: .3rem;
}

.stats-analysis-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: .45rem .7rem;
  border-radius: 999px;
  border: 1px solid #ded8f6;
  background: #f7f5ff;
  color: #5b4bb4;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1;
}

.stats-advanced-workbench-card,
.stats-advanced-matrix-card,
.stats-advanced-chart-card,
.stats-advanced-table-card,
.stats-selected-pair-card,
.stats-assoc-reading-card,
.stats-assoc-examples-card {
  border-color: #e6e2f4;
}

.stats-analysis-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: .9rem 0 1rem;
  padding: .8rem .9rem;
  border: 1px solid #e8e6ef;
  border-radius: 12px;
  background: #fafafd;
}

.stats-analysis-level-label {
  color: #4b5563;
  font-size: .9rem;
  font-weight: 700;
}

.stats-segmented-control {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid #dcd9e7;
  border-radius: 10px;
  background: #fff;
}

.stats-segmented-btn {
  appearance: none;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #5f6570;
  cursor: pointer;
  font: inherit;
  font-size: .84rem;
  font-weight: 700;
  padding: .48rem .72rem;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.stats-segmented-btn:hover {
  background: #f2f0f8;
}

.stats-segmented-btn.active {
  background: #fff;
  color: #413690;
  box-shadow: 0 1px 5px rgba(41, 35, 79, .14);
}

.stats-assoc-select-grid {
  margin-top: .2rem;
}

.stats-selected-pair-card {
  padding: 1rem 1.15rem;
}

.stats-selected-pair-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.stats-selected-pair-head h2 {
  margin: .2rem 0 0;
  color: #25223a;
  font-size: 1.28rem;
  line-height: 1.25;
}

.stats-selected-pair-head h2 span {
  color: #8b86a4;
  font-weight: 500;
}

.stats-selected-pair-en {
  margin-top: .25rem;
  color: #7b7691;
  font-size: .86rem;
  font-style: italic;
}

.stats-result-count {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  border: 1px solid #ded9ef;
  border-radius: 999px;
  background: #faf8ff;
  color: #574b98;
  font-size: .78rem;
  font-weight: 700;
  padding: .38rem .62rem;
  white-space: nowrap;
}

.stats-advanced-kpis {
  margin: 0;
}

.stats-advanced-kpis .stats-box {
  min-height: 92px;
  border-color: #e8e5f2;
}

.stats-advanced-kpis .stats-box .label {
  color: #69657b;
}

.stats-assoc-reading-card {
  padding-bottom: .8rem;
}

.stats-assoc-key-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .65rem;
}

.stats-assoc-key-metrics > div {
  min-width: 0;
  padding: .78rem .82rem;
  border: 1px solid #e8e5f2;
  border-radius: 11px;
  background: #fbfaff;
}

.stats-assoc-key-metrics span,
.stats-assoc-key-metrics strong,
.stats-assoc-key-metrics small {
  display: block;
}

.stats-assoc-key-metrics span {
  color: #6c6879;
  font-size: .76rem;
  font-weight: 700;
}

.stats-assoc-key-metrics strong {
  margin-top: .2rem;
  color: #27233a;
  font-size: 1.2rem;
}

.stats-assoc-key-metrics small {
  margin-top: .15rem;
  color: #8a8499;
  font-size: .72rem;
}

.stats-analysis-details {
  margin-top: .8rem;
  border-top: 1px solid #ece9f3;
  padding-top: .65rem;
}

.stats-analysis-details summary {
  color: #544b83;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 700;
}

.stats-analysis-details .stats-table-scroll {
  margin-top: .65rem;
}

.stats-analysis-about-card,
.stats-analysis-callout,
.stats-analysis-formula-note {
  border: 1px solid #e4e0f1;
  border-radius: 12px;
  background: #fbfaff;
  color: #514d61;
}

.stats-analysis-about-card {
  padding: .9rem 1rem;
}

.stats-analysis-about-card strong,
.stats-analysis-callout strong,
.stats-analysis-formula-note strong {
  color: #3b3557;
}

.stats-analysis-about-card p,
.stats-analysis-callout p {
  margin: .35rem 0 0;
  line-height: 1.52;
}

.stats-analysis-scope-note {
  display: inline-block;
  margin-top: .55rem;
  color: #736d86;
  font-size: .78rem;
}

.stats-analysis-callout {
  margin-top: .8rem;
  padding: .8rem 1rem;
  border-left: 4px solid #8172ca;
}

.stats-advanced-chart-card,
.stats-advanced-table-card,
.stats-advanced-matrix-card {
  margin-top: 1rem;
}

.stats-table-scroll {
  width: 100%;
  overflow-x: auto;
}

.stats-assoc-matrix-scroll {
  padding-bottom: .2rem;
}

.stats-assoc-matrix {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  table-layout: fixed;
}

.stats-assoc-matrix th,
.stats-assoc-matrix td {
  padding: 0;
  border: 0;
  background: transparent;
  vertical-align: middle;
}

.stats-assoc-matrix th {
  max-width: 125px;
  color: #5d586d;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.stats-assoc-matrix th span,
.stats-assoc-matrix th small {
  display: block;
}

.stats-assoc-matrix th small {
  margin-top: 2px;
  color: #9a94a8;
  font-size: .62rem;
  font-weight: 500;
  font-style: italic;
}

.stats-assoc-matrix tbody th {
  min-width: 115px;
  padding-right: .4rem;
  text-align: right;
}

.stats-assoc-matrix-corner {
  min-width: 115px;
}

.stats-assoc-matrix-cell {
  width: 64px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid rgba(92, 76, 170, calc(.12 + var(--assoc-strength, 0) * .35));
  border-radius: 8px;
  background: rgba(112, 94, 199, calc(.035 + var(--assoc-strength, 0) * .22));
  color: #38324d;
  cursor: pointer;
  font: inherit;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.stats-assoc-matrix-cell:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: #8b7fd1;
  box-shadow: 0 3px 10px rgba(67, 56, 125, .12);
}

.stats-assoc-matrix-cell:disabled {
  opacity: .38;
  cursor: default;
}

.stats-assoc-matrix-cell strong {
  font-size: .9rem;
}

.stats-assoc-matrix-cell small {
  color: #817b91;
  font-size: .65rem;
}

.stats-analysis-matrix-note {
  margin: .65rem 0 0;
  color: #827d8d;
  font-size: .76rem;
}

.stats-tool-card__header--split {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.stats-assoc-examples-list {
  display: grid;
  gap: .75rem;
}

.stats-assoc-example-card {
  margin: 0;
}

.stats-assoc-example-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin-top: .7rem;
}

.stats-assoc-example-column {
  min-width: 0;
  padding: .65rem .7rem;
  border: 1px solid #ece9f3;
  border-radius: 10px;
  background: #fcfbfe;
}

.stats-assoc-example-label {
  display: flex;
  flex-direction: column;
  gap: .08rem;
  margin-bottom: .5rem;
  color: #4d4764;
  font-size: .78rem;
}

.stats-assoc-example-label small {
  color: #918ba0;
  font-style: italic;
}

.stats-assoc-example-ann {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .45rem;
  align-items: start;
  margin-top: .42rem;
  color: #4b4755;
  font-size: .8rem;
  line-height: 1.35;
}

.stats-assoc-example-ann .inline-tag {
  grid-row: span 2;
  white-space: normal;
}

.stats-assoc-example-ann small {
  color: #8e8999;
  font-style: italic;
}

.stats-entropy-bars .bar {
  grid-template-columns: minmax(150px, 260px) minmax(180px, 1fr) auto;
}

.stats-entropy-bar .bar__label span,
.stats-entropy-bar .bar__label small {
  display: block;
}

.stats-entropy-bar .bar__label small {
  margin-top: 1px;
  color: #9993a5;
  font-size: .68rem;
  font-style: italic;
}

.stats-entropy-bar .bar__value small {
  color: #8d8798;
}

.stats-entropy-tag-cell strong,
.stats-entropy-tag-cell small {
  display: block;
}

.stats-entropy-tag-cell small {
  margin-top: .1rem;
  color: #938d9e;
  font-size: .72rem;
  font-style: italic;
}

.stats-analysis-formula-note {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  margin-top: .75rem;
  padding: .7rem .8rem;
  font-size: .78rem;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .stats-assoc-key-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-assoc-example-columns {
    grid-template-columns: 1fr;
  }
  .stats-selected-pair-head,
  .stats-tool-card__header--split,
  .stats-analysis-level-row {
    align-items: stretch;
    flex-direction: column;
  }
  .stats-result-count {
    align-self: flex-start;
  }
}

@media (max-width: 620px) {
  .stats-assoc-key-metrics {
    grid-template-columns: 1fr;
  }
  .stats-analysis-formula-note {
    flex-direction: column;
  }
  .stats-entropy-bars .bar {
    grid-template-columns: 1fr;
  }
}

/* ========================================================================== */
/* Associations layout fix + visual refinement                                */
/* ========================================================================== */

/* Legacy #assocMetrics styles used to turn every new analysis card into a
   separate auto-fit column. Keep the refreshed view as one vertical flow. */
#tab-assoc #assocMetrics.stats-analysis-results-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  grid-template-columns: none;
  margin: 16px 0 0;
  min-width: 0;
}

#tab-assoc #assocMetrics.stats-analysis-results-stack > * {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#tab-assoc .stats-selected-pair-card {
  padding: 16px 18px;
  background: linear-gradient(180deg, #fff 0%, #fcfbff 100%);
}

#tab-assoc .stats-selected-pair-main {
  min-width: 0;
  flex: 1 1 auto;
}

#tab-assoc .stats-assoc-pair-display {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-top: 8px;
}

#tab-assoc .stats-assoc-pair-term {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #e8e3f5;
  border-radius: 12px;
  background: #fff;
}

#tab-assoc .stats-assoc-pair-letter {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: #f0edff;
  color: #5142a4;
  font-size: .72rem;
  font-weight: 800;
}

#tab-assoc .stats-assoc-pair-term strong,
#tab-assoc .stats-assoc-pair-term small {
  display: block;
  overflow-wrap: anywhere;
}

#tab-assoc .stats-assoc-pair-term strong {
  color: #25223a;
  font-size: .98rem;
  line-height: 1.28;
}

#tab-assoc .stats-assoc-pair-term small {
  margin-top: 3px;
  color: #817b91;
  font-size: .76rem;
  font-style: italic;
  line-height: 1.3;
}

#tab-assoc .stats-assoc-pair-arrow {
  align-self: center;
  color: #8d86a5;
  font-size: 1.15rem;
  font-weight: 700;
}

#tab-assoc .stats-assoc-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

#tab-assoc .stats-assoc-summary-grid .stats-box {
  min-width: 0;
  min-height: 100px;
  padding: 14px 16px;
  box-shadow: none;
  transition: border-color .15s ease, background .15s ease;
}

#tab-assoc .stats-assoc-summary-grid .stats-box:hover {
  transform: none;
  border-color: #d9d2ef;
  background: #fbfaff;
}

#tab-assoc .stats-assoc-summary-grid .stats-box--accent {
  border-color: #d9d2f3;
  background: #f8f6ff;
}

#tab-assoc .stats-assoc-summary-grid .label {
  color: #6b667b;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.25;
}

#tab-assoc .stats-assoc-summary-grid .value {
  margin-top: 5px;
  font-size: 1.65rem;
  line-height: 1;
}

#tab-assoc .stats-box__hint {
  margin-top: 6px;
  color: #8a8497;
  font-size: .73rem;
  font-weight: 600;
}

#tab-assoc .stats-assoc-explanation-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, .85fr);
  gap: 16px;
  align-items: start;
}

#tab-assoc .stats-assoc-reading-card,
#tab-assoc .stats-assoc-about-card {
  margin: 0;
  min-width: 0;
}

#tab-assoc .stats-assoc-about-card {
  background: #fbfaff;
}

#tab-assoc .stats-assoc-key-metrics {
  grid-template-columns: repeat(4, minmax(108px, 1fr));
}

#tab-assoc .stats-assoc-key-metrics > div {
  min-height: 82px;
}

#tab-assoc .stats-assoc-examples-card {
  margin: 0;
}

#tab-assoc .stats-assoc-example-card {
  padding: 16px;
}

#tab-assoc .stats-assoc-example-columns {
  gap: 12px;
}

#tab-assoc .stats-assoc-example-column {
  padding: 10px 11px;
  overflow: hidden;
}

#tab-assoc .stats-assoc-example-ann {
  grid-template-columns: minmax(88px, max-content) minmax(0, 1fr);
  gap: 4px 9px;
}

#tab-assoc .stats-assoc-example-ann .inline-tag {
  max-width: 190px;
  overflow-wrap: anywhere;
}

#tab-assoc .stats-assoc-example-ann > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

#tab-assoc .stats-assoc-same-tag-warning {
  border: 1px solid #eadfc1;
  background: #fffdf7;
  color: #6b5b31;
}

#tab-assoc .stats-assoc-matrix-wrap {
  min-width: 0;
}

#tab-assoc .stats-assoc-matrix-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 6px;
}

#tab-assoc .stats-assoc-matrix-cell--diagonal {
  border-style: dashed;
  background: #f8f8fb;
  color: #aaa5b4;
  opacity: 1;
}

@media (max-width: 1120px) {
  #tab-assoc .stats-assoc-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tab-assoc .stats-assoc-explanation-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  #tab-assoc .stats-assoc-pair-display {
    grid-template-columns: 1fr;
  }

  #tab-assoc .stats-assoc-pair-arrow {
    justify-self: start;
    transform: rotate(90deg);
  }

  #tab-assoc .stats-assoc-key-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  #tab-assoc .stats-assoc-summary-grid,
  #tab-assoc .stats-assoc-key-metrics {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Statistics — Macrostructures 1.0
   ========================================================= */
.stats-page-heading--macrostructures .stats-eyebrow {
  display: inline-block;
  margin-bottom: 0.35rem;
}

.stats-overview-macro-card {
  margin-top: 0.9rem;
}

.stats-overview-macro-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stats-macro-kpi-grid .stats-kpi-card small {
  display: block;
  margin-top: 0.3rem;
  color: var(--ann-muted, #64748b);
  font-size: 0.72rem;
  font-weight: 600;
}

.stats-macro-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.stats-macro-four-panels {
  margin-top: 0.8rem;
}

.stats-macro-bars .basic-bar__main {
  min-width: 0;
}

.stats-macro-bars .basic-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-macro-table-card {
  margin-top: 0.8rem;
}

.stats-macro-table-wrap {
  overflow-x: auto;
}

.stats-macro-table {
  width: 100%;
  min-width: 860px;
}

.stats-macro-table th button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 750;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.stats-macro-table th button::after {
  content: "";
  display: inline-block;
  width: 0.75rem;
  margin-left: 0.25rem;
  color: var(--ann-muted, #64748b);
}

.stats-macro-table th button[data-sort-dir="asc"]::after {
  content: "↑";
}

.stats-macro-table th button[data-sort-dir="desc"]::after {
  content: "↓";
}

.stats-macro-name-cell {
  min-width: 200px;
}

.stats-macro-continuity {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--ann-border, #d6dee8) 75%, transparent);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.stats-macro-continuity.is-continuous {
  background: color-mix(in srgb, var(--ann-surface, #fff) 78%, #dff4e5);
}

.stats-macro-continuity.is-discontinuous {
  background: color-mix(in srgb, var(--ann-surface, #fff) 78%, #fff0d6);
}

.stats-macro-warning-card {
  border-color: color-mix(in srgb, #d69b42 55%, var(--ann-border, #d6dee8));
}

.stats-macro-cycle-warning {
  margin-top: 0.7rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, #d69b42 55%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, #fff3d8 55%, transparent);
  font-size: 0.8rem;
  line-height: 1.4;
}

.stats-macro-empty {
  max-width: 760px;
  margin-top: 0.8rem;
}

@media (max-width: 1180px) {
  .stats-overview-macro-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .stats-macro-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-overview-macro-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================
   Statistics Tags UX 2.0 — compact subnavigation + workbenches
   ========================================================== */

/* The tag subnavigation behaves like a compact segmented control instead of
   a full-width white card. It remains sticky, but aligns with page content. */
.stats-subnav-shell {
  padding-left: max(64px, calc((100vw - 1800px) / 2 + 64px));
  padding-right: max(64px, calc((100vw - 1800px) / 2 + 64px));
}

.stats-context-nav--tags {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  gap: 3px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 2px 10px rgba(15,23,42,.045);
}

.stats-context-nav--tags .stats-context-tab {
  min-height: 34px;
  padding: 6px 13px;
  border-radius: 9px;
  font-size: .88rem;
}

.stats-context-nav--tags .stats-context-tab.active {
  background: #eef2ff;
  color: #3730a3;
  box-shadow: inset 0 0 0 1px #c7d2fe, 0 1px 2px rgba(67,56,202,.06);
}

/* All tag-analysis pages share the same vertical rhythm. */
.stats-tags-analysis-view,
.stats-cooc-tab.stats-tags-analysis-view {
  padding-top: 30px;
}

.stats-tags-analysis-view .stats-page-heading {
  margin-bottom: 18px;
}

/* Control panels are intentionally more compact and slightly tinted so that
   settings and results are visually distinct. */
.stats-tags-control-card {
  max-width: 1180px;
  padding: 15px 17px 16px;
  border-color: #dfe6ee;
  background: rgba(248,250,252,.92);
  box-shadow: 0 1px 3px rgba(15,23,42,.035);
}

.stats-workbench-label {
  margin-bottom: 11px;
  color: #475569;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .065em;
  text-transform: uppercase;
}

.stats-compact-control-grid {
  gap: 13px 16px;
}

.stats-compact-control-grid .stats-tool-field {
  gap: 6px;
}

.stats-compact-control-grid .stats-tool-field label,
.stats-profile-tag-select label {
  color: #475569;
  font-size: .78rem;
  font-weight: 700;
}

.stats-tool-actions--compact {
  margin-top: 13px;
}

.stats-tool-actions--compact .stats-btn {
  min-height: 36px;
  padding: 7px 14px;
}

/* Co-occurrence: compact compare panel, while results can still use width. */
.stats-cooccurrence-compare-card .cooccurrence-results:not(:empty) {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.stats-tag-profile-card {
  margin-top: 18px;
}

.stats-tag-profile-card .stats-tool-card__header {
  margin-bottom: 12px;
}

.stats-profile-tag-select {
  flex: 0 1 430px;
  width: min(430px, 100%);
  min-width: 280px;
}

.stats-profile-tag-select .select2-container,
.stats-profile-tag-select select {
  width: 100% !important;
}

.stats-single-tag-kpis {
  grid-template-columns: repeat(3, minmax(145px, 220px));
  justify-content: start;
  gap: 12px;
  margin: 14px 0 !important;
}

.stats-single-tag-kpis .stats-box {
  min-height: 92px;
}

.stats-box-note {
  margin-top: 3px;
  color: #64748b;
  font-size: .72rem;
}

.stats-result-intro {
  margin: 14px 0 10px;
  max-width: 850px;
  color: #64748b;
  font-size: .86rem;
  line-height: 1.5;
}

/* Sequence settings: detailed explanations are available on demand instead
   of taking over the first viewport. */
.stats-order-control-card {
  max-width: 1160px;
}

.stats-settings-explainer {
  max-width: 100%;
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
  padding-top: 9px;
  color: #64748b;
  font-size: .8rem;
}

.stats-settings-explainer summary {
  width: fit-content;
  cursor: pointer;
  color: #475569;
  font-weight: 700;
  list-style-position: outside;
}

.stats-settings-explainer summary:hover {
  color: #3730a3;
}

.stats-settings-help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px 18px;
  margin-top: 10px;
  padding: 12px 13px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: rgba(255,255,255,.8);
}

.stats-settings-help-grid > div {
  min-width: 0;
}

.stats-settings-help-grid > div > strong {
  display: block;
  margin-bottom: 3px;
  color: #334155;
  font-size: .76rem;
}

.stats-settings-help-grid .order-field-help {
  margin: 0;
  color: #64748b;
  font-size: .76rem;
  line-height: 1.45;
}

/* Position/distribution: one compact selector rather than a full-width form. */
.stats-position-control-card {
  max-width: 820px;
}

.stats-position-tag-field {
  max-width: 660px;
}

.stats-position-tag-field .select2-container,
.stats-position-tag-field select {
  width: 100% !important;
}

.stats-settings-explainer--inline {
  margin-top: 10px;
}

.stats-settings-explainer--inline p {
  max-width: 720px;
  margin: 9px 0 2px;
  line-height: 1.5;
}

/* Slightly denser result cards in the document-distribution view. */
#tab-position .stats-position-summary {
  padding: 13px 14px;
  gap: 14px;
}

#tab-position .stats-position-summary__metrics > div {
  min-height: 64px;
  padding: 8px 10px;
}

#tab-position .stats-position-bin {
  grid-template-rows: 74px auto auto auto;
  padding: 9px;
}

#tab-position .stats-position-bin__bar {
  height: 68px;
  width: 25px;
}

#tab-position .stats-position-bin.is-peak {
  border-color: #d6dcfb;
  box-shadow: 0 0 0 1px rgba(99,102,241,.045);
}

@media (max-width: 900px) {
  .stats-subnav-shell {
    padding-left: 18px;
    padding-right: 18px;
  }
  .stats-tags-control-card,
  .stats-order-control-card,
  .stats-position-control-card {
    max-width: none;
  }
  .stats-profile-tag-select {
    min-width: 0;
    width: 100%;
  }
  .stats-single-tag-kpis,
  .stats-settings-help-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   Statistics Speakers UX 2.0 — navigation, profile discovery,
   comparison clarity and direct-relation details
   ========================================================== */
.stats-context-nav--speakers {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  gap: 3px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 2px 10px rgba(15,23,42,.045);
}

.stats-context-nav--speakers .stats-context-tab {
  min-height: 34px;
  padding: 6px 13px;
  border-radius: 9px;
  font-size: .88rem;
}

.stats-context-nav--speakers .stats-context-tab.active {
  background: #eef2ff;
  color: #3730a3;
  box-shadow: inset 0 0 0 1px #c7d2fe, 0 1px 2px rgba(67,56,202,.06);
}

.stats-speaker-card__foot {
  align-items: center;
  flex-wrap: wrap;
}

.stats-speaker-hierarchy-summary {
  color: #64748b;
  line-height: 1.35;
}

.stats-speaker-profile-anchor {
  scroll-margin-top: 150px;
}

.stats-speaker-profile-nav {
  position: sticky;
  top: 116px;
  z-index: 115;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 5px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 3px 12px rgba(15,23,42,.06);
  backdrop-filter: blur(8px);
}

.stats-speaker-profile-nav button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 7px 11px;
  color: #64748b;
  font: inherit;
  font-size: .73rem;
  font-weight: 750;
  cursor: pointer;
}

.stats-speaker-profile-nav button:hover {
  background: #f8fafc;
  color: #334155;
}

.stats-speaker-profile-nav button.active {
  background: #eef2ff;
  color: #4338ca;
}

.stats-speaker-pagination {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  background: #fbfdff;
  padding: 8px 10px;
  color: #64748b;
  font-size: .69rem;
}

.stats-speaker-pagination__controls {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.stats-speaker-pagination button {
  width: 30px;
  height: 28px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #fff;
  color: #4338ca;
  font-weight: 800;
  cursor: pointer;
}

.stats-speaker-pagination button:disabled {
  color: #cbd5e1;
  cursor: default;
}

.stats-speaker-pagination label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stats-speaker-pagination select {
  min-height: 28px;
  border: 1px solid #dbe4ef;
  border-radius: 7px;
  background: #fff;
  padding: 2px 24px 2px 7px;
  color: #334155;
  font: inherit;
}

.stats-speaker-examples + .stats-speaker-pagination {
  margin-top: 12px;
}

.stats-speaker-compare-table-header,
.stats-speaker-compare-metric {
  display: grid;
  grid-template-columns: minmax(120px,1fr) minmax(150px,.72fr) minmax(120px,1fr);
  gap: 12px;
  align-items: center;
}

.stats-speaker-compare-table-header {
  padding: 9px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.stats-speaker-compare-table-header strong {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  font-size: .72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-speaker-compare-table-header strong:last-child {
  text-align: right;
}

.stats-speaker-compare-table-header span {
  color: #94a3b8;
  font-size: .66rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stats-speaker-compare-metric {
  padding: 10px 14px;
}

.stats-speaker-compare-metric strong:first-child {
  text-align: left;
}

.stats-speaker-compare-metric strong:last-child {
  text-align: right;
}

.stats-speaker-compare-metric span {
  text-align: center;
}

.stats-section-help {
  margin: 4px 0 0;
  max-width: 760px;
  color: #94a3b8;
  font-size: .66rem;
  font-weight: 500;
  line-height: 1.45;
}

.stats-speaker-direct-interactions {
  border-color: #c7d2fe;
  box-shadow: 0 2px 10px rgba(79,70,229,.055);
}

.stats-speaker-direct-table-wrap {
  max-height: 360px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.stats-speaker-direct-table {
  min-width: 760px;
  margin: 0;
}

.stats-speaker-direct-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

.stats-relation-id-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  padding: 2px 7px;
  color: #4338ca;
  font-size: .68rem;
  font-weight: 850;
}

.stats-speaker-comparison-columns,
.stats-speaker-diff-row,
.stats-speaker-rel-compare > div {
  display: grid;
  grid-template-columns: minmax(180px,1.2fr) minmax(120px,.62fr) minmax(120px,.62fr) minmax(150px,.8fr);
  gap: 10px;
  align-items: center;
}

.stats-speaker-comparison-columns {
  margin: 8px 0 6px;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 10px 7px;
  color: #94a3b8;
  font-size: .63rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .035em;
}

.stats-speaker-comparison-columns strong {
  min-width: 0;
  overflow: hidden;
  color: #64748b;
  font-size: .65rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-speaker-diff-row {
  border: 1px solid #eef2f7;
  border-radius: 10px;
  padding: 8px 10px;
}

.stats-speaker-comparison-value {
  min-width: 0;
  color: #4338ca;
  font-size: .72rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-comparison-value.is-b {
  color: #7c3aed;
}

.stats-speaker-comparison-value i {
  display: block;
  height: 4px;
  margin-top: 5px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.stats-speaker-comparison-value b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #818cf8;
}

.stats-speaker-comparison-value.is-b b {
  background: #a78bfa;
}

.stats-speaker-diff-delta {
  min-width: 0;
  color: #64748b;
  font-size: .65rem;
  line-height: 1.35;
  text-align: right;
}

.stats-speaker-diff-delta strong {
  display: block;
  overflow: hidden;
  font-size: .66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-speaker-diff-delta.is-even {
  color: #94a3b8;
}

.stats-speaker-rel-compare > div {
  border-bottom: 1px solid #eef2f7;
  padding: 8px 10px;
}

.stats-speaker-rel-compare > div > span:first-child {
  color: #475569;
  font-size: .72rem;
  font-weight: 700;
}

.stats-speaker-rel-compare > div > strong {
  text-align: center;
}

.stats-speaker-rel-compare > div > .stats-speaker-diff-delta {
  text-align: right;
}

@media (max-width: 980px) {
  .stats-speaker-profile-nav { top: 108px; }
  .stats-speaker-comparison-columns,
  .stats-speaker-diff-row,
  .stats-speaker-rel-compare > div {
    grid-template-columns: minmax(160px,1fr) 92px 92px minmax(120px,.75fr);
  }
}

@media (max-width: 760px) {
  .stats-speaker-pagination {
    grid-template-columns: 1fr;
  }
  .stats-speaker-profile-nav {
    top: 106px;
  }
  .stats-speaker-compare-table-header,
  .stats-speaker-compare-metric {
    grid-template-columns: minmax(90px,1fr) minmax(110px,.8fr) minmax(90px,1fr);
  }
  .stats-speaker-comparison-columns,
  .stats-speaker-diff-row,
  .stats-speaker-rel-compare > div {
    grid-template-columns: 1fr 78px 78px;
  }
  .stats-speaker-comparison-columns > :last-child,
  .stats-speaker-diff-row > :last-child,
  .stats-speaker-rel-compare > div > :last-child {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* =========================================================
   TMM 5.10r — Speaker Comparison Table Polish
   Stable, readable comparison tables with explicit share deltas.
   ========================================================= */

/* The two comparison analyses need horizontal room for full speaker names and
   an explicit delta column. Stack them instead of compressing one into a
   narrow side card. */
.stats-speaker-compare-grid {
  grid-template-columns: minmax(0, 1fr);
}

.stats-speaker-comparison-table-shell {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.stats-speaker-comparison-table-shell > .stats-speaker-comparison-columns,
.stats-speaker-comparison-table-shell > .stats-speaker-diff-list,
.stats-speaker-comparison-table-shell > .stats-speaker-rel-compare {
  min-width: 760px;
}

.stats-speaker-comparison-columns,
.stats-speaker-diff-row,
.stats-speaker-rel-compare > div {
  grid-template-columns:
    minmax(190px, 1.15fr)
    minmax(160px, .85fr)
    minmax(160px, .85fr)
    minmax(180px, .9fr);
  gap: 14px;
}

.stats-speaker-comparison-columns {
  align-items: end;
  padding-left: 12px;
  padding-right: 12px;
}

.stats-speaker-comparison-columns strong {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.stats-speaker-diff-row,
.stats-speaker-rel-compare > div {
  padding-left: 12px;
  padding-right: 12px;
}

.stats-speaker-diff-delta {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  text-align: right;
  line-height: 1.25;
}

.stats-speaker-diff-delta strong {
  display: block;
  max-width: 100%;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.stats-speaker-diff-value {
  display: block;
  white-space: nowrap;
  font-size: .66rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.stats-speaker-diff-delta.is-even {
  align-items: flex-end;
}

.stats-speaker-rel-compare > div > strong {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
}

.stats-speaker-rel-compare > div > strong small {
  margin-top: 0;
}

@media (max-width: 980px) {
  .stats-speaker-comparison-columns,
  .stats-speaker-diff-row,
  .stats-speaker-rel-compare > div {
    grid-template-columns:
      minmax(180px, 1.1fr)
      minmax(145px, .82fr)
      minmax(145px, .82fr)
      minmax(170px, .9fr);
  }
}

/* On genuinely narrow screens preserve the table grammar and scroll inside
   the card instead of moving the difference cell to an unrelated new row. */
@media (max-width: 760px) {
  .stats-speaker-comparison-columns,
  .stats-speaker-diff-row,
  .stats-speaker-rel-compare > div {
    grid-template-columns:
      minmax(180px, 1.1fr)
      minmax(140px, .82fr)
      minmax(140px, .82fr)
      minmax(165px, .9fr);
  }

  .stats-speaker-comparison-columns > :last-child,
  .stats-speaker-diff-row > :last-child,
  .stats-speaker-rel-compare > div > :last-child {
    grid-column: auto;
    text-align: right;
  }
}

/* =========================================================
   TMM 5.10s — Speaker Interaction Network 1.0
   ========================================================= */
.stats-speaker-network-section {
  overflow: hidden;
}

.stats-speaker-network-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 16px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 92%, #f8fafc);
}

.stats-speaker-network-controls label {
  display: grid;
  gap: 5px;
  min-width: 180px;
}

.stats-speaker-network-controls label > span {
  color: #64748b;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.stats-speaker-network-controls select {
  min-height: 36px;
  border: 1px solid #dbe3ec;
  border-radius: 9px;
  background: #fff;
  padding: 0 34px 0 10px;
  color: #0f172a;
  font: inherit;
  font-size: .78rem;
}

.stats-speaker-network-hint {
  flex: 1 1 320px;
  align-self: center;
  color: #64748b;
  font-size: .72rem;
  line-height: 1.45;
}

.stats-speaker-network-canvas {
  position: relative;
  min-height: 520px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background:
    linear-gradient(rgba(148,163,184,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.055) 1px, transparent 1px),
    color-mix(in srgb, var(--stats-card-bg, #fff) 97%, #eef2ff);
  background-size: 24px 24px;
  overflow: hidden;
}

.stats-speaker-network-canvas svg {
  display: block;
  width: 100%;
  min-width: 680px;
  height: clamp(500px, 52vh, 620px);
  user-select: none;
  touch-action: none;
}

.stats-speaker-network-edge {
  cursor: pointer;
  transition: opacity .16s ease;
}

.stats-speaker-network-edge-line {
  stroke: #94a3b8;
  stroke-width: var(--edge-width, 2px);
  stroke-linecap: round;
  opacity: .66;
  transition: stroke .16s ease, opacity .16s ease, stroke-width .16s ease;
}

.stats-speaker-network-edge-hit {
  stroke: transparent;
  stroke-width: 16px;
  stroke-linecap: round;
}

.stats-speaker-network-edge:hover .stats-speaker-network-edge-line,
.stats-speaker-network-edge.is-active .stats-speaker-network-edge-line {
  stroke: #4f46e5;
  opacity: .95;
}

.stats-speaker-network-edge.is-active .stats-speaker-network-edge-line {
  stroke-width: calc(var(--edge-width, 2px) + 1.5px);
}

.stats-speaker-network-edge.is-dimmed {
  opacity: .12;
}

.stats-speaker-network-edge-count rect {
  fill: #eef2ff;
  stroke: #c7d2fe;
}

.stats-speaker-network-edge-count text {
  fill: #4338ca;
  font-size: 11px;
  font-weight: 850;
  pointer-events: none;
}

.stats-speaker-network-node {
  cursor: grab;
  transition: opacity .16s ease;
}

.stats-speaker-network-node:active {
  cursor: grabbing;
}

.stats-speaker-network-node circle {
  fill: #eef2ff;
  stroke: #818cf8;
  stroke-width: 2;
  filter: drop-shadow(0 3px 5px rgba(15,23,42,.12));
  transition: fill .16s ease, stroke .16s ease, stroke-width .16s ease;
}

.stats-speaker-network-node:hover circle,
.stats-speaker-network-node.is-selected circle {
  fill: #e0e7ff;
  stroke: #4338ca;
  stroke-width: 3;
}

.stats-speaker-network-node.is-compare circle {
  stroke: #4f46e5;
  stroke-width: 3;
}

.stats-speaker-network-node.is-dimmed {
  opacity: .18;
}

.stats-speaker-network-initials {
  fill: #312e81;
  font-size: 16px;
  font-weight: 900;
  pointer-events: none;
}

.stats-speaker-network-tooltip {
  position: absolute;
  z-index: 10;
  width: min(300px, calc(100% - 20px));
  white-space: pre-line;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 10px 28px rgba(15,23,42,.16);
  padding: 9px 10px;
  color: #1e293b;
  font-size: .72rem;
  line-height: 1.45;
  pointer-events: none;
}

.stats-speaker-network-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 9px;
  color: #64748b;
  font-size: .69rem;
}

.stats-speaker-network-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.stats-speaker-network-legend i {
  display: inline-block;
  flex: 0 0 auto;
}

.stats-speaker-network-legend i.is-node {
  width: 18px;
  height: 18px;
  border: 2px solid #818cf8;
  border-radius: 50%;
  background: #eef2ff;
}

.stats-speaker-network-legend i.is-edge {
  width: 30px;
  height: 0;
  border-top: 4px solid #94a3b8;
  border-radius: 999px;
}

.stats-speaker-network-empty {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 300px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  padding: 30px;
  text-align: center;
}

.stats-speaker-network-empty span {
  color: #64748b;
  font-size: .75rem;
}

@media (max-width: 780px) {
  .stats-speaker-network-canvas {
    overflow-x: auto;
  }
  .stats-speaker-network-canvas svg {
    height: 500px;
  }
  .stats-speaker-network-controls {
    align-items: stretch;
  }
  .stats-speaker-network-controls label,
  .stats-speaker-network-hint {
    flex-basis: 100%;
  }
}

/* =========================================================
   STATS 5.10t — Tag Sequence Flow 1.0
   Matrix and alluvial/Sankey-style views share the same sequence engine.
   ========================================================= */
.order-results-viewbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  max-width: 1160px;
  margin: 16px 0 12px;
  padding: 0 2px;
}

.order-results-viewbar-label {
  margin-bottom: 6px;
  color: #64748b;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.order-results-view-toggle {
  width: fit-content;
}

.order-flow-quick-status {
  max-width: 720px;
  color: #64748b;
  font-size: .78rem;
  line-height: 1.35;
  text-align: right;
}

.order-flow-only-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.order-flow-length-control {
  width: fit-content;
  max-width: 100%;
}

.order-flow-card {
  overflow: hidden;
  border: 1px solid #dfe6ef;
  border-radius: 16px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .045);
}

.order-flow-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid #e8edf3;
}

.order-flow-card-head h3 {
  margin: 0 0 4px;
  color: #172033;
  font-size: 1rem;
}

.order-flow-coverage {
  color: #475569;
  font-size: .82rem;
  font-weight: 700;
}

.order-flow-hidden-note {
  min-height: 1.2em;
  margin-top: 3px;
  color: #94a3b8;
  font-size: .72rem;
}

.order-flow-card-actions {
  flex: 0 0 auto;
}

.order-flow-selection-chip {
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef2ff;
  color: #3730a3;
  font: inherit;
  font-size: .76rem;
  font-weight: 750;
  cursor: pointer;
}

.order-flow-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

.order-flow-canvas {
  position: relative;
  width: 100%;
  min-height: 500px;
  background-image:
    linear-gradient(rgba(148, 163, 184, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .07) 1px, transparent 1px);
  background-size: 22px 22px;
}

.order-flow-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 500px;
  overflow: visible;
}

.order-flow-record {
  opacity: .45;
  cursor: pointer;
  transition: opacity .12s ease, filter .12s ease;
  vector-effect: non-scaling-stroke;
}

.order-flow-record:hover,
.order-flow-record.is-hovered,
.order-flow-record.is-selected {
  opacity: .9;
  filter: saturate(1.2);
}

.order-flow-record.is-dimmed,
.order-flow-record.is-hover-dimmed {
  opacity: .07;
}

.order-flow-node {
  cursor: pointer;
  transition: opacity .12s ease;
}

.order-flow-node rect {
  stroke: rgba(30, 41, 59, .28);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.order-flow-node.is-selected rect,
.order-flow-node.is-connected rect {
  stroke: #4f46e5;
  stroke-width: 2;
}

.order-flow-node.is-dimmed {
  opacity: .28;
}

.order-flow-node-label {
  fill: #243047;
  font-size: 12px;
  font-weight: 720;
  paint-order: stroke;
  stroke: rgba(255,255,255,.96);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}

.order-flow-stage-label {
  fill: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.order-flow-tooltip {
  position: absolute;
  z-index: 9;
  width: min(280px, calc(100vw - 40px));
  padding: 10px 11px;
  border: 1px solid #d7deea;
  border-radius: 11px;
  background: rgba(255,255,255,.98);
  color: #334155;
  box-shadow: 0 10px 28px rgba(15,23,42,.14);
  pointer-events: none;
  font-size: .75rem;
  line-height: 1.4;
}

.order-flow-tooltip-title {
  color: #172033;
  font-weight: 800;
}

.order-flow-tooltip-translation {
  margin-top: 1px;
  color: #7c8aa0;
  font-size: .7rem;
  font-style: italic;
}

.order-flow-tooltip-metric {
  margin-top: 7px;
}

.order-flow-tooltip-muted {
  margin-top: 3px;
  color: #64748b;
}

.order-flow-tooltip-subtitle {
  margin-top: 8px;
  color: #64748b;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.order-flow-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
}

.order-flow-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 10px 18px 12px;
  border-top: 1px solid #edf1f5;
  color: #64748b;
  font-size: .72rem;
}

.order-flow-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.order-flow-legend-band {
  display: inline-block;
  width: 28px;
  height: 6px;
  border-radius: 999px;
  background: #818cf8;
  opacity: .7;
}

.order-flow-empty {
  padding: 34px 22px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: rgba(255,255,255,.75);
  color: #64748b;
  text-align: center;
}

.order-flow-details-card {
  margin-top: 2px;
}

.order-flow-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.order-flow-detail-metrics {
  grid-template-columns: repeat(3, minmax(150px, 220px));
  justify-content: start;
  gap: 10px;
}

.order-flow-related-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.order-flow-related-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
  color: #334155;
  text-align: left;
  cursor: pointer;
}

.order-flow-related-row:hover {
  border-color: #c7d2fe;
  background: #f8faff;
}

.order-flow-triple-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
}

@media (max-width: 900px) {
  .order-results-viewbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .order-flow-quick-status {
    text-align: left;
  }

  .order-flow-card-head,
  .order-flow-details-head {
    flex-direction: column;
    align-items: stretch;
  }

  .order-flow-detail-metrics {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .order-flow-triple-grid {
    grid-template-columns: 1fr;
  }

  .order-flow-triple-grid .order-example-arrow {
    transform: rotate(90deg);
    min-height: 26px;
  }
}

/* =========================================================
   TMM 5.10u — Speaker Interaction Chord 1.0
   Second, circular view of the same speaker-interaction model.
   ========================================================= */
.stats-speaker-network-viewbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 2px;
}

.stats-speaker-network-viewbar > span {
  color: #64748b;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.stats-speaker-network-viewbar .stats-inline-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 90%, #f1f5f9);
}

.stats-speaker-network-viewbar .stats-inline-toggle button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: .74rem;
  font-weight: 750;
  cursor: pointer;
}

.stats-speaker-network-viewbar .stats-inline-toggle button.active {
  background: #fff;
  color: #312e81;
  box-shadow: 0 1px 4px rgba(15,23,42,.10);
}

.stats-speaker-network-summary {
  margin: 2px 0 8px;
  color: #64748b;
  font-size: .72rem;
  font-weight: 650;
}

.stats-speaker-chord-canvas {
  position: relative;
  min-height: 570px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background:
    radial-gradient(circle at center, rgba(99,102,241,.035), transparent 38%),
    linear-gradient(rgba(148,163,184,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.045) 1px, transparent 1px),
    color-mix(in srgb, var(--stats-card-bg, #fff) 97%, #eef2ff);
  background-size: auto, 24px 24px, 24px 24px, auto;
  overflow: hidden;
}

.stats-speaker-chord-canvas svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: clamp(570px, 59vh, 690px);
  user-select: none;
}

.stats-speaker-chord-node,
.stats-speaker-chord-ribbon {
  transition: opacity .15s ease, filter .15s ease;
}

.stats-speaker-chord-node {
  cursor: pointer;
}

.stats-speaker-chord-arc {
  fill: var(--speaker-chord-color, #818cf8);
  fill-opacity: var(--speaker-chord-strength, .72);
  stroke: color-mix(in srgb, var(--speaker-chord-color, #818cf8) 78%, #475569);
  stroke-width: 1.4;
  filter: drop-shadow(0 2px 3px rgba(15,23,42,.10));
  transition: stroke-width .15s ease, filter .15s ease, opacity .15s ease;
}

.stats-speaker-chord-node:hover .stats-speaker-chord-arc,
.stats-speaker-chord-node.is-selected .stats-speaker-chord-arc,
.stats-speaker-chord-node.is-compare .stats-speaker-chord-arc {
  stroke: #4338ca;
  stroke-width: 3;
  filter: drop-shadow(0 3px 6px rgba(67,56,202,.18));
}

.stats-speaker-chord-node.is-dimmed {
  opacity: .22;
}

.stats-speaker-chord-label {
  fill: #1e293b;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.stats-speaker-chord-ribbon {
  cursor: pointer;
  stroke: rgba(99,102,241,.16);
  stroke-width: .6;
  opacity: .62;
}

.stats-speaker-chord-ribbon:hover,
.stats-speaker-chord-ribbon.is-hover-active,
.stats-speaker-chord-ribbon.is-active {
  opacity: .96;
  filter: drop-shadow(0 2px 4px rgba(79,70,229,.18));
}

.stats-speaker-chord-ribbon.is-active {
  stroke: #4338ca;
  stroke-width: 1.6;
}

.stats-speaker-chord-ribbon.is-dimmed,
.stats-speaker-chord-ribbon.is-hover-dim {
  opacity: .08;
}

.stats-speaker-network-legend i.is-chord-node {
  width: 22px;
  height: 12px;
  border: 3px solid #818cf8;
  border-bottom-color: transparent;
  border-left-color: transparent;
  border-radius: 50% 50% 0 0;
  transform: rotate(-18deg);
}

.stats-speaker-network-legend i.is-chord-ribbon {
  width: 30px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(199,210,254,.72), rgba(79,70,229,.82));
}

.stats-speaker-network-legend i.is-chord-direction {
  width: 30px;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(199,210,254,.38), #4f46e5);
}

@media (max-width: 780px) {
  .stats-speaker-network-viewbar {
    align-items: stretch;
    flex-direction: column;
  }
  .stats-speaker-chord-canvas {
    overflow-x: auto;
  }
  .stats-speaker-chord-canvas svg {
    height: 570px;
  }
}

/* ============================================================
   Statistics 5.10v — Relation Arc Timeline 1.0
   ============================================================ */
.stats-relation-timeline-view {
  --timeline-accent: var(--stats-accent, #5b5ce2);
}

.stats-relation-timeline-controls {
  margin-bottom: 14px;
}

.relation-timeline-filter-grid {
  align-items: end;
}

.relation-timeline-control-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--stats-border, #e4eaf2);
}

.stats-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .84rem;
  color: var(--stats-text, #223149);
}

.relation-timeline-help {
  color: var(--stats-muted, #75829a);
  font-size: .78rem;
}

.relation-timeline-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 0 14px;
}

.relation-timeline-kpi-note {
  margin-top: 2px;
  color: var(--stats-muted, #7b879b);
  font-size: .72rem;
}

.stats-relation-timeline-card {
  overflow: hidden;
  padding: 0;
}

.relation-timeline-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 10px;
}

.relation-timeline-card-head h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.relation-timeline-card-head p {
  margin: 0;
  color: var(--stats-muted, #7b879b);
  font-size: .78rem;
}

.relation-timeline-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--stats-muted, #738099);
  font-size: .74rem;
}

.relation-timeline-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.relation-timeline-legend-arc {
  width: 24px;
  height: 11px;
  border-top: 2px solid var(--timeline-accent);
  border-radius: 50% 50% 0 0;
}

.relation-timeline-legend-arrow {
  color: var(--timeline-accent);
  font-style: normal;
  font-weight: 800;
  font-size: 1rem;
}

.relation-timeline-stage {
  position: relative;
  width: 100%;
  min-height: 450px;
  border-top: 1px solid var(--stats-border, #e4eaf2);
  border-bottom: 1px solid var(--stats-border, #e4eaf2);
  background:
    linear-gradient(to right, color-mix(in srgb, var(--stats-border, #e6edf5) 32%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--stats-border, #e6edf5) 25%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--stats-card-bg, #fff) 96%, transparent);
  background-size: 24px 24px;
  overflow: hidden;
}

.relation-timeline-svg,
.relation-timeline-nav-svg {
  display: block;
  width: 100%;
  user-select: none;
}

.relation-timeline-guide {
  stroke: color-mix(in srgb, var(--stats-border, #dbe4ef) 72%, transparent);
  stroke-width: 1;
  stroke-dasharray: 2 5;
}

.relation-timeline-baseline,
.relation-timeline-nav-line {
  stroke: color-mix(in srgb, var(--stats-text, #24334b) 45%, transparent);
  stroke-width: 1.2;
}

.relation-timeline-tick,
.relation-timeline-nav-label {
  fill: var(--stats-muted, #75829a);
  font-size: 11px;
  font-weight: 650;
}

.relation-timeline-arc {
  fill: none;
  stroke-width: 1.65;
  opacity: .28;
  cursor: pointer;
  transition: opacity .12s ease, stroke-width .12s ease, filter .12s ease;
}

.relation-timeline-arc:hover,
.relation-timeline-arc.is-hovered {
  opacity: .96;
  stroke-width: 3.1;
  filter: drop-shadow(0 1px 2px rgba(20, 40, 80, .14));
}

.relation-timeline-arc.is-selected {
  opacity: 1;
  stroke-width: 3.6;
  filter: drop-shadow(0 1px 3px rgba(20, 40, 80, .18));
}

.relation-timeline-point {
  fill: var(--stats-card-bg, #fff);
  stroke: var(--timeline-accent);
  stroke-width: 1.4;
  cursor: pointer;
  transition: r .12s ease, fill .12s ease;
}

.relation-timeline-point:hover,
.relation-timeline-point.is-pinned {
  fill: color-mix(in srgb, var(--timeline-accent) 18%, var(--stats-card-bg, #fff));
  stroke-width: 2.2;
}

.relation-timeline-density-bar,
.relation-timeline-nav-density {
  fill: color-mix(in srgb, var(--timeline-accent) 42%, transparent);
  opacity: .72;
}

.relation-timeline-navigator {
  position: relative;
  min-height: 88px;
  padding: 2px 0 0;
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 88%, var(--stats-soft, #f6f8fb));
}

.relation-timeline-brush {
  fill: color-mix(in srgb, var(--timeline-accent) 12%, transparent);
  stroke: color-mix(in srgb, var(--timeline-accent) 72%, transparent);
  stroke-width: 1.4;
  cursor: grab;
}

.relation-timeline-brush:active { cursor: grabbing; }

.relation-timeline-tooltip {
  position: fixed;
  z-index: 10000;
  width: min(310px, calc(100vw - 20px));
  padding: 10px 12px;
  border: 1px solid var(--stats-border, #dde5ef);
  border-radius: 10px;
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 96%, transparent);
  box-shadow: 0 10px 28px rgba(24, 39, 70, .18);
  color: var(--stats-text, #1f2d43);
  pointer-events: none;
  font-size: .78rem;
}

.relation-timeline-tooltip strong,
.relation-timeline-tooltip span {
  display: block;
}

.relation-timeline-tooltip strong { margin-bottom: 5px; font-size: .82rem; }
.relation-timeline-tooltip span + span { margin-top: 3px; color: var(--stats-muted, #738099); }

.relation-timeline-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--stats-muted, #75829a);
  font-size: .9rem;
  pointer-events: none;
}

.relation-timeline-details {
  margin-top: 14px;
}

.relation-timeline-details-head,
.relation-timeline-details-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.relation-timeline-details-head h3 { margin: 2px 0 0; }

.relation-timeline-details-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--stats-border, #dfe6ef);
  border-radius: 9px;
  background: transparent;
  color: var(--stats-muted, #718097);
  font-size: 1.15rem;
  cursor: pointer;
}

.relation-timeline-details-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 42px minmax(0,1fr);
  align-items: stretch;
  gap: 10px;
  margin: 14px 0;
}

.relation-timeline-details-grid > div:not(.relation-timeline-detail-arrow) {
  padding: 12px;
  border: 1px solid var(--stats-border, #e1e7ef);
  border-radius: 10px;
  background: color-mix(in srgb, var(--stats-soft, #f7f9fc) 72%, transparent);
}

.relation-timeline-detail-label {
  display: block;
  margin-bottom: 5px;
  color: var(--stats-muted, #75829a);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.relation-timeline-details-grid strong { font-size: .82rem; }
.relation-timeline-details-grid p { margin: 7px 0 0; font-size: .8rem; line-height: 1.45; }
.relation-timeline-detail-arrow { display:grid;place-items:center;color:var(--timeline-accent);font-size:1.25rem;font-weight:800; }

.relation-timeline-details-foot {
  padding-top: 10px;
  border-top: 1px solid var(--stats-border, #e3e9f1);
  font-size: .8rem;
}

@media (max-width: 1050px) {
  .relation-timeline-kpis { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .relation-timeline-filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
}

@media (max-width: 720px) {
  .relation-timeline-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .relation-timeline-filter-grid { grid-template-columns: 1fr !important; }
  .relation-timeline-card-head { flex-direction: column; }
  .relation-timeline-details-grid { grid-template-columns: 1fr; }
  .relation-timeline-detail-arrow { transform: rotate(90deg); }
  .relation-timeline-details-foot { align-items: flex-start; flex-direction: column; }
}

.relation-timeline-arc.is-dimmed {
  opacity: .055;
}

.relation-timeline-arc.is-context {
  opacity: .92;
  stroke-width: 2.8;
}

/* =========================================================
   Statistics 5.10w — Tag Network 1.0
   ========================================================= */
.stats-tag-network-view {
  --tag-network-accent: var(--stats-accent, #5b5ce2);
  --tag-network-edge: color-mix(in srgb, var(--stats-accent, #5b5ce2) 34%, #9aa8bc);
}

.stats-tag-network-controls { margin-bottom: 14px; }
.stats-tag-network-mode-row { margin-bottom: 12px; }
.stats-tag-network-grid { grid-template-columns: repeat(4, minmax(0,1fr)) !important; }
.stats-tag-network-context-controls {
  grid-template-columns: repeat(3, minmax(0,1fr)) !important;
  margin-top: 10px;
}
.stats-tag-network-self-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  align-self: end;
  padding: 8px 10px;
  border: 1px solid var(--stats-border, #dde5ee);
  border-radius: 9px;
  background: color-mix(in srgb, var(--stats-soft, #f7f9fc) 76%, transparent);
  font-size: .78rem;
  color: var(--stats-text, #172033);
}
.stats-tag-network-summary {
  margin: 8px 0 10px;
  color: var(--stats-muted, #718097);
  font-size: .78rem;
}
.stats-tag-network-summary strong { color: var(--stats-text, #172033); }

.stats-tag-network-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: stretch;
}
.stats-tag-network-card { min-width: 0; overflow: hidden; }
.stats-tag-network-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--stats-border, #e3e9f1);
}
.stats-tag-network-selection { min-height: 28px; display:flex; align-items:center; }
.stats-tag-network-zoom-controls { display:flex; align-items:center; gap:5px; white-space:nowrap; }
.stats-tag-network-zoom-controls .stats-btn { min-width: 34px; padding: 5px 9px; }
#tagNetworkZoomLabel { min-width: 48px; text-align:center; color:var(--stats-muted,#718097); font-size:.75rem; font-weight:700; }

.stats-tag-network-canvas {
  position: relative;
  height: 660px;
  min-height: 480px;
  margin: 8px -8px 0;
  overflow: hidden;
  border-radius: 10px;
  background:
    linear-gradient(color-mix(in srgb, var(--stats-border,#dfe6ef) 28%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--stats-border,#dfe6ef) 28%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--stats-card-bg,#fff) 96%, transparent);
  background-size: 24px 24px;
}
.stats-tag-network-canvas svg { width:100%; height:100%; display:block; user-select:none; }
.stats-tag-network-bg { fill: transparent; }
.stats-tag-network-edge {
  fill: none;
  stroke: var(--tag-network-edge);
  color: var(--tag-network-accent);
  stroke-width: var(--tag-edge-width, 2px);
  stroke-linecap: round;
  opacity: .50;
  cursor: pointer;
  transition: opacity .12s ease, stroke-width .12s ease;
  pointer-events: stroke;
}
.stats-tag-network-edge:hover,
.stats-tag-network-edge.is-active { opacity: .98; stroke: var(--tag-network-accent); }
.stats-tag-network-edge.is-active { stroke-width: calc(var(--tag-edge-width, 2px) + 1.8px); }
.stats-tag-network-edge.is-dimmed { opacity: .06; }

.stats-tag-network-node { cursor: grab; transition: opacity .12s ease; }
.stats-tag-network-node:active { cursor: grabbing; }
.stats-tag-network-node circle {
  stroke: color-mix(in srgb, var(--stats-text,#172033) 26%, transparent);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(15,23,42,.10));
}
.stats-tag-network-node text {
  fill: var(--stats-text, #172033);
  font-size: 12px;
  font-weight: 700;
  paint-order: stroke;
  stroke: color-mix(in srgb, var(--stats-card-bg,#fff) 94%, transparent);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.stats-tag-network-node:hover circle,
.stats-tag-network-node.is-selected circle {
  stroke: var(--tag-network-accent);
  stroke-width: 3px;
}
.stats-tag-network-node.is-dimmed { opacity: .12; }

.stats-tag-network-tooltip {
  position: absolute;
  z-index: 80;
  width: min(300px, calc(100vw - 30px));
  white-space: pre-line;
  pointer-events: none;
  padding: 9px 11px;
  border: 1px solid var(--stats-border, #dde5ee);
  border-radius: 9px;
  background: color-mix(in srgb, var(--stats-card-bg,#fff) 96%, transparent);
  box-shadow: 0 10px 30px rgba(15,23,42,.16);
  color: var(--stats-text,#172033);
  font-size: .76rem;
  line-height: 1.45;
}

.stats-tag-network-legend {
  display:flex;
  flex-wrap:wrap;
  gap:16px;
  padding-top:9px;
  border-top:1px solid var(--stats-border,#e3e9f1);
  color:var(--stats-muted,#718097);
  font-size:.72rem;
}
.stats-tag-network-legend span { display:inline-flex;align-items:center;gap:7px; }
.stats-tag-network-node-legend { width:14px;height:14px;border-radius:50%;background:var(--tag-network-accent);opacity:.72; }
.stats-tag-network-edge-legend { width:28px;height:0;border-top:4px solid var(--tag-network-edge);border-radius:999px; }

.stats-tag-network-details { min-width:0; padding:14px; }
.stats-tag-network-details-empty { display:grid;place-items:center;min-height:260px;text-align:center;color:var(--stats-muted,#718097);font-size:.82rem; }
.stats-tag-network-detail-head { display:flex;align-items:flex-start;gap:10px;padding-bottom:10px;border-bottom:1px solid var(--stats-border,#e3e9f1); }
.stats-tag-network-detail-head h3,.stats-tag-network-edge-detail h3 { margin:0; font-size:1rem; line-height:1.3; }
.stats-tag-network-detail-head p { margin:3px 0 0;color:var(--stats-muted,#718097);font-size:.73rem;font-style:italic; }
.stats-tag-network-detail-dot { width:18px;height:18px;border-radius:50%;flex:0 0 auto;margin-top:2px;border:1px solid rgba(0,0,0,.08); }
.stats-tag-network-detail-kpis { grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:10px 0; }
.stats-tag-network-detail-kpis .stats-box { padding:9px; }
.stats-tag-network-detail-kpis .stats-box h3 { font-size:.62rem; }
.stats-tag-network-detail-kpis .stats-box .value { font-size:1rem; }
.stats-tag-network-details h4 { margin:13px 0 7px;font-size:.78rem; }
.stats-tag-network-detail-list { display:grid;gap:5px;margin-bottom:12px; }
.stats-tag-network-detail-list button {
  display:flex;justify-content:space-between;gap:8px;width:100%;padding:7px 8px;border:1px solid var(--stats-border,#e1e7ef);border-radius:8px;background:transparent;color:var(--stats-text,#172033);font:inherit;font-size:.74rem;text-align:left;cursor:pointer;
}
.stats-tag-network-detail-list button:hover { background:color-mix(in srgb,var(--stats-accent,#5b5ce2) 7%,transparent); }
.stats-tag-network-example-list { margin:7px 0 0;padding-left:18px;display:grid;gap:6px;font-size:.73rem;line-height:1.4; }
.stats-tag-network-edge-detail .stats-box { margin:10px 0; }

@media (max-width: 1180px) {
  .stats-tag-network-grid { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  .stats-tag-network-layout { grid-template-columns:1fr; }
  .stats-tag-network-details { min-height:160px; }
  .stats-tag-network-details-empty { min-height:120px; }
}
@media (max-width: 720px) {
  .stats-tag-network-grid,
  .stats-tag-network-context-controls { grid-template-columns:1fr !important; }
  .stats-tag-network-toolbar { align-items:flex-start; flex-direction:column; }
  .stats-tag-network-canvas { height:540px; min-height:420px; }
}

/* =========================================================
   Statistics 5.10x — Visual controls polish
   Shared controls language for Tag Network and Relation Timeline.
   ========================================================= */
.stats-visual-settings-card {
  max-width: 1280px;
  padding: 16px 18px 17px;
  border-color: color-mix(in srgb, var(--stats-border, #dfe6ee) 88%, transparent);
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 94%, var(--stats-soft, #f7f9fc));
  box-shadow: 0 2px 8px rgba(15, 23, 42, .045);
}

.stats-visual-settings-card .stats-workbench-label {
  margin-bottom: 12px;
}

.stats-visual-control-grid {
  gap: 13px 16px;
}

.stats-visual-control-grid .stats-tool-field {
  min-width: 0;
  gap: 6px;
}

.stats-visual-control-grid .stats-tool-field label {
  color: var(--stats-text-soft, #475569);
  font-size: .78rem;
  font-weight: 750;
}

.stats-polished-select,
.stats-visual-settings-card .stats-tool-field > select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 40px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--stats-border, #d8e0e9);
  border-radius: 10px;
  background-color: color-mix(in srgb, var(--stats-card-bg, #fff) 92%, var(--stats-soft, #f7f9fc));
  background-image:
    linear-gradient(45deg, transparent 50%, var(--stats-muted, #718097) 50%),
    linear-gradient(135deg, var(--stats-muted, #718097) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--stats-text, #172033);
  font: inherit;
  font-size: .84rem;
  line-height: 1.2;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

.stats-polished-select:hover,
.stats-visual-settings-card .stats-tool-field > select:hover {
  border-color: color-mix(in srgb, var(--stats-accent, #5b5ce2) 58%, var(--stats-border, #d8e0e9));
}

.stats-polished-select:focus,
.stats-visual-settings-card .stats-tool-field > select:focus {
  outline: none;
  border-color: var(--stats-accent, #5b5ce2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--stats-accent, #5b5ce2) 14%, transparent);
}

.stats-polished-select:disabled,
.stats-visual-settings-card .stats-tool-field > select:disabled {
  cursor: not-allowed;
  opacity: .58;
  background-color: color-mix(in srgb, var(--stats-soft, #f7f9fc) 88%, transparent);
}

.stats-field-note {
  display: block;
  margin-top: 1px;
  color: var(--stats-muted, #718097);
  font-size: .69rem;
  line-height: 1.4;
}

.stats-visual-settings-foot {
  margin-top: 13px;
  padding-top: 12px;
  border-top-color: color-mix(in srgb, var(--stats-border, #e4eaf2) 78%, transparent);
}

.stats-inline-check--card,
.stats-tag-network-self-toggle {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--stats-border, #dde5ee);
  border-radius: 10px;
  background: color-mix(in srgb, var(--stats-soft, #f7f9fc) 78%, transparent);
}

.stats-inline-check--card input,
.stats-tag-network-self-toggle input {
  accent-color: var(--stats-accent, #5b5ce2);
}

/* Explicitly win over .stats-tool-field { display:flex }, which otherwise
   makes contextual Tag Network controls visible even while [hidden]. */
.stats-tag-network-context-controls [hidden],
.stats-tag-network-grid [hidden] {
  display: none !important;
}

.stats-tag-network-mode-row {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--stats-border, #dfe6ee) 88%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--stats-soft, #f7f9fc) 72%, transparent);
}

.stats-tag-network-context-controls:empty {
  display: none;
}

.stats-tag-network-how-read {
  padding: 3px 2px;
}

.stats-tag-network-how-read h3 {
  margin: 0 0 5px;
  font-size: .98rem;
}

.stats-tag-network-how-read > p {
  margin: 0 0 13px;
  color: var(--stats-muted, #718097);
  font-size: .76rem;
  line-height: 1.45;
}

.stats-tag-network-how-read dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stats-tag-network-how-read dl > div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--stats-border, #e1e7ef) 84%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--stats-soft, #f7f9fc) 62%, transparent);
}

.stats-tag-network-how-read dt {
  color: var(--stats-text, #172033);
  font-size: .72rem;
  font-weight: 800;
}

.stats-tag-network-how-read dd {
  margin: 0;
  color: var(--stats-muted, #718097);
  font-size: .72rem;
  line-height: 1.4;
}

/* Relation Timeline: use the same compact 2×2 workbench language as the
   other Statistics analysis views instead of full-width native selects. */
.relation-timeline-filter-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.stats-relation-timeline-controls .relation-timeline-help {
  flex: 1 1 320px;
}

@media (max-width: 1050px) {
  .stats-visual-settings-card { max-width: 100%; }
  .stats-tag-network-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .stats-tag-network-context-controls { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
}

@media (max-width: 720px) {
  .relation-timeline-filter-grid,
  .stats-tag-network-grid,
  .stats-tag-network-context-controls {
    grid-template-columns: 1fr !important;
  }
  .stats-tag-network-how-read dl > div { grid-template-columns: 1fr; gap: 3px; }
}

/* =========================================================
   Statistics 5.10y — Relation Structure Gallery 1.0
   ========================================================= */
.stats-structure-gallery-view .stats-tool-card { overflow: visible; }
.stats-structure-gallery-controls .stats-tool-grid { align-items: end; }
.stats-structure-gallery-kpis { margin: 0 0 16px; }

.stats-structure-gallery-section,
.stats-structure-gallery-examples-card,
.stats-structure-gallery-guide { margin-top: 16px; }

.stats-structure-gallery-section-head,
.stats-structure-gallery-examples-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.stats-structure-type-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.stats-structure-pattern-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.stats-structure-type-card,
.stats-structure-pattern-card {
  appearance: none;
  width: 100%;
  border: 1px solid var(--stats-card-border, #dfe6ee);
  border-radius: 14px;
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 96%, transparent);
  color: inherit;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease, background .14s ease;
}

.stats-structure-type-card:hover,
.stats-structure-pattern-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--stats-accent, #6366f1) 38%, var(--stats-card-border, #dfe6ee));
  box-shadow: 0 5px 18px rgba(38, 53, 77, .08);
}

.stats-structure-type-card.is-active,
.stats-structure-pattern-card.is-active {
  border-color: color-mix(in srgb, var(--stats-accent, #6366f1) 60%, var(--stats-card-border, #dfe6ee));
  background: color-mix(in srgb, var(--stats-accent, #6366f1) 7%, var(--stats-card-bg, #fff));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--stats-accent, #6366f1) 12%, transparent);
}

.stats-structure-type-card__diagram,
.stats-structure-pattern-card__diagram {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--stats-muted-bg, #f5f7fb) 84%, transparent);
}

.stats-structure-type-card__diagram svg,
.stats-structure-pattern-card__diagram svg { width: 100%; height: 100%; overflow: visible; }
.stats-structure-card-node { fill: color-mix(in srgb, var(--stats-accent, #6366f1) 14%, #fff); stroke: var(--stats-accent, #6366f1); stroke-width: 1.7; }
.stats-structure-card-edge { stroke: color-mix(in srgb, var(--stats-accent, #6366f1) 68%, #9aa6b2); stroke-width: 2; fill: none; stroke-linecap: round; }
.stats-structure-card-arrow { fill: color-mix(in srgb, var(--stats-accent, #6366f1) 68%, #9aa6b2); }

.stats-structure-type-card__name,
.stats-structure-pattern-card__name { display: block; font-size: .86rem; font-weight: 800; line-height: 1.2; }
.stats-structure-type-card__count,
.stats-structure-pattern-card__count { display: flex; align-items: baseline; gap: 6px; margin-top: 5px; }
.stats-structure-type-card__count strong,
.stats-structure-pattern-card__count strong { font-size: 1.35rem; line-height: 1; }
.stats-structure-type-card__count span,
.stats-structure-pattern-card__count span { color: var(--stats-muted, #738097); font-size: .74rem; }

.stats-structure-gallery-sort-wrap { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.stats-structure-gallery-sort-wrap label { font-size: .75rem; font-weight: 800; color: var(--stats-muted, #68758a); text-transform: uppercase; letter-spacing: .04em; }
.stats-structure-gallery-sort-wrap select { min-width: 220px; }

.stats-structure-example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.stats-structure-example-card {
  border: 1px solid var(--stats-card-border, #e0e6ee);
  border-radius: 14px;
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 97%, transparent);
  padding: 12px;
  min-width: 0;
}

.stats-structure-example-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.stats-structure-example-head h4 { margin: 0; font-size: .92rem; }
.stats-structure-example-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; color: var(--stats-muted, #728096); font-size: .72rem; }
.stats-structure-example-meta span { padding: 3px 7px; border-radius: 999px; background: color-mix(in srgb, var(--stats-muted-bg, #f3f6fa) 90%, transparent); }

.stats-structure-example-svg-wrap {
  position: relative;
  min-height: 270px;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--stats-card-border, #e2e8f0) 70%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--stats-panel-bg, #fbfcfe) 92%, transparent);
}
.stats-structure-example-svg { display: block; width: 100%; min-width: 620px; min-height: 270px; height: auto; }
.stats-structure-example-svg.is-dense { min-width: 700px; }
.stats-structure-example-edge { stroke: #8fa0b5; stroke-width: 2.15; fill: none; }
.stats-structure-example-edge.is-symmetric { stroke-dasharray: 4 3; }
.stats-structure-example-node { stroke: rgba(25,35,50,.25); stroke-width: 1.15; }
.stats-structure-example-node-id { font-size: 12px; font-weight: 800; fill: var(--stats-text, #172033); text-anchor: middle; }
.stats-structure-example-node-tag { font-size: 10px; fill: var(--stats-muted, #64748b); text-anchor: middle; }
.stats-structure-example-edge-label { font-size: 10px; fill: var(--stats-muted, #66758a); paint-order: stroke; stroke: color-mix(in srgb, var(--stats-card-bg, #fff) 92%, transparent); stroke-width: 4px; stroke-linejoin: round; }

.stats-structure-example-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.stats-structure-example-foot-note { color: var(--stats-muted, #748196); font-size: .72rem; min-width: 0; flex: 1 1 auto; }
.stats-structure-example-foot .stats-btn { flex: 0 0 auto; }
.stats-structure-gallery-more-wrap { display: flex; justify-content: center; margin-top: 14px; }

.stats-structure-guide-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 1380px) {
  .stats-structure-type-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .stats-structure-pattern-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}
@media (max-width: 980px) {
  .stats-structure-example-grid { grid-template-columns: 1fr; }
  .stats-structure-gallery-examples-head { flex-direction: column; }
  .stats-structure-guide-grid { grid-template-columns: 1fr; }
  .stats-structure-example-svg-wrap { min-height: 250px; }
  .stats-structure-example-svg, .stats-structure-example-svg.is-dense { min-width: 620px; min-height: 250px; }
}
@media (max-width: 720px) {
  .stats-structure-type-grid,
  .stats-structure-pattern-grid { grid-template-columns: 1fr 1fr; }
  .stats-structure-gallery-sort-wrap { width: 100%; align-items: stretch; flex-direction: column; }
  .stats-structure-gallery-sort-wrap select { min-width: 0; width: 100%; }
}


/* =========================================================
   Statistics 5.10z — Relation Structure Gallery 1.1
   Terminology, guide placement, polished controls and richer examples.
   ========================================================= */
.stats-structure-gallery-guide--top {
  margin: 0 0 14px;
  padding: 15px 17px;
  border-color: color-mix(in srgb, var(--stats-accent, #6366f1) 20%, var(--stats-card-border, #dfe6ee));
  background: color-mix(in srgb, var(--stats-card-bg, #fff) 94%, var(--stats-accent, #6366f1) 3%);
}

.stats-structure-gallery-guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 11px;
}

.stats-structure-gallery-guide-details {
  flex: 0 0 auto;
  max-width: 560px;
}

.stats-structure-gallery-guide-details summary {
  cursor: pointer;
  list-style: none;
  color: var(--stats-accent, #5557d9);
  font-size: .77rem;
  font-weight: 800;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--stats-accent, #6366f1) 22%, var(--stats-border, #dfe6ee));
  border-radius: 9px;
  background: color-mix(in srgb, var(--stats-accent, #6366f1) 5%, transparent);
}
.stats-structure-gallery-guide-details summary::-webkit-details-marker { display:none; }
.stats-structure-gallery-guide-details summary::before { content:"ⓘ "; }
.stats-structure-gallery-guide-more {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--stats-soft, #f6f8fb) 92%, transparent);
  color: var(--stats-muted, #66758a);
  font-size: .74rem;
  line-height: 1.5;
}
.stats-structure-gallery-guide-more p { margin:0 0 7px; }
.stats-structure-gallery-guide-more p:last-child { margin-bottom:0; }

.stats-structure-gallery-controls {
  max-width: none;
  margin-bottom: 14px;
}
.stats-structure-gallery-control-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px 15px;
  align-items: start !important;
}
.stats-structure-gallery-controls .stats-tool-field { gap: 6px; min-width:0; }
.stats-structure-gallery-controls .stats-tool-field label {
  color: var(--stats-text-soft, #475569);
  font-size: .78rem;
  font-weight: 750;
}
.stats-structure-gallery-controls .stats-tool-field small {
  color: var(--stats-muted, #718097);
  font-size: .67rem;
  line-height:1.35;
}

.stats-structure-analytic-id-help {
  display:inline-flex;
  margin-left:6px;
  color:var(--stats-muted,#718097);
  font-size:.72rem;
  vertical-align:middle;
  cursor:help;
}

.stats-structure-example-actions {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:7px;
  flex-wrap:wrap;
}

.stats-structure-example-card.is-expanded {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--stats-accent,#6366f1) 35%, var(--stats-card-border,#e0e6ee));
  box-shadow: 0 5px 18px rgba(38,53,77,.06);
}
.stats-structure-example-card.is-expanded .stats-structure-example-svg-wrap { min-height: 330px; }
.stats-structure-example-card.is-expanded .stats-structure-example-svg { min-width: 760px; min-height: 330px; }

.stats-structure-expanded-content {
  display:grid;
  grid-template-columns:minmax(0,1.6fr) minmax(250px,.7fr);
  gap:12px;
  margin-top:12px;
  padding-top:12px;
  border-top:1px solid color-mix(in srgb,var(--stats-card-border,#e0e6ee) 78%,transparent);
}
.stats-structure-expanded-column {
  min-width:0;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#e0e6ee) 78%,transparent);
  border-radius:11px;
  background:color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 94%,transparent);
  padding:11px;
}
.stats-structure-expanded-column h5 {
  margin:0 0 9px;
  font-size:.77rem;
  color:var(--stats-text-soft,#475569);
  text-transform:uppercase;
  letter-spacing:.035em;
}
.stats-structure-expanded-node {
  padding:9px 0;
  border-top:1px solid color-mix(in srgb,var(--stats-card-border,#e0e6ee) 68%,transparent);
}
.stats-structure-expanded-node:first-of-type { border-top:0; padding-top:0; }
.stats-structure-expanded-node-head {
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  gap:8px;
  align-items:start;
}
.stats-structure-expanded-node-head strong { display:block; font-size:.79rem; }
.stats-structure-expanded-node-head small { display:block; margin-top:2px; color:var(--stats-muted,#718097); font-size:.68rem; font-style:italic; }
.stats-structure-expanded-speaker { color:var(--stats-muted,#718097); font-size:.69rem; white-space:nowrap; }
.stats-structure-expanded-node p { margin:6px 0 0; font-size:.78rem; line-height:1.45; color:var(--stats-text,#172033); }
.stats-structure-expanded-translation { margin-top:6px; display:flex; gap:7px; align-items:flex-start; color:var(--stats-muted,#718097); font-size:.7rem; line-height:1.4; }
.stats-structure-expanded-translation span { flex:0 0 auto; padding:1px 5px; border-radius:999px; background:var(--stats-soft,#f1f5f9); font-weight:800; font-size:.62rem; }
.stats-structure-expanded-relations ul { list-style:none; margin:0; padding:0; display:grid; gap:7px; }
.stats-structure-expanded-relations li { display:grid; grid-template-columns:auto minmax(0,1fr); gap:3px 7px; align-items:center; padding:7px 8px; border-radius:9px; background:color-mix(in srgb,var(--stats-card-bg,#fff) 94%,transparent); font-size:.72rem; }
.stats-structure-expanded-relations li > span:last-child { grid-column:2; color:var(--stats-muted,#718097); }


@media (max-width:1180px) {
  .stats-structure-gallery-control-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .stats-structure-gallery-guide-head { flex-direction:column; }
  .stats-structure-gallery-guide-details { max-width:none; width:100%; }
}
@media (max-width:820px) {
  .stats-structure-expanded-content { grid-template-columns:1fr; }
  .stats-structure-expanded-node-head { grid-template-columns:auto minmax(0,1fr); }
  .stats-structure-expanded-speaker { grid-column:2; white-space:normal; }
}
@media (max-width:620px) {
  .stats-structure-gallery-control-grid { grid-template-columns:1fr; }
  .stats-structure-example-actions { width:100%; justify-content:stretch; }
  .stats-structure-example-actions .stats-btn { flex:1 1 auto; }
}

/* =========================================================
   Statistics 5.10ZB — Relation Structure Gallery direction polish
   Directional arrowheads + synchronized graph / relation / content hover.
   ========================================================= */
.stats-structure-example-relation,
.stats-structure-example-node-group,
.stats-structure-expanded-relation,
.stats-structure-direction-chip,
.stats-structure-expanded-node {
  transition: opacity .14s ease, filter .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.stats-structure-example-edge {
  stroke: #8295ad;
  stroke-width: 2;
  fill: none;
  transition: stroke .14s ease, stroke-width .14s ease, opacity .14s ease;
}
.stats-structure-example-edge.is-symmetric { stroke-dasharray: 4 3; }
.stats-structure-example-arrowhead { fill: #8295ad; }
.stats-structure-example-relation { cursor: pointer; outline: none; }
.stats-structure-example-relation.is-relation-active .stats-structure-example-edge {
  stroke: var(--stats-accent, #5b5ce2);
  stroke-width: 3.4;
}
.stats-structure-example-relation.is-relation-active .stats-structure-example-edge-label {
  fill: var(--stats-accent, #4f46e5);
  font-weight: 850;
}
.stats-structure-example-node-group { cursor: pointer; outline: none; }
.stats-structure-example-node-group.is-node-source .stats-structure-example-node,
.stats-structure-example-node-group.is-node-active .stats-structure-example-node {
  stroke: var(--stats-accent, #4f46e5);
  stroke-width: 3;
  filter: drop-shadow(0 2px 4px rgba(79,70,229,.16));
}
.stats-structure-example-node-group.is-node-target .stats-structure-example-node {
  stroke: color-mix(in srgb, var(--stats-accent, #4f46e5) 72%, #111827);
  stroke-width: 3.4;
  filter: drop-shadow(0 2px 5px rgba(79,70,229,.22));
}
.stats-structure-example-relation.is-context-dimmed,
.stats-structure-example-node-group.is-context-dimmed { opacity: .18; }
.stats-structure-example-node-group.is-node-target .stats-structure-example-node-id,
.stats-structure-example-node-group.is-node-active .stats-structure-example-node-id { fill: var(--stats-accent,#4338ca); }
.stats-structure-example-node-group.is-node-target .stats-structure-example-node-tag,
.stats-structure-example-node-group.is-node-active .stats-structure-example-node-tag { fill: var(--stats-text-soft,#334155); }

.stats-structure-direction-legend {
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  margin-top:12px;
  padding:7px 9px;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#e0e6ee) 78%,transparent);
  border-radius:9px;
  background:color-mix(in srgb,var(--stats-soft,#f5f7fb) 90%,transparent);
  color:var(--stats-muted,#66758a);
  font-size:.68rem;
}
.stats-structure-direction-legend b {
  color:var(--stats-accent,#4f46e5);
  font-size:1rem;
  line-height:1;
}
.stats-structure-direction-legend-highlight {
  color:var(--stats-accent,#4f46e5);
  font-size:.7rem;
  margin-left:6px;
}

.stats-structure-node-directions {
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:8px;
}
.stats-structure-direction-chip {
  display:inline-flex;
  align-items:center;
  gap:5px;
  max-width:100%;
  padding:4px 7px;
  border:1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 18%,var(--stats-card-border,#dfe6ee));
  border-radius:999px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 4%,var(--stats-card-bg,#fff));
  color:var(--stats-text-soft,#475569);
  font-size:.66rem;
  line-height:1.15;
  cursor:pointer;
  outline:none;
}
.stats-structure-direction-chip strong { color:var(--stats-text,#172033); font-size:.65rem; }
.stats-structure-direction-chip .stats-relation-id-chip { padding:1px 5px; font-size:.61rem; }
.stats-structure-direction-chip.is-relation-active {
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 55%,var(--stats-card-border,#dfe6ee));
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 10%,var(--stats-card-bg,#fff));
  box-shadow:0 0 0 2px color-mix(in srgb,var(--stats-accent,#6366f1) 8%,transparent);
}
.stats-structure-direction-chip.is-context-dimmed { opacity:.24; }
.stats-structure-expanded-node { scroll-margin-top: 90px; }

.stats-structure-expanded-node.is-node-source,
.stats-structure-expanded-node.is-node-target,
.stats-structure-expanded-node.is-node-active {
  margin-left:-7px;
  margin-right:-7px;
  padding-left:7px;
  padding-right:7px;
  border-radius:9px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 6%,transparent);
}
.stats-structure-expanded-node.is-node-source { box-shadow:inset 3px 0 0 color-mix(in srgb,var(--stats-accent,#6366f1) 70%,transparent); }
.stats-structure-expanded-node.is-node-target { box-shadow:inset 3px 0 0 var(--stats-accent,#4f46e5); }
.stats-structure-expanded-node.is-context-dimmed { opacity:.4; }

.stats-structure-expanded-relations li.stats-structure-expanded-relation {
  cursor:pointer;
  outline:none;
}
.stats-structure-expanded-relations li.stats-structure-expanded-relation.is-relation-active {
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 9%,var(--stats-card-bg,#fff));
  box-shadow:inset 3px 0 0 var(--stats-accent,#4f46e5);
}
.stats-structure-expanded-relations li.stats-structure-expanded-relation.is-context-dimmed { opacity:.28; }

@media (prefers-reduced-motion: reduce) {
  .stats-structure-example-relation,
  .stats-structure-example-node-group,
  .stats-structure-expanded-relation,
  .stats-structure-direction-chip,
  .stats-structure-expanded-node,
  .stats-structure-example-edge { transition:none; }
}


/* =========================================================
   Statistics 5.10ZD — Relation Structure Gallery motif-aware labels/examples
   Relation type labels, motif-specific ranking and occurrence focus.
   ========================================================= */
.stats-structure-example-edge-label {
  font-size: 9.5px;
  font-weight: 760;
  fill: var(--stats-text-soft,#475569);
  pointer-events: none;
}
.stats-structure-example-svg.is-dense .stats-structure-example-edge-label { font-size: 8.2px; }
.stats-structure-example-relation.is-pattern-muted,
.stats-structure-example-node-group.is-pattern-muted { opacity: .25; }
.stats-structure-example-relation.is-pattern-relevant,
.stats-structure-example-node-group.is-pattern-relevant { opacity: 1; }
.stats-structure-example-relation.is-pattern-relevant .stats-structure-example-edge {
  stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 68%,#8295ad);
  stroke-width: 2.6;
}
.stats-structure-example-relation.is-pattern-relevant .stats-structure-example-edge-label {
  fill: var(--stats-accent,#4f46e5);
  font-weight: 850;
}
.stats-structure-example-relation.is-relation-active,
.stats-structure-example-node-group.is-node-active,
.stats-structure-example-node-group.is-node-source,
.stats-structure-example-node-group.is-node-target { opacity: 1 !important; }
.stats-structure-pattern-focus {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:8px 0 9px;
  padding:8px 10px;
  border:1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 22%,var(--stats-card-border,#dfe6ee));
  border-radius:10px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 5%,var(--stats-card-bg,#fff));
}
.stats-structure-pattern-focus > div:first-child { display:flex; align-items:baseline; gap:8px; min-width:0; }
.stats-structure-pattern-focus strong { font-size:.75rem; color:var(--stats-text,#172033); }
.stats-structure-pattern-focus span { color:var(--stats-muted,#718097); font-size:.69rem; }
.stats-structure-pattern-nav { display:flex; align-items:center; gap:6px; flex:0 0 auto; }
.stats-structure-pattern-nav .stats-btn--icon { min-width:28px; width:28px; height:28px; padding:0; border-radius:8px; }
.stats-structure-pattern-nav > span { min-width:42px; text-align:center; font-variant-numeric:tabular-nums; }
.stats-structure-pattern-chip-row {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:5px;
  margin-top:7px;
  color:var(--stats-muted,#718097);
  font-size:.66rem;
}
.stats-structure-pattern-chip {
  display:inline-flex;
  padding:2px 6px;
  border-radius:999px;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
  background:color-mix(in srgb,var(--stats-soft,#f4f6fa) 92%,transparent);
  color:var(--stats-text-soft,#475569);
}
.stats-structure-pattern-chip.is-current {
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 34%,var(--stats-card-border,#dfe6ee));
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 8%,var(--stats-card-bg,#fff));
  color:var(--stats-accent,#4f46e5);
  font-weight:800;
}
@media (max-width:720px) {
  .stats-structure-pattern-focus { align-items:flex-start; flex-direction:column; }
  .stats-structure-pattern-nav { align-self:flex-end; }
}

/* =========================================================
   Statistics 5.11A — Relation Chain Explorer 1.0
   ========================================================= */
.stats-structure-subnav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--stats-card-border, #dfe6ee);
  border-radius: 12px;
  background: color-mix(in srgb, var(--stats-soft, #f6f8fb) 90%, transparent);
}
.stats-structure-subnav button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--stats-muted, #66758a);
  padding: 8px 13px;
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.stats-structure-subnav button.active {
  background: var(--stats-card-bg, #fff);
  color: var(--stats-accent, #4f46e5);
  box-shadow: 0 1px 4px rgba(15,23,42,.08);
}
.stats-structure-workspace-panel[hidden] { display: none !important; }

.stats-chain-guide { margin-bottom: 14px; }
.stats-chain-guide-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.stats-chain-controls { margin-bottom: 14px; }
.stats-chain-control-grid {
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 13px 15px;
  align-items: start !important;
}
.stats-chain-control-grid .stats-tool-field { min-width: 0; }
.stats-chain-control-grid .stats-polished-select { width: 100%; min-width: 0; }
.stats-chain-kpis { margin-bottom: 14px; }

.stats-chain-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
}
.stats-chain-search { flex: 1 1 520px; max-width: 720px; }
.stats-chain-sort-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.stats-chain-sort-field label {
  color: var(--stats-muted,#66758a);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-chain-sort-field select { min-width: 230px; }

.stats-chain-explorer-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0,1fr);
  gap: 16px;
  align-items: start;
}
.stats-chain-list-pane,
.stats-chain-detail-pane {
  border: 1px solid var(--stats-card-border, #dfe6ee);
  border-radius: 14px;
  background: var(--stats-card-bg, #fff);
  box-shadow: 0 1px 4px rgba(15,23,42,.04);
}
.stats-chain-list-pane {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 116px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stats-chain-list-head {
  padding: 13px 14px 10px;
  border-bottom: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 75%,transparent);
}
.stats-chain-list-head h3 { margin: 0; font-size: .88rem; }
.stats-chain-list-head p { margin: 4px 0 0; color: var(--stats-muted,#66758a); font-size: .7rem; }
.stats-chain-list {
  display: grid;
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
}
.stats-chain-list-item {
  width: 100%;
  min-width: 0;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 88%,transparent);
  border-radius: 11px;
  background: color-mix(in srgb,var(--stats-card-bg,#fff) 97%,transparent);
  padding: 9px 10px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease, transform .14s ease;
}
.stats-chain-list-item:hover {
  border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 30%,var(--stats-card-border,#dfe6ee));
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 3%,var(--stats-card-bg,#fff));
}
.stats-chain-list-item.is-active {
  border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 55%,var(--stats-card-border,#dfe6ee));
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 7%,var(--stats-card-bg,#fff));
  box-shadow: inset 3px 0 0 var(--stats-accent,#4f46e5);
}
.stats-chain-list-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stats-chain-list-top strong { font-size: .79rem; }
.stats-chain-list-top span { color: var(--stats-muted,#66758a); font-size: .66rem; }
.stats-chain-list-mini { height: 33px; margin: 5px 0 2px; }
.stats-chain-list-mini svg { width: 100%; height: 32px; overflow: visible; }
.stats-chain-mini-lines path { stroke: #8b9bb0; stroke-width: 1.7; fill: none; }
.stats-chain-mini-lines marker path { fill: #8b9bb0; stroke: none; }
.stats-chain-mini-nodes circle { fill: color-mix(in srgb,var(--stats-accent,#6366f1) 12%,#fff); stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 65%,#64748b); stroke-width: 1.4; }
.stats-chain-list-meta { display: flex; flex-wrap: wrap; gap: 4px; color: var(--stats-muted,#6b778b); font-size: .63rem; }
.stats-chain-list-meta span { padding: 2px 5px; border-radius: 999px; background: color-mix(in srgb,var(--stats-soft,#f3f6fa) 92%,transparent); }
.stats-chain-list-types { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.stats-chain-list-types span { padding: 2px 6px; border-radius: 999px; border: 1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 16%,var(--stats-card-border,#dfe6ee)); color: var(--stats-text-soft,#475569); font-size: .62rem; background: color-mix(in srgb,var(--stats-accent,#6366f1) 3%,transparent); }

.stats-chain-detail-pane { min-width: 0; padding: 15px; }
.stats-chain-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.stats-chain-detail-head h3 { margin: 0; font-size: 1rem; }
.stats-chain-detail-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.stats-chain-detail-meta span { padding: 3px 7px; border-radius: 999px; background: color-mix(in srgb,var(--stats-soft,#f1f5f9) 92%,transparent); color: var(--stats-muted,#66758a); font-size: .66rem; }
.stats-chain-nav-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.stats-chain-nav-actions > span { min-width: 52px; text-align: center; color: var(--stats-muted,#66758a); font-size: .7rem; font-weight: 800; }
.stats-chain-layout-switch { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin: 10px 0; }
.stats-chain-layout-switch > span { color: var(--stats-muted,#66758a); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.stats-chain-layout-switch #relationChainOpenAnnotation { margin-left: auto; }

.stats-chain-graph-card {
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 80%,transparent);
  border-radius: 12px;
  background: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 94%,transparent);
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 270px;
}
.stats-chain-graph { min-width: 100%; }
.stats-chain-svg { display: block; height: 270px; min-width: 760px; width: auto; }
.stats-chain-step { cursor: pointer; transition: opacity .14s ease; }
.stats-chain-step path { stroke: #8a9ab0; stroke-width: 2.2; fill: none; transition: stroke .14s ease, stroke-width .14s ease, opacity .14s ease; }
.stats-chain-step text { font-size: 10px; fill: var(--stats-text-soft,#475569); text-anchor: middle; paint-order: stroke; stroke: color-mix(in srgb,var(--stats-panel-bg,#fff) 94%,transparent); stroke-width: 5px; stroke-linejoin: round; }
.stats-chain-arrowhead { fill: #8a9ab0; }
.stats-chain-step.is-selected path { stroke: var(--stats-accent,#4f46e5); stroke-width: 3.4; }
.stats-chain-step.is-selected text { fill: var(--stats-accent,#4338ca); font-weight: 850; }
.stats-chain-node { cursor: pointer; transition: opacity .14s ease, filter .14s ease; }
.stats-chain-node circle { stroke: rgba(25,35,50,.28); stroke-width: 1.2; }
.stats-chain-node.is-selected circle { stroke: var(--stats-accent,#4f46e5); stroke-width: 3.3; filter: drop-shadow(0 2px 5px rgba(79,70,229,.2)); }
.stats-chain-node-id { font-size: 11px; font-weight: 850; fill: var(--stats-text,#172033); text-anchor: middle; }
.stats-chain-node-tag { font-size: 9px; fill: var(--stats-muted,#64748b); text-anchor: middle; }
.stats-chain-node-speaker { font-size: 8px; fill: var(--stats-muted,#718097); text-anchor: middle; }
.stats-chain-node.is-dimmed,
.stats-chain-step.is-dimmed,
.stats-chain-reader-node.is-dimmed,
.stats-chain-reader-step.is-dimmed { opacity: .22; }

.stats-chain-signatures { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 11px 0; }
.stats-chain-signatures > div { border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent); border-radius: 10px; padding: 8px 10px; background: color-mix(in srgb,var(--stats-soft,#f6f8fb) 88%,transparent); min-width: 0; }
.stats-chain-signatures span { display: block; color: var(--stats-muted,#66758a); font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 3px; }
.stats-chain-signatures strong { display: block; color: var(--stats-text,#172033); font-size: .72rem; line-height: 1.45; overflow-wrap: anywhere; }

.stats-chain-reader-card { margin-top: 10px; border-top: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 80%,transparent); padding-top: 13px; }
.stats-chain-reader { display: grid; gap: 0; margin-top: 9px; }
.stats-chain-reader-node { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 9px; border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent); border-radius: 11px; padding: 10px; background: color-mix(in srgb,var(--stats-card-bg,#fff) 98%,transparent); cursor: pointer; transition: opacity .14s ease, border-color .14s ease, background .14s ease; }
.stats-chain-reader-node.is-selected { border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 48%,var(--stats-card-border,#dfe6ee)); background: color-mix(in srgb,var(--stats-accent,#6366f1) 5%,var(--stats-card-bg,#fff)); }
.stats-chain-reader-index { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb,var(--stats-accent,#6366f1) 9%,#fff); color: var(--stats-accent,#4f46e5); font-size: .7rem; font-weight: 850; }
.stats-chain-reader-head { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: start; gap: 8px; }
.stats-chain-reader-head strong { display: block; font-size: .78rem; }
.stats-chain-reader-head small { display: block; margin-top: 2px; color: var(--stats-muted,#718097); font-size: .67rem; font-style: italic; }
.stats-chain-reader-head > span:last-child { color: var(--stats-muted,#718097); font-size: .68rem; }
.stats-chain-reader-main p { margin: 6px 0 0; color: var(--stats-text,#172033); font-size: .77rem; line-height: 1.48; }
.stats-chain-reader-translation { margin-top: 6px; color: var(--stats-muted,#66758a); font-size: .69rem; line-height: 1.42; }
.stats-chain-reader-translation b { margin-right: 6px; color: var(--stats-text-soft,#475569); font-size: .62rem; }
.stats-chain-reader-step { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: center; gap: 6px 8px; width: calc(100% - 32px); margin: 4px 0 4px 32px; padding: 7px 9px; border: 0; border-left: 2px solid color-mix(in srgb,var(--stats-accent,#6366f1) 25%,var(--stats-card-border,#dfe6ee)); background: transparent; color: var(--stats-text-soft,#475569); text-align: left; cursor: pointer; }
.stats-chain-reader-step.is-selected { border-left-color: var(--stats-accent,#4f46e5); background: color-mix(in srgb,var(--stats-accent,#6366f1) 5%,transparent); }
.stats-chain-reader-arrow { color: var(--stats-accent,#4f46e5); font-size: 1rem; text-align: center; }
.stats-chain-reader-step > strong { font-size: .71rem; }
.stats-chain-reader-step > span:nth-child(3) { display: flex; flex-wrap: wrap; gap: 5px; color: var(--stats-muted,#66758a); font-size: .65rem; }
.stats-chain-reader-step > span:nth-child(3) span { padding: 2px 5px; border-radius: 999px; background: color-mix(in srgb,var(--stats-soft,#f1f5f9) 92%,transparent); }
.stats-chain-reader-step small { grid-column: 2 / -1; color: var(--stats-muted,#718097); font-size: .63rem; }

@media (max-width: 1320px) {
  .stats-chain-control-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .stats-chain-explorer-layout { grid-template-columns: minmax(250px,300px) minmax(0,1fr); }
}
@media (max-width: 1020px) {
  .stats-chain-guide-grid { grid-template-columns: 1fr; }
  .stats-chain-control-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stats-chain-explorer-layout { grid-template-columns: 1fr; }
  .stats-chain-list-pane { position: static; max-height: 430px; }
}
@media (max-width: 720px) {
  .stats-structure-subnav { display: flex; width: 100%; }
  .stats-structure-subnav button { flex: 1; }
  .stats-chain-control-grid { grid-template-columns: 1fr; }
  .stats-chain-toolbar { align-items: stretch; flex-direction: column; }
  .stats-chain-search { max-width: none; flex-basis: auto; }
  .stats-chain-sort-field { align-items: stretch; flex-direction: column; }
  .stats-chain-sort-field select { min-width: 0; width: 100%; }
  .stats-chain-detail-head { flex-direction: column; }
  .stats-chain-nav-actions { justify-content: flex-start; }
  .stats-chain-layout-switch #relationChainOpenAnnotation { margin-left: 0; }
  .stats-chain-signatures { grid-template-columns: 1fr; }
  .stats-chain-reader-head { grid-template-columns: auto minmax(0,1fr); }
  .stats-chain-reader-head > span:last-child { grid-column: 2; }
}

/* =========================================================
   Statistics 5.11B — Relation Chain Explorer visual repair
   Empty-state fix, stable arrowheads, document lanes and SVG focus polish.
   ========================================================= */
#relationChainEmpty[hidden],
#relationChainDetail[hidden] {
  display: none !important;
}

.stats-chain-node,
.stats-chain-step {
  outline: none;
}
.stats-chain-node:focus,
.stats-chain-step:focus {
  outline: none;
}
.stats-chain-node:focus-visible circle {
  stroke: var(--stats-accent,#4f46e5);
  stroke-width: 2.6;
  filter: drop-shadow(0 2px 4px rgba(79,70,229,.15));
}
.stats-chain-step:focus-visible path {
  stroke: var(--stats-accent,#4f46e5);
}

.stats-chain-graph-card {
  min-height: 292px;
}
.stats-chain-svg {
  height: var(--chain-svg-height,292px);
  min-height: 292px;
}
.stats-chain-step path {
  vector-effect: non-scaling-stroke;
}
.stats-chain-arrowhead {
  fill: #8a9ab0;
}
.stats-chain-arrowhead--selected {
  fill: var(--stats-accent,#4f46e5);
}
.stats-chain-step text {
  dominant-baseline: middle;
}

@media (max-width: 1020px) {
  .stats-chain-graph-card { min-height: 280px; }
  .stats-chain-svg { min-height: 280px; }
}

/* =========================================================
   Statistics 5.11C — Relation Chain Explorer patterns + context
   Full-structure context, signatures, branch peeks, similar chains and export.
   ========================================================= */
.stats-chain-patterns-card {
  margin: 12px 0 14px;
  padding-bottom: 13px;
}
.stats-chain-patterns-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.stats-chain-patterns-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 10px;
  margin-top: 10px;
}
.stats-chain-pattern-box {
  min-width: 0;
  padding: 10px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
  border-radius: 11px;
  background: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 94%,transparent);
}
.stats-chain-pattern-box h4 {
  margin: 0 0 7px;
  color: var(--stats-text-soft,#475569);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-chain-pattern-list {
  display: grid;
  gap: 5px;
}
.stats-chain-pattern-chip {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
  border-radius: 8px;
  background: var(--stats-card-bg,#fff);
  color: var(--stats-text-soft,#475569);
  text-align: left;
  cursor: pointer;
}
.stats-chain-pattern-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .68rem;
}
.stats-chain-pattern-chip b {
  min-width: 24px;
  padding: 2px 5px;
  border-radius: 999px;
  background: color-mix(in srgb,var(--stats-soft,#f1f5f9) 94%,transparent);
  color: var(--stats-muted,#66758a);
  font-size: .62rem;
  text-align: center;
}
.stats-chain-pattern-chip:hover,
.stats-chain-pattern-chip.is-active {
  border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 45%,var(--stats-card-border,#dfe6ee));
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 5%,var(--stats-card-bg,#fff));
}
.stats-chain-pattern-chip.is-active span,
.stats-chain-pattern-chip.is-active b { color: var(--stats-accent,#4f46e5); }
.stats-chain-pattern-empty { color: var(--stats-muted,#718097); font-size: .7rem; }

.stats-chain-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 15%,var(--stats-card-border,#dfe6ee));
  border-radius: 10px;
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 3%,var(--stats-card-bg,#fff));
}
.stats-chain-context-summary {
  min-width: 0;
  color: var(--stats-text-soft,#475569);
  font-size: .7rem;
  line-height: 1.4;
}
.stats-chain-context-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.stats-chain-context-actions .stats-btn { min-height: 32px; padding: 5px 9px; }

.stats-chain-branch-badge { cursor: pointer; outline: none; }
.stats-chain-branch-badge circle {
  fill: color-mix(in srgb,var(--stats-accent,#6366f1) 10%,#fff);
  stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 62%,#64748b);
  stroke-width: 1.4;
}
.stats-chain-branch-badge text {
  fill: var(--stats-accent,#4f46e5);
  font-size: 9px;
  font-weight: 850;
  text-anchor: middle;
  pointer-events: none;
}
.stats-chain-branch-badge:hover circle,
.stats-chain-branch-badge.is-active circle {
  fill: color-mix(in srgb,var(--stats-accent,#6366f1) 18%,#fff);
  stroke-width: 2.2;
}
.stats-chain-branch-badge:focus-visible circle { stroke-width: 2.5; }

#relationChainBranchPanel[hidden] { display: none !important; }
.stats-chain-branch-panel {
  margin-top: 9px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 22%,var(--stats-card-border,#dfe6ee));
  border-radius: 10px;
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 4%,var(--stats-panel-bg,#fbfcfe));
}
.stats-chain-branch-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.stats-chain-branch-head strong { display: block; font-size: .73rem; color: var(--stats-text,#172033); }
.stats-chain-branch-head span { display: block; margin-top: 2px; color: var(--stats-muted,#66758a); font-size: .65rem; }
.stats-chain-branch-close {
  border: 0;
  background: transparent;
  color: var(--stats-muted,#66758a);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.stats-chain-branch-panel > p { margin: 7px 0 9px; color: var(--stats-muted,#66758a); font-size: .67rem; line-height: 1.42; }
.stats-chain-branch-panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.stats-chain-branch-panel li {
  display: grid;
  grid-template-columns: auto auto minmax(0,1fr);
  gap: 4px 7px;
  align-items: center;
  padding: 6px 7px;
  border-radius: 8px;
  background: color-mix(in srgb,var(--stats-card-bg,#fff) 94%,transparent);
  font-size: .66rem;
}
.stats-chain-branch-panel li > small { grid-column: 3; color: var(--stats-muted,#718097); }

.stats-chain-signatures--context {
  grid-template-columns: repeat(2,minmax(0,1fr));
}

.stats-chain-similar-card {
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent);
  border-radius: 10px;
  background: color-mix(in srgb,var(--stats-soft,#f6f8fb) 82%,transparent);
}
.stats-chain-similar-head h4 { margin: 0; font-size: .76rem; color: var(--stats-text,#172033); }
.stats-chain-similar-head p { margin: 2px 0 0; color: var(--stats-muted,#66758a); font-size: .65rem; }
.stats-chain-similar-list {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 6px;
  margin-top: 8px;
}
.stats-chain-similar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
  border-radius: 8px;
  background: var(--stats-card-bg,#fff);
  color: var(--stats-text,#172033);
  text-align: left;
  cursor: pointer;
}
.stats-chain-similar-item:hover { border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 35%,var(--stats-card-border,#dfe6ee)); }
.stats-chain-similar-item span { min-width: 0; }
.stats-chain-similar-item strong { display: block; font-size: .69rem; }
.stats-chain-similar-item small { display: block; margin-top: 2px; color: var(--stats-muted,#718097); font-size: .62rem; }
.stats-chain-similar-item em { flex: 0 0 auto; max-width: 46%; color: var(--stats-accent,#4f46e5); font-size: .61rem; font-style: normal; text-align: right; }
.stats-chain-similar-empty { color: var(--stats-muted,#718097); font-size: .67rem; }

@media (max-width: 1120px) {
  .stats-chain-patterns-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .stats-chain-context-bar { align-items: stretch; flex-direction: column; }
  .stats-chain-context-actions { flex-wrap: wrap; }
  .stats-chain-similar-list { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .stats-chain-signatures--context { grid-template-columns: 1fr; }
}

/* =========================================================
   Statistics 5.12A — Relation Structure Map 1.0
   Whole-dataset component map: document + shape layouts.
   ========================================================= */
.stats-structure-map-guide { margin-bottom: 14px; }
.stats-structure-map-guide-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.stats-structure-map-controls { margin-bottom: 14px; }
.stats-structure-map-control-grid {
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 13px 15px;
  align-items: start !important;
}
.stats-structure-map-control-grid .stats-tool-field { min-width: 0; }
.stats-structure-map-control-grid .stats-polished-select { width: 100%; min-width: 0; }
.stats-structure-map-kpis { margin-bottom: 14px; }

.stats-structure-map-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
}
.stats-structure-map-layout-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.stats-structure-map-layout-switch > span {
  color: var(--stats-muted,#66758a);
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-structure-map-search { flex: 1 1 520px; max-width: 700px; }
.stats-structure-map-count {
  margin-left: auto;
  color: var(--stats-muted,#66758a);
  font-size: .7rem;
  font-weight: 800;
  white-space: nowrap;
}

.stats-structure-map-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(285px,340px);
  gap: 16px;
  align-items: start;
}
.stats-structure-map-canvas-card,
.stats-structure-map-detail-card {
  border: 1px solid var(--stats-card-border,#dfe6ee);
  border-radius: 14px;
  background: var(--stats-card-bg,#fff);
  box-shadow: 0 1px 4px rgba(15,23,42,.04);
}
.stats-structure-map-canvas-card { min-width: 0; overflow: hidden; }
.stats-structure-map-detail-card {
  position: sticky;
  top: 88px;
  padding: 13px;
  min-width: 0;
}
.stats-structure-map-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 38px;
  padding: 8px 11px;
  border-bottom: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 75%,transparent);
  color: var(--stats-muted,#66758a);
  font-size: .65rem;
}
.stats-structure-map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.stats-structure-map-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--map-color,#94a3b8);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.12);
}
.stats-structure-map-canvas {
  min-height: 520px;
  overflow: auto;
  background:
    linear-gradient(to right, color-mix(in srgb,var(--stats-card-border,#e2e8f0) 22%,transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb,var(--stats-card-border,#e2e8f0) 18%,transparent) 1px, transparent 1px),
    color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 95%,transparent);
  background-size: 28px 28px;
}
.stats-structure-map-svg {
  display: block;
  width: 100%;
  min-width: 1040px;
  height: var(--map-svg-height,520px);
  min-height: 520px;
}
.stats-structure-map-node {
  cursor: pointer;
  outline: none;
  transition: opacity .14s ease, filter .14s ease;
}
.stats-structure-map-node circle {
  stroke: rgba(30,41,59,.28);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  transition: stroke .14s ease, stroke-width .14s ease, filter .14s ease;
}
.stats-structure-map-node text {
  fill: #fff;
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(15,23,42,.28);
  stroke-width: 2px;
  pointer-events: none;
}
.stats-structure-map-node:hover circle,
.stats-structure-map-node:focus-visible circle {
  stroke: var(--stats-accent,#4f46e5);
  stroke-width: 2.5;
  filter: drop-shadow(0 3px 5px rgba(79,70,229,.2));
}
.stats-structure-map-node.is-selected circle {
  stroke: var(--stats-accent,#4f46e5);
  stroke-width: 3.5;
  filter: drop-shadow(0 3px 7px rgba(79,70,229,.28));
}
.stats-structure-map-node.is-selected text { font-size: 11px; }
.stats-structure-map-span {
  stroke: color-mix(in srgb,var(--stats-muted,#64748b) 38%,transparent);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 3 3;
}
.stats-structure-map-span.is-selected {
  stroke: var(--stats-accent,#4f46e5);
  stroke-width: 2.2;
  stroke-dasharray: none;
}
.stats-structure-map-axis { stroke: color-mix(in srgb,var(--stats-muted,#64748b) 45%,transparent); stroke-width: 1; }
.stats-structure-map-axis-label { fill: var(--stats-muted,#718097); font-size: 9px; }
.stats-structure-map-cluster-label {
  fill: var(--stats-text-soft,#475569);
  font-size: 12px;
  font-weight: 850;
  text-anchor: middle;
  text-transform: uppercase;
  letter-spacing: .03em;
}

#structureMapDetail[hidden] { display: none !important; }
.stats-structure-map-detail-empty {
  display: grid;
  gap: 5px;
  min-height: 205px;
  place-content: center;
  padding: 18px;
  text-align: center;
  color: var(--stats-muted,#66758a);
}
.stats-structure-map-detail-empty strong { color: var(--stats-text,#172033); font-size: .85rem; }
.stats-structure-map-detail-empty span { max-width: 260px; font-size: .69rem; line-height: 1.45; }
.stats-structure-map-detail-head h3 { margin: 0; font-size: .96rem; }
.stats-structure-map-mini-graph {
  margin: 10px 0;
  overflow: auto;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent);
  border-radius: 10px;
  background: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 94%,transparent);
}
.stats-structure-map-mini-graph .stats-structure-example-svg {
  width: 100%;
  min-width: 460px;
  min-height: 225px;
  max-height: 270px;
}
.stats-structure-map-detail-grid { display: grid; gap: 7px; }
.stats-structure-map-detail-grid > div {
  padding: 7px 8px;
  border-radius: 9px;
  background: color-mix(in srgb,var(--stats-soft,#f3f6fa) 90%,transparent);
}
.stats-structure-map-detail-grid span {
  display: block;
  margin-bottom: 3px;
  color: var(--stats-muted,#718097);
  font-size: .61rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-structure-map-detail-grid strong {
  display: block;
  color: var(--stats-text,#172033);
  font-size: .7rem;
  line-height: 1.45;
  font-weight: 750;
}
.stats-structure-map-detail-grid small { color: var(--stats-muted,#718097); font-weight: 700; }
.stats-structure-map-detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 11px;
}
.stats-structure-map-detail-actions .stats-btn { flex: 1 1 auto; min-height: 34px; padding: 6px 8px; }
.stats-structure-example-card.is-map-jump-target {
  border-color: var(--stats-accent,#4f46e5) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--stats-accent,#6366f1) 12%,transparent),0 8px 22px rgba(79,70,229,.08) !important;
}

@media (max-width: 1260px) {
  .stats-structure-map-control-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stats-structure-map-layout { grid-template-columns: minmax(0,1fr) 300px; }
}
@media (max-width: 980px) {
  .stats-structure-map-guide-grid { grid-template-columns: 1fr; }
  .stats-structure-map-layout { grid-template-columns: 1fr; }
  .stats-structure-map-detail-card { position: static; }
  .stats-structure-map-toolbar { align-items: stretch; flex-wrap: wrap; }
  .stats-structure-map-search { max-width: none; flex: 1 1 100%; order: 3; }
  .stats-structure-map-count { margin-left: 0; }
}
@media (max-width: 640px) {
  .stats-structure-map-control-grid { grid-template-columns: 1fr; }
  .stats-structure-map-toolbar { flex-direction: column; }
  .stats-structure-map-layout-switch { align-items: stretch; flex-direction: column; }
  .stats-structure-map-layout-switch .stats-segmented { width: 100%; }
  .stats-structure-map-layout-switch .stats-segmented button { flex: 1; }
  .stats-structure-map-count { white-space: normal; }
}
.stats-structure-map-span.is-hovered {
  stroke: color-mix(in srgb,var(--stats-accent,#4f46e5) 72%,transparent);
  stroke-width: 2;
}

/* =========================================================
   Statistics 5.12B — Relation Structure Map semantic clarity
   Explicit spatial semantics, document ticks, categorical packing.
   ========================================================= */
.stats-structure-map-guide-grid {
  grid-template-columns: repeat(4,minmax(0,1fr));
}

.stats-structure-map-semantic-note {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  margin: -3px 0 10px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 15%,var(--stats-card-border,#dfe6ee));
  border-radius: 9px;
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 3%,var(--stats-card-bg,#fff));
  color: var(--stats-muted,#66758a);
  font-size: .68rem;
  line-height: 1.45;
}
.stats-structure-map-semantic-note strong {
  color: var(--stats-text-soft,#475569);
  font-size: .69rem;
}

.stats-structure-map-zone rect {
  fill: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 96%,transparent);
  stroke: color-mix(in srgb,var(--stats-card-border,#dfe6ee) 76%,transparent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.stats-structure-map-cluster-count {
  fill: var(--stats-muted,#718097);
  font-size: 8.5px;
  font-weight: 700;
  text-anchor: middle;
}

.stats-structure-map-axis-tick line {
  stroke: color-mix(in srgb,var(--stats-muted,#64748b) 42%,transparent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.stats-structure-map-axis-tick text,
.stats-structure-map-axis-title {
  fill: var(--stats-muted,#718097);
  font-size: 8.5px;
}
.stats-structure-map-axis-title {
  font-weight: 750;
  letter-spacing: .02em;
}
.stats-structure-map-selected-range line {
  stroke: var(--stats-accent,#4f46e5);
  stroke-width: 3;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.stats-structure-map-selected-range circle {
  fill: var(--stats-accent,#4f46e5);
}
.stats-structure-map-selected-range text {
  fill: var(--stats-accent,#4338ca);
  font-size: 8.5px;
  font-weight: 850;
  paint-order: stroke;
  stroke: var(--stats-card-bg,#fff);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.stats-structure-map-node text {
  font-size: 9px;
}
.stats-structure-map-node.is-selected text { font-size: 10px; }

#structureMapDetailEmpty[hidden],
#structureMapDetail[hidden] {
  display: none !important;
}

.stats-structure-map-mini-graph {
  overflow: hidden;
}
.stats-structure-map-mini-graph .stats-structure-example-svg,
.stats-structure-map-mini-graph .stats-structure-example-svg.is-dense {
  width: 100%;
  min-width: 0;
  min-height: 210px;
  height: 230px;
  max-height: 260px;
}

@media (max-width: 1260px) {
  .stats-structure-map-guide-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 980px) {
  .stats-structure-map-guide-grid { grid-template-columns: 1fr; }
}


/* =========================================================
   Statistics 5.12C — Structure Map top ruler + external Annotation
   ========================================================= */
.stats-external-annotation::after {
  content: "↗";
  display: inline-block;
  margin-left: 5px;
  font-size: .82em;
  line-height: 1;
  transform: translateY(-1px);
}
.stats-structure-map-axis-group {
  pointer-events: none;
}
.stats-structure-map-axis-group .stats-structure-map-axis {
  stroke-width: 1.15;
}
.stats-structure-map-axis-group .stats-structure-map-axis-title {
  font-size: 9px;
}


/* =========================================================
   Statistics 5.12D.1 — Structure Map similarity layout + readable labels
   ========================================================= */
.stats-structure-map-guide-grid {
  grid-template-columns: repeat(5,minmax(0,1fr));
}
.stats-structure-map-similarity-card {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid color-mix(in srgb,var(--stats-accent,#6366f1) 16%,var(--stats-card-border,#dfe6ee));
  border-radius: 11px;
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 3%,var(--stats-card-bg,#fff));
}
.stats-structure-map-similarity-head h4 { margin: 0; font-size: .78rem; color: var(--stats-text,#172033); }
.stats-structure-map-similarity-head p { margin: 4px 0 0; color: var(--stats-muted,#66758a); font-size: .66rem; line-height: 1.45; }
.stats-structure-map-similarity-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}
.stats-structure-map-similarity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 10px;
  background: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 92%,transparent);
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
}
.stats-structure-map-similarity-item:hover { border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 35%,var(--stats-card-border,#dfe6ee)); }
.stats-structure-map-similarity-item strong { display: block; font-size: .71rem; color: var(--stats-text,#172033); }
.stats-structure-map-similarity-item small { display: block; margin-top: 2px; color: var(--stats-muted,#718097); font-size: .62rem; line-height: 1.35; }
.stats-structure-map-similarity-score {
  flex: 0 0 auto;
  min-width: 56px;
  text-align: right;
  font-size: .78rem;
  font-weight: 850;
  color: var(--stats-accent,#4338ca);
}
.stats-structure-map-similarity-go {
  margin-left: 8px;
  min-height: 28px;
  padding: 5px 8px;
}
.stats-structure-map-similarity-weights {
  display: grid;
  gap: 4px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
}
.stats-structure-map-similarity-weights span {
  color: var(--stats-muted,#718097);
  font-size: .61rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-structure-map-similarity-weights strong {
  color: var(--stats-text,#172033);
  font-size: .68rem;
  line-height: 1.45;
}
.stats-structure-map-sim-line {
  stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 38%,transparent);
  stroke-width: 1.6;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}
.stats-structure-map-sim-line.is-strong {
  stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 58%,transparent);
}
.stats-structure-map-similarity-label rect {
  fill: color-mix(in srgb,var(--stats-card-bg,#fff) 92%,transparent);
  stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 18%,var(--stats-card-border,#dfe6ee));
  stroke-width: 1;
  rx: 8px;
}
.stats-structure-map-similarity-label text {
  fill: var(--stats-accent,#4338ca);
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: color-mix(in srgb,var(--stats-card-bg,#fff) 88%,transparent);
  stroke-width: 2.4px;
  stroke-linejoin: round;
}
.stats-structure-map-node.is-sim-neighbor circle {
  stroke: color-mix(in srgb,var(--stats-accent,#6366f1) 76%,transparent);
  stroke-width: 2.7;
}
@media (max-width: 1400px) {
  .stats-structure-map-guide-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 1260px) {
  .stats-structure-map-guide-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 980px) {
  .stats-structure-map-guide-grid { grid-template-columns: 1fr; }
}


/* =========================================================
   Statistics 5.13A — Structure Reader core
   One relation structure read in document order.
   ========================================================= */
.stats-structure-reader-panel {
  --reader-line: color-mix(in srgb,var(--stats-accent,#6366f1) 24%,var(--stats-card-border,#dfe6ee));
}
.stats-structure-reader-picker-card { margin-bottom: 14px; }
.stats-structure-reader-picker-row {
  display: grid;
  grid-template-columns: 42px minmax(260px,560px) 42px;
  align-items: end;
  justify-content: center;
  gap: 10px;
}
.stats-structure-reader-picker-row > .stats-btn {
  width: 42px;
  min-width: 42px;
  height: 38px;
  padding: 0;
  font-size: 1rem;
}
.stats-structure-reader-picker-main { display: grid; gap: 5px; }
.stats-structure-reader-picker-main label {
  color: var(--stats-text-soft,#475569);
  font-size: .68rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-structure-reader-picker-main small {
  color: var(--stats-muted,#718097);
  font-size: .64rem;
  line-height: 1.4;
}
.stats-structure-reader-empty {
  display: grid;
  min-height: 250px;
  place-content: center;
  gap: 7px;
  text-align: center;
}
.stats-structure-reader-empty strong { color: var(--stats-text,#172033); font-size: .95rem; }
.stats-structure-reader-empty span { max-width: 580px; color: var(--stats-muted,#66758a); font-size: .72rem; line-height: 1.55; }
#structureReaderContent[hidden],#structureReaderEmpty[hidden] { display: none !important; }
.stats-structure-reader-structure-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 12px;
  padding: 13px 15px;
  border: 1px solid var(--stats-card-border,#dfe6ee);
  border-radius: 12px;
  background: var(--stats-card-bg,#fff);
}
.stats-structure-reader-breadcrumb {
  margin-bottom: 4px;
  color: var(--stats-muted,#718097);
  font-size: .61rem;
  font-weight: 750;
  letter-spacing: .02em;
}
.stats-structure-reader-structure-head h2 {
  margin: 0 0 5px;
  color: var(--stats-text,#172033);
  font-size: 1.16rem;
}
.stats-structure-reader-head-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.stats-structure-reader-head-actions .stats-btn { min-height: 34px; padding: 6px 9px; }
.stats-structure-reader-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) 340px;
  gap: 14px;
  align-items: start;
}
.stats-structure-reader-document-card,
.stats-structure-reader-inspector-card {
  border: 1px solid var(--stats-card-border,#dfe6ee);
  border-radius: 12px;
  background: var(--stats-card-bg,#fff);
}
.stats-structure-reader-document-card { padding: 14px; min-width: 0; }
.stats-structure-reader-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 74%,transparent);
}
.stats-structure-reader-section-head h3 { margin: 0; color: var(--stats-text,#172033); font-size: .88rem; }
.stats-structure-reader-section-head p { margin: 4px 0 0; color: var(--stats-muted,#66758a); font-size: .67rem; line-height: 1.45; }
.stats-structure-reader-document { display: grid; gap: 13px; }
.stats-structure-reader-segment {
  position: relative;
  padding: 12px 13px 13px 17px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 88%,transparent);
  border-radius: 11px;
  background: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 80%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-segment::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--reader-line);
}
.stats-structure-reader-segment-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  color: var(--stats-muted,#66758a);
  font-size: .66rem;
}
.stats-structure-reader-segment-head strong { color: var(--stats-text-soft,#475569); font-size: .7rem; }
.stats-structure-reader-segment-text {
  margin: 0;
  color: var(--stats-text,#172033);
  font-size: .84rem;
  line-height: 1.7;
  white-space: pre-wrap;
}
.stats-structure-reader-segment-text mark {
  padding: 1px 2px;
  border-radius: 4px;
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 15%,transparent);
  color: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.stats-structure-reader-segment-text mark.is-selected {
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 28%,transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--stats-accent,#6366f1) 28%,transparent);
}
.stats-structure-reader-annotations { display: grid; gap: 8px; margin-top: 11px; }
.stats-structure-reader-ann {
  display: grid;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 86%,transparent);
  border-radius: 9px;
  background: var(--stats-card-bg,#fff);
  cursor: pointer;
  transition: border-color .14s ease,box-shadow .14s ease,background .14s ease;
}
.stats-structure-reader-ann:hover { border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 30%,var(--stats-card-border,#dfe6ee)); }
.stats-structure-reader-ann.is-selected {
  border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 62%,var(--stats-card-border,#dfe6ee));
  box-shadow: 0 0 0 2px color-mix(in srgb,var(--stats-accent,#6366f1) 9%,transparent);
  background: color-mix(in srgb,var(--stats-accent,#6366f1) 3%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-ann-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stats-structure-reader-ann-head .ann-id-badge { flex: 0 0 auto; }
.stats-structure-reader-ann-tag { display: grid; gap: 1px; min-width: 0; }
.stats-structure-reader-ann-tag strong { color: var(--stats-text,#172033); font-size: .72rem; }
.stats-structure-reader-ann-tag small { color: var(--stats-muted,#718097); font-size: .61rem; }
.stats-structure-reader-relations { display: flex; flex-wrap: wrap; gap: 5px; }
.stats-structure-reader-rel-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 27px;
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 86%,transparent);
  border-radius: 999px;
  background: color-mix(in srgb,var(--stats-soft,#f3f6fa) 84%,transparent);
  color: var(--stats-text-soft,#475569);
  font: inherit;
  font-size: .61rem;
  cursor: pointer;
}
.stats-structure-reader-rel-chip:hover { border-color: color-mix(in srgb,var(--stats-accent,#6366f1) 34%,var(--stats-card-border,#dfe6ee)); }
.stats-structure-reader-rel-chip b { color: var(--stats-accent,#4338ca); font-weight: 850; }
.stats-structure-reader-rel-chip em { color: var(--stats-muted,#718097); font-style: normal; }
.stats-structure-reader-inspector-card {
  position: sticky;
  top: 76px;
  overflow: hidden;
}
.stats-structure-reader-inspector-section { padding: 12px; }
.stats-structure-reader-inspector-section + .stats-structure-reader-inspector-section {
  border-top: 1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 80%,transparent);
}
.stats-structure-reader-inspector-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.stats-structure-reader-inspector-title span {
  color: var(--stats-muted,#718097);
  font-size: .61rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stats-structure-reader-inspector-title strong { color: var(--stats-text,#172033); font-size: .78rem; }
.stats-structure-reader-mini-graph { margin: 6px 0 9px; }
.stats-structure-reader-mini-graph .stats-structure-example-svg,
.stats-structure-reader-mini-graph .stats-structure-example-svg.is-dense { height: 205px; min-height: 190px; max-height: 220px; }
.stats-structure-reader-facts { display: grid; gap: 6px; }
.stats-structure-reader-facts > div {
  padding: 7px 8px;
  border-radius: 8px;
  background: color-mix(in srgb,var(--stats-soft,#f3f6fa) 85%,transparent);
}
.stats-structure-reader-facts span { display: block; color: var(--stats-muted,#718097); font-size: .58rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.stats-structure-reader-facts strong { display: block; margin-top: 2px; color: var(--stats-text,#172033); font-size: .67rem; line-height: 1.45; }
.stats-structure-reader-ann-empty { color: var(--stats-muted,#718097); font-size: .67rem; line-height: 1.5; }
.stats-structure-reader-ann-detail { display: grid; gap: 8px; }
.stats-structure-reader-ann-detail-head { display: grid; gap: 3px; }
.stats-structure-reader-ann-detail-head strong { color: var(--stats-text,#172033); font-size: .76rem; }
.stats-structure-reader-ann-detail-head small { color: var(--stats-muted,#718097); font-size: .63rem; }
.stats-structure-reader-ann-detail-block { display: grid; gap: 4px; }
.stats-structure-reader-ann-detail-block > span { color: var(--stats-muted,#718097); font-size: .58rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.stats-structure-reader-ann-detail-block > p { margin: 0; color: var(--stats-text-soft,#475569); font-size: .69rem; line-height: 1.5; }
.stats-structure-reader-ann-relations { display: grid; gap: 5px; }
.stats-structure-reader-ann-relations button { width: 100%; justify-content: flex-start; border-radius: 8px; }
@media (max-width: 1180px) {
  .stats-structure-reader-layout { grid-template-columns: minmax(0,1fr) 300px; }
}
@media (max-width: 900px) {
  .stats-structure-reader-layout { grid-template-columns: 1fr; }
  .stats-structure-reader-inspector-card { position: static; }
  .stats-structure-reader-structure-head { align-items: stretch; flex-direction: column; }
  .stats-structure-reader-head-actions { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .stats-structure-reader-picker-row { grid-template-columns: 38px minmax(0,1fr) 38px; }
  .stats-structure-reader-picker-row > .stats-btn { width: 38px; min-width: 38px; }
  .stats-structure-reader-document-card { padding: 10px; }
}


/* =========================================================
   Statistics 5.13B — Structure Reader navigation + local context
   ========================================================= */
.stats-structure-reader-pick-fields {
  display: grid;
  grid-template-columns: minmax(230px,.75fr) minmax(280px,1.25fr);
  gap: 8px;
  align-items: center;
}
.stats-structure-reader-search { max-width: none; min-width: 0; }
.stats-structure-reader-search input { min-width: 0; }
.stats-structure-reader-scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.stats-structure-reader-scope-row #structureReaderSearchSummary {
  color: var(--stats-accent,#4f46e5);
  font-weight: 800;
}
.stats-structure-reader-gap {
  display: grid;
  gap: 9px;
  margin: -2px 0;
  padding: 8px 10px;
  border: 1px dashed color-mix(in srgb,var(--stats-muted,#64748b) 25%,var(--stats-card-border,#dfe6ee));
  border-radius: 10px;
  background: color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 92%,transparent);
}
.stats-structure-reader-gap-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--stats-muted,#718097);
  font-size: .66rem;
  font-weight: 750;
}
.stats-structure-reader-gap-toggle { min-height: 28px; padding: 4px 8px; font-size: .62rem; }
.stats-structure-reader-context-list { display: grid; gap: 7px; }
.stats-structure-reader-context-list > small {
  color: var(--stats-muted,#718097);
  font-size: .59rem;
  text-align: center;
}
.stats-structure-reader-context-segment {
  padding: 9px 10px;
  border-left: 2px solid color-mix(in srgb,var(--stats-muted,#64748b) 28%,transparent);
  border-radius: 0 9px 9px 0;
  background: color-mix(in srgb,var(--stats-soft,#f3f6fa) 78%,transparent);
}
.stats-structure-reader-context-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--stats-muted,#718097);
  font-size: .61rem;
}
.stats-structure-reader-context-head > span:first-child {
  padding: 2px 5px;
  border-radius: 999px;
  background: color-mix(in srgb,var(--stats-muted,#64748b) 10%,transparent);
  font-size: .55rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.stats-structure-reader-context-head strong { color: var(--stats-text-soft,#475569); font-size: .63rem; }
.stats-structure-reader-context-head em { font-style: normal; }
.stats-structure-reader-context-segment p {
  margin: 6px 0 0;
  color: var(--stats-text-soft,#475569);
  font-size: .7rem;
  line-height: 1.52;
}
.stats-structure-reader-context-omitted {
  padding: 3px 0;
  color: var(--stats-muted,#718097);
  font-size: .61rem;
  font-weight: 750;
  text-align: center;
}
@media (max-width: 840px) {
  .stats-structure-reader-pick-fields { grid-template-columns: 1fr; }
}


/* =========================================================
   Statistics 5.13C — Structure Reader interactions + bilingual mode
   ========================================================= */
.stats-structure-reader-section-head {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}
.stats-structure-reader-language-switch {
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
}
.stats-structure-reader-language-switch > span {
  color:var(--stats-muted,#718097);
  font-size:.61rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.035em;
}
.stats-structure-reader-language-switch .stats-segmented button { min-height:30px; padding:5px 9px; font-size:.64rem; }
.stats-structure-reader-interaction-hint {
  margin:0 0 10px;
  padding:7px 9px;
  border-radius:9px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 4%,var(--stats-panel-bg,#fbfcfe));
  color:var(--stats-muted,#66758a);
  font-size:.63rem;
  line-height:1.4;
}
.stats-structure-reader-lang-block { display:grid; grid-template-columns:34px minmax(0,1fr); gap:7px; align-items:start; }
.stats-structure-reader-lang-block + .stats-structure-reader-lang-block { margin-top:8px; padding-top:8px; border-top:1px dashed color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent); }
.stats-structure-reader-lang-block > span,
.stats-structure-reader-context-lang > span,
.stats-structure-reader-inspector-lang > b {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:max-content;
  min-width:28px;
  min-height:19px;
  padding:2px 5px;
  border-radius:5px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 8%,var(--stats-card-bg,#fff));
  color:var(--stats-accent,#4338ca);
  font-size:.56rem;
  font-weight:850;
  letter-spacing:.03em;
}
.stats-structure-reader-lang-block .stats-structure-reader-segment-text { margin:0; }
.stats-structure-reader-lang-block > small,
.stats-structure-reader-context-lang > small,
.stats-structure-reader-inspector-lang > small { grid-column:2; color:var(--stats-muted,#718097); font-size:.58rem; }
.stats-structure-reader-lang-block.is-fallback,
.stats-structure-reader-context-lang.is-fallback,
.stats-structure-reader-inspector-lang.is-fallback { opacity:.72; }
.stats-structure-reader-context-lang { display:grid; grid-template-columns:34px minmax(0,1fr); gap:7px; align-items:start; margin-top:7px; }
.stats-structure-reader-context-lang p { margin:0 !important; }
.stats-structure-reader-inspector-lang { display:grid; grid-template-columns:34px minmax(0,1fr); gap:7px; align-items:start; }
.stats-structure-reader-inspector-lang + .stats-structure-reader-inspector-lang { margin-top:7px; }
.stats-structure-reader-inspector-lang p { margin:0; }
.stats-structure-reader-rel-route { font-weight:750; color:var(--stats-text-soft,#475569); }
.stats-structure-reader-ann,
.stats-structure-reader-rel-chip,
.stats-structure-reader-segment-text mark { transition:opacity .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease; }
.stats-structure-reader-ann.is-reader-focus {
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 72%,var(--stats-card-border,#dfe6ee));
  box-shadow:inset 3px 0 0 var(--stats-accent,#4f46e5),0 0 0 2px color-mix(in srgb,var(--stats-accent,#6366f1) 7%,transparent);
}
.stats-structure-reader-ann.is-reader-source {
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 58%,var(--stats-card-border,#dfe6ee));
  box-shadow:inset 3px 0 0 color-mix(in srgb,var(--stats-accent,#6366f1) 72%,transparent);
}
.stats-structure-reader-ann.is-reader-target {
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 38%,var(--stats-card-border,#dfe6ee));
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 5%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-ann.is-reader-dimmed,
.stats-structure-reader-rel-chip.is-reader-dimmed { opacity:.28; }
.stats-structure-reader-rel-chip.is-relation-active {
  opacity:1 !important;
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 68%,var(--stats-card-border,#dfe6ee));
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 8%,var(--stats-card-bg,#fff));
  box-shadow:0 0 0 2px color-mix(in srgb,var(--stats-accent,#6366f1) 7%,transparent);
}
.stats-structure-reader-segment-text mark.is-reader-focus,
.stats-structure-reader-segment-text mark.is-reader-source {
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 28%,#fff3a5);
  box-shadow:0 0 0 2px color-mix(in srgb,var(--stats-accent,#6366f1) 16%,transparent);
}
.stats-structure-reader-segment-text mark.is-reader-target { background:color-mix(in srgb,var(--stats-accent,#6366f1) 16%,#fff3a5); }
.stats-structure-reader-segment-text mark.is-reader-dimmed { opacity:.35; }
.stats-structure-reader-mini-graph [data-node-id],
.stats-structure-reader-mini-graph [data-rel-id] { cursor:pointer; }
@media (max-width: 760px) {
  .stats-structure-reader-section-head { flex-direction:column; }
  .stats-structure-reader-language-switch { width:100%; justify-content:space-between; }
  .stats-structure-reader-language-switch .stats-segmented { flex:1; }
  .stats-structure-reader-language-switch .stats-segmented button { flex:1; }
}


/* =========================================================
   Statistics 5.13C.1 — Structure Reader translation resolver fix
   ========================================================= */
.stats-structure-reader-translation-empty {
  color:var(--stats-muted,#718097);
  font-style:italic;
}
.stats-structure-reader-ann-text {
  display:grid;
  gap:5px;
  margin:7px 0 2px 34px;
  padding-top:7px;
  border-top:1px dashed color-mix(in srgb,var(--stats-card-border,#dfe6ee) 72%,transparent);
}
.stats-structure-reader-ann-text-row {
  display:grid;
  grid-template-columns:31px minmax(0,1fr);
  gap:7px;
  align-items:start;
}
.stats-structure-reader-ann-text-row b {
  display:inline-flex;
  justify-content:center;
  padding:2px 4px;
  border-radius:5px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 7%,var(--stats-card-bg,#fff));
  color:var(--stats-accent,#4338ca);
  font-size:.53rem;
  font-weight:850;
}
.stats-structure-reader-ann-text-row span {
  color:var(--stats-text-soft,#475569);
  font-size:.65rem;
  line-height:1.45;
}
.stats-structure-reader-ann-text-row small {
  grid-column:2;
  color:var(--stats-muted,#718097);
  font-size:.57rem;
}
.stats-structure-reader-ann-text-row.is-missing { opacity:.72; }


/* =========================================================
   Statistics 5.13D — Structure Reader order, paths + export
   ========================================================= */
.stats-structure-reader-view-controls {
  display:flex;
  align-items:flex-start;
  justify-content:flex-end;
  gap:12px;
  flex-wrap:wrap;
}
.stats-structure-reader-order-switch {
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
}
.stats-structure-reader-order-switch > span {
  color:var(--stats-muted,#718097);
  font-size:.61rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.035em;
}
.stats-structure-reader-order-switch .stats-segmented button { min-height:30px; padding:5px 9px; font-size:.64rem; }
.stats-structure-reader-path-bar {
  display:grid;
  grid-template-columns:minmax(220px,340px) minmax(0,1fr);
  gap:10px;
  align-items:end;
  margin:0 0 11px;
  padding:9px 10px;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
  border-radius:10px;
  background:color-mix(in srgb,var(--stats-soft,#f3f6fa) 68%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-path-picker { display:grid; gap:4px; }
.stats-structure-reader-path-picker label {
  color:var(--stats-muted,#718097);
  font-size:.59rem;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.035em;
}
.stats-structure-reader-path-summary {
  color:var(--stats-muted,#66758a);
  font-size:.63rem;
  line-height:1.45;
}
.stats-structure-reader-path-summary strong { color:var(--stats-text-soft,#475569); }
.stats-structure-reader-relational-step {
  position:relative;
  padding-top:32px;
}
.stats-structure-reader-step-badge {
  position:absolute;
  top:8px;
  right:10px;
  display:inline-flex;
  align-items:center;
  gap:4px;
  padding:3px 7px;
  border-radius:999px;
  background:color-mix(in srgb,var(--stats-accent,#6366f1) 7%,var(--stats-card-bg,#fff));
  color:var(--stats-accent,#4338ca);
  font-size:.57rem;
  font-weight:850;
}
.stats-structure-reader-mini-graph .is-path-dimmed { opacity:.16 !important; }
.stats-structure-reader-mini-graph .is-path-active { opacity:1 !important; }
.stats-structure-reader-mini-graph [data-rel-id].is-path-active {
  filter:drop-shadow(0 0 2px color-mix(in srgb,var(--stats-accent,#6366f1) 42%,transparent));
}
@media (max-width: 900px) {
  .stats-structure-reader-view-controls { justify-content:flex-start; }
  .stats-structure-reader-path-bar { grid-template-columns:1fr; }
}
@media (max-width: 760px) {
  .stats-structure-reader-view-controls { width:100%; }
  .stats-structure-reader-order-switch,
  .stats-structure-reader-language-switch { width:100%; justify-content:space-between; }
  .stats-structure-reader-order-switch .stats-segmented,
  .stats-structure-reader-language-switch .stats-segmented { flex:1; }
  .stats-structure-reader-order-switch .stats-segmented button,
  .stats-structure-reader-language-switch .stats-segmented button { flex:1; }
}


/* =========================================================
   Statistics 5.13D.1 — Structure Reader graph panel + enlarged modal
   ========================================================= */
@media (min-width: 1181px) {
  .stats-structure-reader-layout { grid-template-columns:minmax(0,1fr) 395px; gap:16px; }
}
@media (min-width: 901px) and (max-width: 1180px) {
  .stats-structure-reader-layout { grid-template-columns:minmax(0,1fr) 335px; }
}
.stats-structure-reader-inspector-title--graph { align-items:center; margin-bottom:7px; }
.stats-structure-reader-inspector-title-actions { display:flex; align-items:center; gap:8px; }
.stats-structure-reader-enlarge-btn {
  display:inline-flex;
  align-items:center;
  min-height:27px;
  padding:4px 8px;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 90%,transparent);
  border-radius:8px;
  background:var(--stats-card-bg,#fff);
  color:var(--stats-text-soft,#475569);
  font:inherit;
  font-size:.59rem;
  font-weight:800;
  cursor:pointer;
}
.stats-structure-reader-enlarge-btn::after { content:" ⛶"; margin-left:4px; color:var(--stats-accent,#4338ca); }
.stats-structure-reader-enlarge-btn:hover,
.stats-structure-reader-enlarge-btn:focus-visible {
  border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 40%,var(--stats-card-border,#dfe6ee));
  color:var(--stats-accent,#4338ca);
  outline:none;
}
.stats-structure-reader-mini-graph {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:250px;
  margin:5px 0 10px;
  padding:6px;
  border-radius:10px;
  background:color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 86%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-mini-graph .stats-structure-example-svg,
.stats-structure-reader-mini-graph .stats-structure-example-svg.is-dense {
  width:100%;
  min-width:0;
  height:250px;
  min-height:250px;
  max-height:250px;
}
.stats-structure-reader-mini-graph .stats-structure-example-node-id { font-size:13px; }
.stats-structure-reader-mini-graph .stats-structure-example-node-tag { font-size:10.4px; }
.stats-structure-reader-mini-graph .stats-structure-example-edge-label { font-size:10.4px; }

/* One metadata card instead of a stack of separate tiles. */
.stats-structure-reader-facts {
  display:grid;
  gap:0;
  padding:3px 9px;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent);
  border-radius:10px;
  background:color-mix(in srgb,var(--stats-soft,#f3f6fa) 66%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-facts > div {
  display:grid;
  grid-template-columns:88px minmax(0,1fr);
  gap:9px;
  align-items:start;
  padding:7px 0;
  border-radius:0;
  background:transparent;
}
.stats-structure-reader-facts > div + div { border-top:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 70%,transparent); }
.stats-structure-reader-facts span { margin:1px 0 0; }
.stats-structure-reader-facts strong { margin:0; font-size:.67rem; }

.stats-structure-reader-graph-modal[hidden] { display:none !important; }
.stats-structure-reader-graph-modal {
  position:fixed;
  inset:0;
  z-index:12000;
  display:grid;
  place-items:center;
  padding:28px;
}
.stats-structure-reader-graph-modal-backdrop {
  position:absolute;
  inset:0;
  background:rgba(15,23,42,.48);
  backdrop-filter:blur(2px);
}
.stats-structure-reader-graph-modal-card {
  position:relative;
  z-index:1;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  width:min(1240px,92vw);
  height:min(820px,86vh);
  overflow:hidden;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 82%,transparent);
  border-radius:16px;
  background:var(--stats-card-bg,#fff);
  box-shadow:0 24px 70px rgba(15,23,42,.26);
}
.stats-structure-reader-graph-modal-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  border-bottom:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent);
}
.stats-structure-reader-graph-modal-head span {
  display:block;
  margin-bottom:3px;
  color:var(--stats-muted,#718097);
  font-size:.59rem;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.045em;
}
.stats-structure-reader-graph-modal-head h3 { margin:0; color:var(--stats-text,#172033); font-size:1rem; }
.stats-structure-reader-graph-modal-close {
  width:34px;
  height:34px;
  border:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 86%,transparent);
  border-radius:9px;
  background:var(--stats-card-bg,#fff);
  color:var(--stats-text-soft,#475569);
  font-size:1.25rem;
  line-height:1;
  cursor:pointer;
}
.stats-structure-reader-graph-modal-close:hover { color:var(--stats-accent,#4338ca); border-color:color-mix(in srgb,var(--stats-accent,#6366f1) 35%,var(--stats-card-border,#dfe6ee)); }
.stats-structure-reader-graph-modal-graph {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:0;
  overflow:auto;
  padding:18px;
  background:color-mix(in srgb,var(--stats-panel-bg,#fbfcfe) 88%,var(--stats-card-bg,#fff));
}
.stats-structure-reader-graph-modal-graph .stats-structure-example-svg,
.stats-structure-reader-graph-modal-graph .stats-structure-example-svg.is-dense {
  width:100%;
  height:100%;
  min-width:640px;
  min-height:440px;
  max-height:none;
}
.stats-structure-reader-graph-modal-graph .stats-structure-example-node-id { font-size:14px; }
.stats-structure-reader-graph-modal-graph .stats-structure-example-node-tag { font-size:11px; }
.stats-structure-reader-graph-modal-graph .stats-structure-example-edge-label { font-size:11px; }
.stats-structure-reader-graph-modal-foot {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 16px;
  border-top:1px solid color-mix(in srgb,var(--stats-card-border,#dfe6ee) 78%,transparent);
  color:var(--stats-muted,#66758a);
  font-size:.63rem;
}
@media (max-width: 900px) {
  .stats-structure-reader-mini-graph { min-height:280px; }
  .stats-structure-reader-mini-graph .stats-structure-example-svg,
  .stats-structure-reader-mini-graph .stats-structure-example-svg.is-dense { height:280px; min-height:280px; max-height:280px; }
  .stats-structure-reader-graph-modal { padding:14px; }
  .stats-structure-reader-graph-modal-card { width:96vw; height:88vh; }
}
@media (max-width: 620px) {
  .stats-structure-reader-facts > div { grid-template-columns:76px minmax(0,1fr); }
  .stats-structure-reader-graph-modal-foot { align-items:flex-start; flex-direction:column; }
  .stats-structure-reader-graph-modal-graph { padding:10px; }
}

/* =========================================================
   General Tags 2.0C — Projection UX + taxonomy statistics
   ========================================================= */
.stats-taxonomy-v2-card {
  margin: 14px 0 18px;
  padding: 20px;
  border: 1px solid var(--stats-border, #dfe5ee);
  border-radius: 18px;
  background: color-mix(in oklab, var(--stats-card-bg, #fff) 96%, transparent);
  box-shadow: 0 8px 24px rgba(15,23,42,.045);
}

.stats-taxonomy-v2-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 16px;
}

.stats-taxonomy-v2-head h2 {
  margin: 3px 0 5px;
  font-size: 1.18rem;
  color: var(--stats-text, #172033);
}

.stats-taxonomy-v2-head p {
  margin: 0;
  max-width: 780px;
  color: var(--stats-muted, #6f7b8e);
  line-height: 1.45;
}

.stats-taxonomy-coverage-ring {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: 92px;
  min-height: 70px;
  padding: 9px 15px;
  border: 1px solid #d9ddf7;
  border-radius: 15px;
  background: #fafaff;
  color: #5759ba;
}

.stats-taxonomy-coverage-ring strong {
  font-size: 1.22rem;
  line-height: 1.05;
}

.stats-taxonomy-coverage-ring span {
  margin-top: 3px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #8087a3;
}

.stats-taxonomy-v2-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}

.stats-taxonomy-v2-kpi {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid #e1e6ef;
  border-radius: 13px;
  background: #fbfcfe;
  color: #46546a;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.stats-taxonomy-v2-kpi:hover,
.stats-taxonomy-v2-kpi.is-active {
  border-color: #aaaaf0;
  background: #f8f8ff;
  box-shadow: 0 0 0 2px rgba(104,106,220,.08);
}

.stats-taxonomy-v2-kpi.is-warning { background: #fffaf1; border-color: #eeddbb; }
.stats-taxonomy-v2-kpi.is-pending { background: #faf9ff; border-color: #ddd9f3; }

.stats-taxonomy-v2-kpi > span {
  font-size: .76rem;
  font-weight: 750;
}

.stats-taxonomy-v2-kpi strong {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  font-size: 1.45rem;
  color: #172033;
}

.stats-taxonomy-v2-kpi small {
  font-size: .67rem;
  color: #8a95a6;
}

.stats-taxonomy-mechanisms {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f9fc;
}

.stats-taxonomy-mechanisms__label {
  margin-right: 4px;
  font-size: .72rem;
  font-weight: 800;
  color: #627087;
}

.stats-taxonomy-mechanism {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid #e1e6ee;
  border-radius: 999px;
  background: #fff;
  font-size: .72rem;
  color: #5b6678;
}

.stats-taxonomy-mechanism strong { color: #3538a0; }

.stats-taxonomy-legacy-note {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #e7ddca;
  border-radius: 11px;
  background: #fffaf2;
  color: #7a6544;
  font-size: .74rem;
  line-height: 1.4;
}

.stats-taxonomy-v2-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.stats-segmented--compact {
  flex-wrap: wrap;
}

.stats-segmented--compact button {
  padding: 6px 9px;
  font-size: .7rem;
}

.stats-taxonomy-v2-result-count {
  white-space: nowrap;
  color: #7b8798;
  font-size: .72rem;
  font-weight: 700;
}

.stats-taxonomy-v2-table-wrap {
  margin-top: 10px;
  overflow: auto;
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  background: #fff;
}

.stats-taxonomy-v2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .77rem;
}

.stats-taxonomy-v2-table th,
.stats-taxonomy-v2-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  vertical-align: middle;
}

.stats-taxonomy-v2-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafc;
  color: #617087;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .035em;
}

.stats-taxonomy-v2-table tbody tr:last-child td { border-bottom: 0; }
.stats-taxonomy-v2-table tbody tr:hover td { background: #fbfcff; }

.stats-taxonomy-v2-table td:first-child strong {
  display: block;
  color: #243149;
}

.stats-taxonomy-v2-table td:first-child small {
  display: block;
  margin-top: 2px;
  color: #8a95a6;
  font-size: .66rem;
}

.stats-taxonomy-target {
  font-weight: 720;
  color: #3438a1;
}

.stats-taxonomy-empty { color: #a0a8b5; }

.stats-taxonomy-status,
.stats-taxonomy-type {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f4f8;
  color: #5e697b;
  font-size: .68rem;
  font-weight: 750;
}

.stats-taxonomy-status.is-mapped { background: #eef0ff; color: #4e50ae; }
.stats-taxonomy-status.is-identity { background: #edf8f4; color: #3d7868; }
.stats-taxonomy-status.is-legacy_identity { background: #fff6e8; color: #8b6421; }
.stats-taxonomy-status.is-unassigned { background: #fff1e6; color: #985820; }
.stats-taxonomy-type.is-pending { background: #f7f3ff; color: #7460a5; }

.stats-taxonomy-v2-empty {
  padding: 20px !important;
  text-align: center !important;
  color: #8a95a6;
}

.stats-taxonomy-expand {
  display: block;
  margin: 10px auto 0;
  padding: 7px 12px;
  border: 1px solid #dce2eb;
  border-radius: 999px;
  background: #fff;
  color: #58667a;
  font-size: .72rem;
  font-weight: 750;
  cursor: pointer;
}
.stats-taxonomy-expand:hover { background: #f7f9fc; }

@media (max-width: 1100px) {
  .stats-taxonomy-v2-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .stats-taxonomy-v2-head { flex-direction: column; }
  .stats-taxonomy-v2-kpis { grid-template-columns: 1fr; }
  .stats-taxonomy-v2-tools { align-items: flex-start; flex-direction: column; }
}


/* =========================================================
   Global Header 1.0D — unified module-tab geometry
   Keep the Statistics page header tab exactly in the same visual
   family as the module buttons seen in the main annotation header:
   same height, same horizontal rhythm and the same soft rectangle.
   ========================================================= */
#toolbar .tab-bar .tabs {
  gap: 12px;
}

#toolbar .tab-bar .tab-button,
#toolbar .tab-bar .tab-button.active,
#toolbar .tab-bar .tab-button[aria-current="page"] {
  box-sizing: border-box;
  min-height: 38px;
  padding: 0 13px !important;
  gap: 7px;
  font-size: 0.92rem;
  line-height: 1 !important;
  border-radius: 13px !important;
}

/* Macro Explorer 19 — entry point from Macrostructure statistics */
.stats-macro-explorer-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  text-decoration: none;
  white-space: nowrap;
}
