/* Detail area: insights filter toolbars, charts chrome, search-expand detail (split from detail.css). */

/* P16 — insights filter toolbars: one row on desktop; enhanced selects stay bounded. */
.erpel-insights .erpel-page-header__actions.erpel-insights-filters {
  align-items: center;
  flex-wrap: nowrap;
}

@media screen and (max-width: 768px) {
  .erpel-insights .erpel-page-header__actions.erpel-insights-filters {
    flex-wrap: wrap;
  }
}

.erpel-insights-filters .erpel-insights-filter-select {
  flex: 0 0 auto;
}

.erpel-insights-filters
  .erpel-insights-filter-select
  > .erpel-searchable-select.is-enhanced {
  width: 100%;
}

.erpel-insights-filters .erpel-insights-filter-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.erpel-insights-filters .erpel-insights-filter-field {
  flex: 0 0 auto;
}

.erpel-insights-filters .erpel-insights-filter-select--hygiene-check {
  max-width: 14rem;
  min-width: 11rem;
}

.erpel-insights-filters .erpel-insights-filter-select--hygiene-type {
  max-width: 12rem;
  min-width: 9rem;
}

.erpel-insights-filters .erpel-insights-filter-select--days,
.erpel-insights-filters .erpel-insights-filter-select--top-n {
  max-width: 8rem;
  min-width: 6.5rem;
}

.erpel-insights-chart-period {
  flex: 0 0 auto;
  gap: 0.75rem;
}

.erpel-insights-chart-period .erpel-insights-filter-select--days {
  max-width: 5.75rem;
  min-width: 5.75rem;
  width: 5.75rem;
}

.erpel-insights-filters .erpel-insights-filter-field--month {
  max-width: 11rem;
}

.erpel-insights-stock-filters .erpel-insights-filter-select--mode {
  max-width: 11.5rem;
  min-width: 9.5rem;
}

.erpel-insights-stock-filters .erpel-insights-filter-select--granularity {
  max-width: 7.5rem;
  min-width: 6.5rem;
}

.erpel-insights-stock-filters .erpel-insights-stock-dead-days {
  flex: 0 0 auto;
  max-width: 5rem;
  width: 5rem;
}

.erpel-insights-filters .erpel-insights-filter-apply.button.is-small {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  height: 2.25em;
  justify-content: center;
  min-height: 2.25em;
  padding: 0;
  width: 2.25em;
}

.erpel-insights-filters .erpel-insights-filter-apply .icon {
  height: 1.1em;
  width: 1.1em;
}

.erpel-insights-provider-cell,
.erpel-insights-provider-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  vertical-align: middle;
}

.erpel-insights-provider-cell {
  display: flex;
}

.erpel-insights-provider-cell .erpel-sourcing-provider-logo,
.erpel-insights-provider-tag .erpel-sourcing-provider-logo {
  flex-shrink: 0;
  margin: 0;
}

.erpel-insights-quota-cell {
  min-width: 10rem;
  max-width: 14rem;
  vertical-align: middle;
}

.erpel-quota-lollipop {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--erpel-chart-4);
}

.erpel-quota-lollipop--warning {
  color: var(--erpel-chart-6);
}

.erpel-quota-lollipop--blocked {
  color: var(--erpel-brand);
}

.erpel-quota-lollipop__track {
  position: relative;
  flex: 1 1 auto;
  height: 0.65rem;
  min-width: 6rem;
}

.erpel-quota-lollipop__warn-mark {
  background: color-mix(in srgb, var(--erpel-chart-6) 40%, transparent);
  bottom: 0;
  left: 80%;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 1px;
}

.erpel-quota-lollipop__stem {
  background: currentColor;
  bottom: 3px;
  height: 2px;
  left: 0;
  position: absolute;
  width: calc(var(--quota-pct, 0) * 1%);
}

.erpel-quota-lollipop__head {
  background: currentColor;
  border-radius: 50%;
  bottom: 0;
  height: 7px;
  left: calc(var(--quota-pct, 0) * 1%);
  margin-left: -3.5px;
  position: absolute;
  width: 7px;
}

.erpel-quota-lollipop__pct {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  min-width: 2.75rem;
  text-align: right;
  white-space: nowrap;
}

.erpel-quota-lollipop__period {
  flex-shrink: 0;
  font-size: 0.75rem;
  white-space: nowrap;
}

.erpel-insights .erpel-insights-chart-block {
  margin-bottom: 0;
}

.erpel-bom-charts__grid {
  display: grid;
  gap: var(--erpel-space-3, 0.75rem);
  grid-template-columns: minmax(18rem, 20rem) minmax(0, 1fr);
  align-items: start;
}

.erpel-bom-charts__grid.erpel-bom-charts__grid--pair {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.erpel-bom-charts__grid.erpel-bom-charts__grid--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

@media screen and (max-width: 900px) {
  .erpel-bom-charts__grid.erpel-bom-charts__grid--triple {
    grid-template-columns: 1fr;
  }
}

.erpel-bom-line--off {
  color: var(--erpel-text-muted, #7a7a7a);
  text-decoration: line-through;
}

.erpel-bom-line--off a,
.erpel-bom-line--off .button {
  text-decoration: none;
}

.erpel-bom-charts__sunburst,
.erpel-bom-charts__method,
.erpel-bom-charts__rank {
  min-width: 0;
}

.erpel-bom-charts__sunburst [data-erpel-chart] {
  min-height: 20rem;
}

.erpel-bom-charts__rank {
  height: 20rem;
  max-height: 20rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.erpel-bom-charts__grid--triple .erpel-bom-charts__rank .erpel-bom-type-rank {
  flex: 1 1 auto;
}

/* Sunburst leaf click → subtle row band (no per-cell frames). */
.erpel-bom-table tbody tr.erpel-bom-row-flash > td,
.erpel-detail-table.erpel-bom-table tbody tr.erpel-bom-row-flash > td,
.part-detail-embed .erpel-bom-table tbody tr.erpel-bom-row-flash > td,
.erpel-detail-row .erpel-bom-table tbody tr.erpel-bom-row-flash > td {
  background-color: color-mix(in srgb, var(--erpel-warning-bg) 55%, var(--erpel-surface)) !important;
  box-shadow: none;
  transition: background-color 0.35s ease;
}

.erpel-chart-wrap {
  position: relative;
  margin-bottom: 0;
}

.erpel-chart-wrap > .erpel-chart {
  margin-bottom: 0;
}

.erpel-sunburst-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 7rem;
  transform: translate(-50%, -50%);
  pointer-events: none;
  text-align: center;
}

.erpel-sunburst-center__value {
  color: var(--erpel-text, #363636);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

.erpel-sunburst-center__label {
  color: var(--erpel-text-muted, #7a7a7a);
  font-size: 0.6875rem;
  line-height: 1.3;
}

.erpel-bom-type-rank {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
  font-size: 0.8125rem;
}

.erpel-bom-type-rank__head,
.erpel-bom-type-rank__row {
  /* Natural height — do not let the flex column squash rows (that hides overflow). */
  flex: 0 0 auto;
}

.erpel-bom-type-rank__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(7.5rem, 9.5rem);
  gap: 0.375rem;
  padding: 0 0.25rem 0.125rem;
  color: var(--erpel-text-muted, #7a7a7a);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.erpel-bom-type-rank__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(7.5rem, 9.5rem);
  gap: 0.375rem;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0.125rem 0.25rem;
  border: none;
  border-radius: var(--erpel-radius, 4px);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  line-height: 1.25;
}

/* display:grid on the row beats the UA [hidden] rule, so folded tail rows stay visible. */
.erpel-bom-type-rank [hidden] {
  display: none !important;
}

.erpel-bom-type-rank__row:hover,
.erpel-bom-type-rank__row:focus-visible {
  background: var(--erpel-surface-muted, #f5f5f5);
  outline: none;
}

.erpel-bom-type-rank__row--reset {
  font-weight: 600;
  margin-bottom: 0;
}

.erpel-bom-type-rank__row--other {
  cursor: default;
  color: var(--erpel-text-muted, #7a7a7a);
}

.erpel-bom-type-rank__row--other:hover,
.erpel-bom-type-rank__row--other:focus-visible {
  background: transparent;
}

.erpel-bom-type-rank__col--value {
  white-space: nowrap;
  text-align: right;
}

.erpel-bom-type-rank__col--share {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
}

.erpel-bom-type-rank__pct {
  flex: 0 0 auto;
  font-size: 0.6875rem;
  color: var(--erpel-text-muted, #7a7a7a);
  text-align: right;
  white-space: nowrap;
  min-width: 2.75rem;
}

.erpel-bom-type-rank__bar {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  height: 0.1875rem;
  border-radius: 999px;
  background: var(--erpel-border-subtle, #ededed);
  overflow: hidden;
  position: relative;
}

.erpel-bom-type-rank__bar::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: min(100%, calc(var(--erpel-bom-pct, 0) * 1%));
  background: var(--erpel-accent, #3273dc);
  border-radius: inherit;
}

@media screen and (max-width: 768px) {
  .erpel-bom-charts__grid {
    grid-template-columns: 1fr;
  }
}

.erpel-insights .erpel-insights-chart-heading {
  min-height: 0;
  line-height: 1.25;
}

/* Graph zoom group (components/graph_zoom.html) stays on one line next to long headings. */
.erpel-insights .buttons[data-erpel-graph-controls] {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.erpel-insights .columns > .column {
  display: flex;
  flex-direction: column;
}

.erpel-insights .erpel-insights-chart-block {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
}

/* Subtitles wrap fully (never clipped) and reserve two lines so paired cards stay aligned. */
.erpel-insights .erpel-insights-chart-subtitle {
  flex: 0 0 auto;
  min-height: 3em;
  overflow: visible;
  white-space: normal;
}

.erpel-insights .erpel-insights-chart-block > .erpel-chart-wrap {
  margin-top: auto;
  width: 100%;
}

.erpel-insights .erpel-insights-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.erpel-insights .erpel-insights-breadcrumb-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--erpel-brand, #7f3030);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.erpel-insights .erpel-insights-breadcrumb-link:hover {
  text-decoration: underline;
}

.erpel-insights .erpel-insights-breadcrumb-sep {
  color: var(--erpel-text-muted, #7a7a7a);
  font-weight: 400;
}

.erpel-insights .erpel-insights-breadcrumb-current {
  color: inherit;
}

.erpel-insights .erpel-chart-wrap {
  margin-bottom: 0;
}

/* Height comes from the erpel_chart(height=…) macro argument; 20rem only as fallback. */
.erpel-insights .erpel-chart {
  min-height: var(--erpel-chart-min-height, 20rem);
}

/* Abhängigkeiten 32rem quadratisch; Wachstum nimmt die restliche Breite. */
.erpel-db-pair {
  display: flex;
  align-items: stretch;
  gap: 1.5rem;
}

.erpel-db-pair__graph {
  flex: 0 0 32rem;
  width: 32rem;
  max-width: 100%;
}

.erpel-db-pair__growth {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.erpel-db-pair__growth .erpel-insights-chart-block {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
}

.erpel-db-pair__growth .erpel-chart-wrap {
  display: flex;
  width: 100%;
  margin-top: auto;
}

.erpel-insights #chart-db-graph.erpel-chart {
  width: 32rem;
  max-width: 100%;
  height: 32rem;
  min-height: 32rem;
  padding: 0;
}

.erpel-insights #chart-db-growth.erpel-chart {
  width: 100%;
  height: 32rem;
  min-height: 32rem;
}

@media screen and (max-width: 1023px) {
  .erpel-db-pair {
    flex-direction: column;
  }

  .erpel-db-pair__graph,
  .erpel-insights #chart-db-graph.erpel-chart {
    flex-basis: auto;
    width: 100%;
  }
}

.erpel-insights .erpel-chart--loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.erpel-insights .erpel-chart-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
}

.erpel-insights .erpel-skeleton-line {
  border-radius: var(--erpel-radius, 4px);
  background: linear-gradient(
    90deg,
    var(--erpel-surface-subtle, #f7f7f7) 0%,
    var(--erpel-border-subtle, #ededed) 50%,
    var(--erpel-surface-subtle, #f7f7f7) 100%
  );
  background-size: 200% 100%;
  animation: erpel-skeleton-shimmer 1.2s ease-in-out infinite;
  color: transparent;
  user-select: none;
}

.erpel-insights .erpel-skeleton-line--short {
  width: 5rem;
  height: 0.65rem;
}

.erpel-insights .erpel-skeleton-line--value {
  width: 3rem;
  height: 1.25rem;
  margin-top: 0.15rem;
}

.erpel-insights-teaser-grid {
  margin-top: 0.25rem;
}

.erpel-insights-teaser-grid > .column {
  display: flex;
  flex-direction: column;
}

.erpel-insights-teaser-slot {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.erpel-insights-teaser {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  padding: 0.85rem 1rem;
}

.erpel-insights-teaser__link {
  color: var(--erpel-text, #363636);
}

.erpel-insights-teaser__link:hover {
  color: var(--erpel-brand, #7f3030);
}

.erpel-insights-teaser__chart {
  flex: 0 0 auto;
  height: 7.5rem;
}

.erpel-insights-teaser__chart .erpel-chart-wrap {
  height: 100%;
  margin-bottom: 0;
}

.erpel-insights-teaser__chart .erpel-chart,
.erpel-insights-teaser__chart .erpel-chart--empty,
.erpel-insights-teaser__chart .erpel-chart--loading {
  box-sizing: border-box;
  height: 7.5rem;
  min-height: 7.5rem;
  max-height: 7.5rem;
}

@keyframes erpel-skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* Outer chrome only — tile gaps are controlled in charts.js. */
.erpel-insights .box.erpel-chart {
  padding: 0.35rem;
  overflow: hidden;
}

/* Overview teasers: flush line/area to the box; tiny inset for donuts/treemaps. */
.erpel-insights-teaser__chart .box.erpel-chart {
  padding: 0;
}

.erpel-insights-teaser__chart .erpel-chart[data-erpel-chart-type='donut'],
.erpel-insights-teaser__chart .erpel-chart[data-erpel-chart-type='pie'],
.erpel-insights-teaser__chart .erpel-chart[data-erpel-chart-type='treemap'] {
  padding: 0.2rem;
}

.erpel-insights .erpel-packaging-view-toggle .button.is-active,
.erpel-insights .erpel-mfr-rest-toggle .button.is-active {
  background-color: var(--erpel-surface-muted, #f5f5f5);
  border-color: var(--erpel-border, #dbdbdb);
  color: var(--erpel-text, #363636);
}

.erpel-chart--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.erpel-chart-empty-message {
  text-align: center;
}

.part-detail-embed .erpel-detail-panel .erpel-detail-table > thead > tr:first-child > th,
.part-detail-embed .erpel-detail-panel .erpel-detail-table > thead > tr.erpel-filter-row > th {
  box-shadow: none;
  position: static;
  top: auto;
}

/* Nested in search expand: same column model as the detail page.
   Headers size columns (max-width:none); body cells keep max-width:0 for
   ellipsis. Horizontal scroll when the expand panel is narrower than the table. */
.part-detail-embed .erpel-detail-table {
  max-width: 100%;
  width: 100%;
}

.part-detail-embed .erpel-detail-panel .table-container {
  max-width: 100%;
  overflow-x: auto;
}

.part-detail-embed .erpel-detail-table > thead > tr > th {
  max-width: none;
}

.part-detail-embed .erpel-detail-table > tbody > tr > td {
  max-width: 0;
}

.part-detail-embed .erpel-detail-table .erpel-column-filter {
  min-width: 0;
}

.erpel-detail-tab-select {
  display: none;
}

@media (max-width: 768px) {
  .erpel-detail-stack,
  .erpel-detail-frame:not(.erpel-detail-frame--compact) {
    width: 100%;
    max-width: 100%;
  }

  /* Rail hidden: drop reserved rail column so meta starts at the left again. */
  .erpel-detail-toolbar:has(> .erpel-detail-toolbar-end) {
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 0.75rem;
  }

  /* Chip on its own row so Recherche stays on screen when the rail is hidden. */
  .erpel-detail-toolbar:has(> .erpel-detail-toolbar-end):has(> .erpel-edit-mode-badge) {
    grid-template-columns: auto minmax(0, 1fr) auto;
    row-gap: 0.35rem;
  }

  .erpel-detail-toolbar:has(> .erpel-edit-mode-badge) > .erpel-detail-toolbar-meta {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .erpel-detail-toolbar:has(> .erpel-edit-mode-badge) > .erpel-edit-mode-badge {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .erpel-detail-toolbar:has(> .erpel-edit-mode-badge) > .erpel-detail-toolbar-end {
    grid-column: 3;
    grid-row: 1;
  }

  .erpel-detail-toolbar:has(> .erpel-detail-toolbar-end)
    > .erpel-detail-title-row {
    padding-left: 0;
  }

  .erpel-detail-toolbar:has(> .erpel-detail-toolbar-end)
    > .erpel-detail-title-row:has(> .erpel-detail-title-id) {
    width: calc(15ch + 3.45rem);
  }

  .erpel-detail-frame:not(.erpel-detail-frame--compact) .erpel-detail-body {
    display: block;
  }

  .erpel-detail-frame:not(.erpel-detail-frame--compact) .erpel-rail {
    display: none;
  }

  .erpel-detail-frame:not(.erpel-detail-frame--compact) .erpel-detail-tab-select {
    display: flex;
    margin-bottom: 0.75rem;
    max-width: 100%;
  }

  .erpel-detail-tab-select select,
  .erpel-detail-tab-select .erpel-searchable-select.is-enhanced .erpel-searchable-select__input {
    font-weight: 600;
  }

  .erpel-detail-tab-select .erpel-searchable-select.is-enhanced {
    width: 100%;
  }
}

.erpel-detail-panel {
  background-color: transparent;
  border: none;
  box-shadow: none;
  margin-left: 0;
  margin-right: 0;
  max-width: none;
  padding: 0.75rem 0 1rem;
  width: 100%;
}

.erpel-detail-frame .erpel-detail-panel {
  box-sizing: border-box;
  container-name: erpel-detail-panel;
  container-type: inline-size;
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
}

/*
 * Embed panels need both container names. The frame rule above has the same
 * specificity as `.part-detail-embed .erpel-detail-panel` earlier in the file
 * and would otherwise strip `erpel-embed-panel`, leaving Allgemein/Eigenschaften
 * stuck in the 1-column embed fallback inside the results expand row.
 */
.part-detail-embed .erpel-detail-panel {
  container-name: erpel-embed-panel erpel-detail-panel;
}

.part-detail-embed {
  box-sizing: border-box;
  /* Prevent detail content from contributing to ancestor/table intrinsic width. */
  contain: inline-size;
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow-x: visible;
  overflow-y: visible;
  padding: 0.75rem 1rem;
  width: 100%;
}

.part-detail-embed .erpel-detail-frame,
.part-detail-embed .erpel-detail-body,
.part-detail-embed .erpel-detail-panel,
.part-detail-embed .erpel-detail-grid {
  max-width: 100%;
  min-width: 0;
}

.erpel-detail-table {
  background-color: transparent;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
}

.erpel-detail-table td,
.erpel-detail-table th {
  border: none;
  border-bottom: 1px solid var(--erpel-black-a6);
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

/* Transparent body cells — thead uses --erpel-table-head-bg when sticky/scrolled. */
.erpel-detail-table tbody td {
  background-color: transparent;
}

.erpel-detail-panel .table-container {
  overflow: visible;
}

.erpel-detail-panel .erpel-detail-table > thead > tr > th {
  border-bottom: none;
}

.erpel-detail-panel .erpel-detail-table > thead > tr:first-child > th {
  background-color: var(--erpel-table-head-bg);
  border-bottom: 1px solid var(--erpel-black-a8);
  box-shadow: none;
  position: sticky;
  top: var(--erpel-toolbar-h, 0px);
  z-index: 4;
}

.erpel-detail-panel .erpel-detail-table > thead > tr.erpel-filter-row > th {
  background-color: var(--erpel-table-head-bg);
  border-bottom: 1px solid var(--erpel-black-a12);
  box-shadow: none;
  overflow: visible;
  position: sticky;
  top: calc(var(--erpel-toolbar-h, 0px) + var(--erpel-thead-sort-h, 2.5rem));
  z-index: 3;
}

.erpel-detail-table td a {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.erpel-detail-table tr:last-child th,
.erpel-detail-table tr:last-child td {
  border-bottom: none;
}

.erpel-detail-table .erpel-filter-row th {
  max-width: none;
  overflow: visible;
  white-space: normal;
}

.erpel-detail-table .erpel-th-sort {
  max-width: none;
}

.erpel-table-frame {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  width: 100%;
}
