/*
 * Explorer (/unternehmen, /unternehmen/{q}) — on the design system since 2026-10-30 (DESIGN.md).
 *
 * Replaces the 26 inline <style> partials of company/profile (and the index's own block). The markup is made of the
 * ds components and the type scale (14 px data, 13 px meta, 12 px badges, 11 px labels, Satoshi for headings and big
 * figures) and sits in `.ds-scope`, so app-theme.css no longer reaches it. What stays here is the app's anatomy, all on
 * tokens: the app bar in the navigation's content box (as the Lead Builder and the Enricher), the profile's three
 * columns (rails on the page, the main column as the card), the share and owner rows, the financial statements, the
 * suggestion list the page's script builds, the document panel, and what the legacy scripts toggle by class.
 */

.xp { --xp-gutter: var(--ds-gutter); position: relative; font-size: 14px; line-height: 1.5; }
.xp *, .xp *::before, .xp *::after { box-sizing: border-box; }
/* Zero specificity, so the utilities in the markup (mt-2 …) win. */
:where(.xp) :where(h1, h2, h3, h4, p, ul, ol, dl, dd) { margin: 0; }
:where(.xp) :where(ul, ol) { padding: 0; list-style: none; }
/* Element specificity only (0,0,1, after Tailwind's preflight): links that are components (x-ds.button, x-ds.tab)
   bring their own colour in classes, which win. */
:where(.xp) a { color: rgb(var(--ds-link)); text-decoration: none; }
:where(.xp) a:where(:not([class]):hover) { text-decoration: underline; }
.xp :where(button, a, input, summary, [tabindex]):focus-visible { outline: 2px solid rgb(var(--ds-primary)); outline-offset: 2px; }

/* ---------------------------------------------------------------------- */
/* App bar: a full-width band whose content lines up with the navigation   */
/* ---------------------------------------------------------------------- */

.xp-bar {
  position: relative; z-index: 40; height: 56px;
  display: flex; align-items: center; gap: 16px;
  padding-inline: max(var(--xp-gutter), calc((100% - var(--ds-content)) / 2 + var(--xp-gutter)));
  background: rgb(var(--ds-card)); border-bottom: 1px solid var(--ds-line-soft);
}
.xp-bar__brand {
  display: flex; align-items: center; gap: 8px; flex: none; white-space: nowrap;
  font-family: var(--ds-font-display); font-size: var(--ds-text-h3); line-height: 1; font-weight: var(--ds-heading-weight);
  letter-spacing: var(--ds-heading-tracking); color: rgb(var(--ds-heading));
}
.xp a.xp-bar__brand, .xp a.xp-bar__brand:hover { color: rgb(var(--ds-heading)); text-decoration: none; }
.xp-bar__search { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; }
@media (max-width: 479px) { .xp-bar__beta { display: none; } }

/* The search field: x-ds.field's look (field fill and line, control radius, blue focus ring) around an input with a
   submit button and the suggestion list — a page-own field shell, as on /playground and in the Lead Builder, because
   no component has an autocomplete with side slots. */
.xp-search { position: relative; width: 100%; max-width: 640px; min-width: 0; }
.xp-search__box {
  height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 4px 0 12px;
  background: rgb(var(--ds-field)); border: 1px solid var(--ds-field-line); border-radius: var(--ds-radius-control);
  box-shadow: var(--ds-shadow-field);
  transition: border-color var(--ds-dur-fast) var(--ds-ease), box-shadow var(--ds-dur-fast) var(--ds-ease);
}
.xp-search__box:focus-within { border-color: rgb(var(--ds-primary)); box-shadow: 0 0 0 3px rgb(var(--ds-primary) / .1); }
.xp-search__box > svg { color: rgb(var(--ds-faint)); }
.xp-search__input {
  flex: 1 1 40px; min-width: 40px; height: 100%; border: 0; outline: 0; padding: 0; background: transparent;
  font-family: var(--ds-font-body); font-size: 14px; color: rgb(var(--ds-heading));
}
.xp-search__input::placeholder { color: rgb(var(--ds-faint)); }
.xp-search__input:disabled { cursor: wait; }
.xp-search__input:focus { box-shadow: none; }
.xp-search__go {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; cursor: pointer;
  border-radius: calc(var(--ds-radius-control) - 1px); background: rgb(var(--ds-primary)); color: rgb(var(--ds-primary-fg));
  transition: filter var(--ds-dur-fast) var(--ds-ease);
}
.xp-search__go:hover { filter: brightness(.92); }
.xp-search__go:disabled { cursor: wait; }
.xp-search.shake .xp-search__box, .xp-search__box.shake, .xp-shake.shake { animation: xp-shake .25s ease-in-out; }
@keyframes xp-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .xp-search__box.shake, .xp-shake.shake { animation: none; } }

/* Suggestions (built by the profile script): x-ds.suggestions' look, below the field, best match first. */
.xp-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50;
  max-height: min(380px, 60vh); overflow-y: auto;
  background: rgb(var(--ds-card)); border: 1px solid var(--ds-line-soft); border-radius: var(--ds-radius-control);
  box-shadow: var(--ds-shadow-pop); font-family: var(--ds-font-body);
}
.xp-suggest__item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--ds-line-soft); font-size: 14px;
  transition: background-color var(--ds-dur-fast) var(--ds-ease);
}
.xp-suggest__item:hover, .xp-suggest__item.active { background: var(--ds-primary-tint); }
.xp-suggest__item > svg { color: rgb(var(--ds-faint)); }
.xp-suggest__text { display: grid; min-width: 0; }
.xp-suggest__name { font-weight: 600; color: rgb(var(--ds-heading)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-suggest__meta { font-size: 13px; color: rgb(var(--ds-muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-suggest__hint { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; color: rgb(var(--ds-faint)); }

/* ---------------------------------------------------------------------- */
/* Body: the navigation's content box                                      */
/* ---------------------------------------------------------------------- */

.xp-body { width: 100%; max-width: var(--ds-content); margin-inline: auto; padding: 24px var(--xp-gutter) 40px; }

/* Start screen: the search card, centred. */
.xp-start { display: flex; justify-content: center; padding-top: clamp(16px, 5vw, 40px); }
.xp-start__card { width: 100%; max-width: 680px; }
.xp-kbd {
  font: 500 12px var(--ds-font-code); color: rgb(var(--ds-muted));
  border: 1px solid var(--ds-line); border-radius: var(--ds-radius-chip); padding: 1px 5px; background: rgb(var(--ds-field));
}

/* ---------------------------------------------------------------------- */
/* Profile                                                                 */
/* ---------------------------------------------------------------------- */

/* Columns: rails and the main column all sit on the page, no card (Kevin, 2026-10-30; the layout gets its own
   redesign later). One column below 1280 px and while a document is open. */
.xp-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; align-items: start; margin-top: 24px; }
.xp-grid.has-right { grid-template-columns: 280px minmax(0, 1fr) 300px; }
@media (max-width: 1279px) { .xp-grid, .xp-grid.has-right { grid-template-columns: minmax(0, 1fr); } }
.xp-rail { display: grid; gap: 24px; min-width: 0; }
.xp-main { display: grid; min-width: 0; }
.xp-main > * { padding-block: 24px; min-width: 0; }
.xp-main > :first-child { padding-top: 0; }
.xp-main > * + * { border-top: 1px solid var(--ds-line-soft); }
@media (max-width: 1279px) {
  .xp-rail + .xp-main, .xp-main + .xp-rail { margin-top: 0; }
}

/* A section's label: the 11 px eyebrow. */
.xp-label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: var(--ds-text-label); font-weight: 600; letter-spacing: var(--ds-label-tracking); text-transform: uppercase; color: rgb(var(--ds-faint)); }
.xp-label .xp-count { font-weight: 600; letter-spacing: normal; text-transform: none; }

/* Facts with an icon as their label. */
.xp-facts { display: grid; gap: 10px; }
.xp-facts li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 14px; color: rgb(var(--ds-heading)); overflow-wrap: anywhere; }
.xp-facts li > svg { margin-top: 2px; color: rgb(var(--ds-faint)); }

/* People, owners, holdings: name and figure on a line, a share track, a meta line. */
.xp-rows { display: grid; gap: 14px; }
.xp-row { min-width: 0; }
.xp-row__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.xp-row__name { min-width: 0; font-size: 14px; font-weight: 600; color: rgb(var(--ds-heading)); overflow-wrap: anywhere; }
.xp-row__aside { font-weight: 400; color: rgb(var(--ds-muted)); }
.xp-row__pct { flex: none; font-size: 14px; font-variant-numeric: tabular-nums; color: rgb(var(--ds-heading)); }
.xp-row__meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; color: rgb(var(--ds-muted)); }
.xp-row__meta > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.xp-row__meta svg { flex: none; color: rgb(var(--ds-faint)); }
.xp-row.compact .xp-row__name { font-weight: 400; }
/* The share track behind owner rows (DESIGN.md › Data in charts): the share in the data colour on its quiet track. */
.xp-track { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--ds-data-lo); overflow: hidden; }
.xp-track > span { display: block; height: 100%; border-radius: 2px; background: rgb(var(--ds-data-hi)); }

.xp-person { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; }
.xp-sub { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; font-size: var(--ds-text-label); font-weight: 600; letter-spacing: var(--ds-label-tracking); text-transform: uppercase; color: rgb(var(--ds-faint)); }
.xp-sub::after { content: ''; flex: 1; height: 1px; background: var(--ds-line-soft); }

/* UBO coverage: identified and unidentified as two categories. */
.xp-coverage { display: flex; height: 6px; gap: 2px; border-radius: 3px; overflow: hidden; background: var(--ds-line-soft); }
.xp-coverage > span:first-child { background: var(--ds-cat-1); }
.xp-coverage > span:last-child { background: var(--ds-cat-2); }
.xp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; flex: none; }
.xp-dot.is-identified { background: var(--ds-cat-1); }
.xp-dot.is-unidentified { background: var(--ds-cat-2); }

/* <details> lists ("Mehr anzeigen (12)", "Ehemalige Geschäftsführung (3)"): the summary is a quiet text button. */
.xp-more { margin-top: 12px; }
.xp-more > summary {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; list-style: none; border-radius: var(--ds-radius-control);
  font-size: 13px; font-weight: 600; color: rgb(var(--ds-link));
}
.xp-more > summary::-webkit-details-marker { display: none; }
.xp-more > summary:hover { text-decoration: underline; }
.xp-more > summary > svg { transition: transform var(--ds-dur-fast) var(--ds-ease); }
.xp-more[open] > summary > svg { transform: rotate(90deg); }
.xp-more__body { margin-top: 12px; }

/* Lists in the main column: publications, history, news, insolvency. */
.xp-list { display: grid; }
.xp-list > li, .xp-list > div { padding: 12px 0; border-bottom: 1px solid var(--ds-line-soft); min-width: 0; }
.xp-list > :first-child { padding-top: 0; }
.xp-list > :last-child { border-bottom: 0; padding-bottom: 0; }
.xp-list a.xp-item-link { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; color: inherit; }
.xp-list a.xp-item-link:hover { text-decoration: none; }
.xp-list a.xp-item-link:hover .xp-item-title { color: rgb(var(--ds-link)); }
.xp-list a.xp-item-link > svg { flex: none; margin-top: 3px; color: rgb(var(--ds-faint)); }
.xp-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: rgb(var(--ds-muted)); }
.xp-item-meta svg { color: rgb(var(--ds-faint)); }
.xp-item-title { margin-top: 2px; font-size: 14px; font-weight: 600; color: rgb(var(--ds-heading)); overflow-wrap: anywhere; transition: color var(--ds-dur-fast) var(--ds-ease); }
.xp-item-text { margin-top: 2px; font-size: 13px; line-height: 1.55; color: rgb(var(--ds-muted)); overflow-wrap: anywhere; }
.xp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.xp-chips svg { color: rgb(var(--ds-faint)); }

/* Share link: the URL in a quiet field with a copy button. */
.xp-share { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 560px; height: 32px; padding: 0 2px 0 10px;
  background: rgb(var(--ds-field)); border: 1px solid var(--ds-field-line); border-radius: var(--ds-radius-control); }
.xp-share__url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--ds-font-code); font-size: 12.5px; color: rgb(var(--ds-muted)); }
.xp-feedback { font-size: 13px; color: rgb(var(--ds-muted)); }
.xp-feedback.is-error { color: rgb(var(--ds-bad)); }
.xp-feedback.is-link { color: rgb(var(--ds-link)); }

/* KPI strip: label and year above the figure. */
.xp-kpis { display: flex; flex-wrap: wrap; gap: 16px 40px; }
.xp-kpi__value { font-family: var(--ds-font-display); font-size: 22px; line-height: var(--ds-leading-heading); font-weight: var(--ds-heading-weight); letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: rgb(var(--ds-heading)); white-space: nowrap; }
.xp-kpis--more .xp-kpi__value { font-size: 18px; }
@media (max-width: 639px) { .xp-kpis { gap: 14px 24px; } .xp-kpi__value { font-size: 18px; } }

/* Financial statements: rows with their level's indent, figures right-aligned. */
.xp .tab-content { display: none; }
.xp .tab-content.active { display: block; }
.xp .chart-view { display: none; }
.xp .chart-view.active { display: block; }
.xp-fin { display: grid; }
.xp-fin__row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0 6px calc(var(--level, 0) * 14px); border-bottom: 1px solid var(--ds-line-soft); font-size: 14px; color: rgb(var(--ds-body)); }
.xp-fin__row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.xp-fin__row > span:last-child { flex: none; font-variant-numeric: tabular-nums; text-align: right; }
.xp-fin__row.level-0 { margin-top: 12px; padding-top: 10px; font-weight: 600; color: rgb(var(--ds-heading)); border-bottom-color: var(--ds-line); }
.xp-fin__row.level-0:first-child { margin-top: 0; padding-top: 6px; }
.xp-fin__row.level-1 { color: rgb(var(--ds-heading)); }
.xp-fin__row:not(.level-0):not(.level-1) { color: rgb(var(--ds-muted)); }
.xp-chart { position: relative; height: 320px; }
.xp-chart--doc { height: 360px; }
@media (max-width: 639px) { .xp-chart { height: 260px; } }

/* Website preview: consent, loading and fallback over the frame. */
.xp-preview { position: relative; height: 380px; border: 1px solid var(--ds-line-soft); border-radius: var(--ds-radius-control); background: rgb(var(--ds-card)); overflow: hidden; }
.xp-preview__state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; font-size: 13px; color: rgb(var(--ds-muted)); }
.xp-preview__state > svg { color: rgb(var(--ds-faint)); }
.xp-preview iframe { width: 100%; height: 100%; border: 0; background: rgb(var(--ds-card)); }

/* Annual statements: the year row (its own buttons: the section is cloned into the document panel with innerHTML and
   switches by class) and the statement on a light document surface (documents are always light, DESIGN.md › 6). */
.afs-year-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.afs-year-btn {
  padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  font-family: var(--ds-font-body); font-size: 14px; font-variant-numeric: tabular-nums; color: rgb(var(--ds-muted));
  transition: background-color var(--ds-dur-fast) var(--ds-ease), color var(--ds-dur-fast) var(--ds-ease);
}
.afs-year-btn:hover { background: var(--ds-line-soft); color: rgb(var(--ds-heading)); }
.afs-year-btn.active { background: var(--ds-primary-tint); color: rgb(var(--ds-heading)); font-weight: 600; }
.statement-html-rendered {
  padding: 16px; overflow-x: auto; border: 1px solid var(--ds-line); border-radius: var(--ds-radius-card);
  background: rgb(var(--ds-card)); color: rgb(var(--ds-heading)); font-family: var(--ds-font-body); font-size: 13px; line-height: 1.6;
}
/* The register's statement HTML carries its own inline colours; the text is set to the document's ink. */
.statement-html-rendered :where(p, span, div, li, b, i, a, h1, h2, h3, h4, h5, h6, td, th) { color: rgb(var(--ds-heading)) !important; }
.statement-html-rendered :where(h1, h2) { margin: 1.8em 0 .7em; font-size: 18px; line-height: 1.3; }
.statement-html-rendered :where(h3, h4, h5, h6) { margin: 1.4em 0 .5em; font-size: 15px; line-height: 1.35; color: rgb(var(--ds-muted)) !important; }
.statement-html-rendered p { margin: .7em 0; }
.statement-html-rendered table { width: 100%; margin: 1em 0; border-collapse: collapse; }
.statement-html-rendered :where(td, th) { padding: 4px 8px; font-size: 13px; }
/* Header rows the controller marks white-on-dark (bgcolor of the register's HTML) keep white text. */
.statement-html-rendered tr[style*="color:#ffffff"] :where(td, th) { color: rgb(var(--ds-primary-fg)) !important; }

/* Withheld for this company (config/redacted_entities.php): a bar and the word. */
.explorer-redacted { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: rgb(var(--ds-muted)); white-space: nowrap; vertical-align: middle; }
.explorer-redacted::before { content: ''; display: inline-block; width: 56px; height: 9px; border-radius: 3px; background: var(--ds-line); }

/* ---------------------------------------------------------------------- */
/* Loading                                                                 */
/* ---------------------------------------------------------------------- */

.initial-loading-container { min-height: calc(100vh - 16rem); display: flex; align-items: center; justify-content: center; padding: 32px 0; }
.loading-step { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: rgb(var(--ds-faint)); opacity: .55; transition: opacity var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease); }
.loading-step.is-active { opacity: 1; color: rgb(var(--ds-heading)); }
.loading-step-dot { width: 6px; height: 6px; border-radius: 999px; background: rgb(var(--ds-faint)); }
.loading-step.is-active .loading-step-dot { background: rgb(var(--ds-primary)); }
.loading-step-sep { width: 16px; height: 1px; background: var(--ds-line); }

/* ---------------------------------------------------------------------- */
/* Document panel (split view)                                             */
/* ---------------------------------------------------------------------- */

.profile-split-view { display: flex; width: 100%; position: relative; }
.profile-split-main { flex: 1; min-width: 0; }
.profile-split-view.split-active .profile-split-main { flex: 0 0 48%; overflow-y: auto; max-height: 100vh; position: sticky; top: 0; }
.profile-split-view.split-active .xp-grid, .profile-split-view.split-active .xp-grid.has-right { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1801px) {
  .profile-split-view.split-active .xp-grid { grid-template-columns: 280px minmax(0, 1fr); }
  .profile-split-view.split-active .xp-grid.has-right { grid-template-columns: 280px minmax(0, 1fr) 300px; }
}
.profile-split-document {
  flex: 0 0 52%; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-left: 1px solid var(--ds-line-soft); background: rgb(var(--ds-card));
  animation: xp-panel-in var(--ds-dur-slow) var(--ds-ease);
}
@keyframes xp-panel-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .profile-split-document { animation: none; } }
.doc-panel-header { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--ds-line-soft); }
.doc-panel-title { font-size: 14px; font-weight: 600; color: rgb(var(--ds-heading)); }
.doc-panel-loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px; font-size: 13px; color: rgb(var(--ds-muted)); }
.doc-panel-iframe { flex: 1; width: 100%; border: 0; display: none; background: rgb(var(--ds-card)); }
.doc-panel-iframe.loaded { display: block; }
.doc-panel-html-content { flex: 1; overflow-y: auto; padding: 16px; }
@media (max-width: 1279px) {
  .profile-split-view.split-active .profile-split-main { flex: 0 0 45%; }
  .profile-split-view.split-active .profile-split-document { flex: 0 0 55%; }
}
@media (max-width: 900px) {
  .profile-split-view.split-active .profile-split-main { flex: 1; max-height: none; position: static; overflow-y: visible; }
  .profile-split-document { position: fixed; inset: 0; z-index: 130; border-left: 0; overflow: hidden; }
  body.doc-panel-open { overflow: hidden; position: fixed; width: 100%; }
}

/* A transient note the script shows when a document does not exist. */
.xp-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; max-width: calc(100vw - 32px);
  background: rgb(var(--ds-card)); border: 1px solid var(--ds-line-soft); border-radius: var(--ds-radius-control);
  box-shadow: var(--ds-shadow-pop); font-family: var(--ds-font-body); font-size: 13px; color: rgb(var(--ds-body));
  transition: opacity var(--ds-dur) var(--ds-ease);
}
.xp-toast > svg { color: rgb(var(--ds-faint)); }
