/* Shared UI polish layer. Loads right after ki4med.css on every page that extends base.html
   (staff and public), before the staff and page stylesheets, so page CSS can still refine it.
   Rules that must beat brand-final.css or the legacy !important floors live in brand-final.css.
   Text stays >= 14px (12-13px only for uppercase labels); motion uses the shared tokens. */

/* ---- Disclosure: one <details> look for optional sections. --------------------------------
   Never apply to details that draw their own chevron (.tk-comments, .org-add, .org-form-more, .drive-menu). */
details.disclosure > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  list-style: none;
  border-radius: 8px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color var(--m-fast) var(--ease-out);
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::marker { content: ""; }
details.disclosure > summary:hover { background: rgba(53,35,54,.04); }
details.disclosure > summary:focus-visible { outline: 3px solid #bd795f !important; outline-offset: 2px !important; }
details.disclosure > summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 6px 4px 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--m-fast) var(--ease-out);
}
details.disclosure[open] > summary::after { transform: translateY(3px) rotate(225deg); }
details.disclosure--no-chevron > summary::after { content: none; }
details.disclosure--boxed {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--paper);
}
details.disclosure--boxed > summary { padding: 14px 16px; }
.disclosure-body { padding: 0 16px 16px; }
details.disclosure:not([open]) > summary .disclosure-when-open,
details.disclosure[open] > summary .disclosure-when-closed { display: none; }
/* Hash deep links (app.js opens the targeted <details>) keep a little air above the target. */
details[id] { scroll-margin-top: 16px; }

/* ---- Status pills: global states (analysis states mirror customer-page.css). ------------- */
.status-pill { white-space: nowrap; }
.status-ready { background: #edf1e9; color: #506342; }
.status-pending { background: #f5eedf; color: #795a2a; }
/* Widerrufen/Abgelaufen/Abgesagt/Abgelehnt: the legacy #85807b reached only 3.3:1; this is 5.3:1 at 14px. */
.status-offline { color: #675e65; }
.status-pill.status-invited{background:#f0ece5;color:#675e65}
.status-pill.status-in_progress{background:#fbeadd;color:#8a4a2c}
.status-pill.status-submitted{background:#fdeee6;color:#a64b32;font-weight:700}
.status-pill.status-reviewed{background:#e7eee7;color:#4a6450}
.status-pill.status-completed{background:#e7eee7;color:#3f5a46}

/* ---- Buttons and action clusters. --------------------------------------------------------- */
/* Outline destructive action; always paired with data-confirm. The :is() variant outranks page-level .button colours. */
.button.button-danger-quiet, :is(a, button).button.button-danger-quiet {
  background: transparent;
  color: #963d2e;
  border: 1px solid #e3c4bb;
}
.button.button-danger-quiet:hover:not(:disabled), :is(a, button).button.button-danger-quiet:hover:not(:disabled) { background: #f7e9e5; color: #963d2e; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.action-row--end { justify-content: flex-end; }
.form-actions { flex-wrap: wrap; gap: 12px; }
.form-actions > .required-note { margin-right: auto; }

/* ---- Key/value facts. ---------------------------------------------------------------------- */
dl.facts-list { margin: 0; }
dl.facts-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 34%) minmax(0, 1fr);
  gap: 4px 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
dl.facts-list dt { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
dl.facts-list dd { min-width: 0; margin: 0; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }

/* ---- Segmented filter (same look as the task filter). ------------------------------------- */
.filter-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f1ea;
}
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  color: #5f5560;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--m-fast) var(--ease-out), color var(--m-fast) var(--ease-out);
}
.filter-tab:hover { background: rgba(255,255,255,.7); color: var(--aubergine); }
.filter-tab[aria-current="page"], .filter-tab.is-active {
  background: var(--paper);
  color: var(--aubergine);
  box-shadow: 0 1px 2px rgba(53,35,54,.08), 0 2px 8px rgba(53,35,54,.06);
}
.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ebe3d8;
  color: #675e65;
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.filter-tab[aria-current="page"] .filter-count, .filter-tab.is-active .filter-count { background: #f6e3da; color: #96432d; }

/* ---- Section navigation of the "Angebote" area (_offers-section-nav.html). ------------------ */
.section-tabs {
  display: flex;
  gap: 4px;
  max-width: 100%;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: -1px;
  padding: 0 14px;
  border-bottom: 3px solid transparent;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--m-fast) var(--ease-out), border-color var(--m-fast) var(--ease-out);
}
/* nav.… keeps the colours on pages that colour every link (.bd-page a). */
nav.section-tabs a.section-tab { color: var(--brand-aubergine-light, #765e78); }
nav.section-tabs a.section-tab:hover { color: var(--brand-aubergine-dark, #4a354b); border-bottom-color: var(--brand-line, #e6ded5); }
nav.section-tabs a.section-tab[aria-current="page"] {
  color: var(--brand-copper, #a64b32);
  border-bottom-color: var(--brand-copper, #a64b32);
  font-weight: 750;
}
.section-tab:focus-visible { outline: 2px solid var(--brand-copper, #a64b32); outline-offset: -2px; border-radius: 6px 6px 0 0; }
@media (max-width: 520px) {
  /* All three tabs stay readable on a phone: no cut-off label, no sideways scrolling. */
  .section-tabs { gap: 0; }
  .section-tab { flex: 1 1 auto; justify-content: center; padding: 0 6px; font-size: 14px; }
}

/* ---- Legibility lifts for legacy 7-10px text. --------------------------------------------- */
.count-chip {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: #7a5a48;
  font-size: 14px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 15px;
}
.form-error { font-size: 14px; line-height: 1.55; }
.required-note, .settings-lead, .invite-result-copy > p, .copy-feedback,
.systems-intro-banner p, .export-form strong { font-size: 15px; }
.required-note, .settings-lead, .systems-intro-banner p, .revoke-proposal span { color: var(--muted); }
.settings-lead { margin: 0 0 14px; line-height: 1.6; }
.invite-result-copy > p { color: #4e5e4b; }
.copy-row code { font-size: 14px; }
.copy-row .button { min-height: 44px; }

/* ---- Tables: cells wrap, headers/pills/arrows stay on one line. --------------------------- */
.data-table td { white-space: normal; }
.data-table tbody td { font-size: 15px; }
.data-table .row-title { overflow-wrap: anywhere; }
.data-table th, .data-table .status-pill, .data-table .row-arrow { white-space: nowrap; }

/* ---- Empty states: h2 and h3 read the same. ----------------------------------------------- */
.empty-state h2 { margin: 0 0 8px; color: var(--aubergine); font-size: 1.25rem; font-weight: 600; line-height: 1.1; }

/* ---- Native checkboxes/radios never inherit the text-input box. --------------------------- */
input:is([type=checkbox], [type=radio]) { min-height: 0 !important; padding: 0 !important; flex: none; }

/* ---- Offers: source panel, revision history, preview labels (templates unchanged). -------- */
.offer-source-panel, .offer-revisions { margin-top: 16px; padding: 22px 24px; }
.revision-list { display: grid; margin-top: 6px; }
details.revision-item { border-top: 1px solid var(--line); }
details.revision-item > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 6px;
  list-style: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color var(--m-fast) var(--ease-out);
}
details.revision-item > summary::-webkit-details-marker { display: none; }
details.revision-item > summary::marker { content: ""; }
details.revision-item > summary:hover { background: rgba(53,35,54,.04); }
details.revision-item > summary:focus-visible { outline: 3px solid #bd795f !important; outline-offset: 2px !important; }
details.revision-item > summary > span:first-child { display: grid; flex: 1; gap: 2px; min-width: 0; }
details.revision-item > summary strong { color: var(--aubergine); font-size: 16px; }
details.revision-item > summary small { color: var(--muted); overflow-wrap: anywhere; }
details.revision-item > summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 6px 4px 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--m-fast) var(--ease-out);
}
details.revision-item[open] > summary::after { transform: translateY(3px) rotate(225deg); }
.revision-snapshot { padding: 4px 0 16px; }
.revision-snapshot h3 { margin: 6px 0 6px; font-size: 1.05rem; }
.revision-snapshot p { margin: 0 0 10px; overflow-wrap: anywhere; }
.revision-snapshot > div > span { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.revision-snapshot .proposal-facts { margin-top: 12px; }
.revoke-proposal span { font-size: 14px; }
.proposal-label, .proposal-number, .proposal-confidential { font-size: 12px; }
.proposal-label, .proposal-confidential { color: var(--muted); }
.proposal-number { color: #7a5a48; }
.proposal-facts strong { font-size: 16px; }

@media (max-width: 600px) {
  dl.facts-list > div { grid-template-columns: minmax(0, 1fr); }
  .copy-row { flex-direction: column; align-items: stretch; }
  .offer-source-panel, .offer-revisions { padding: 16px; }
}
@media (pointer: coarse) {
  .filter-tab { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  details.disclosure > summary, details.disclosure > summary::after,
  details.revision-item > summary, details.revision-item > summary::after, .filter-tab { transition: none; }
}

/* ---- Long names: intro and panel headings wrap instead of widening the page. ---------------
   German compounds ("Wirtschaftsprüfungsgesellschaft") have no break point: hyphenate (html lang="de"),
   and break anywhere as the fallback. Grid/flex children need min-width:0 to be allowed to shrink. */
.nowrap { white-space: nowrap; }
.page-intro > div, .section-heading > div { min-width: 0; }
.page-intro h1, .page-intro .eyebrow, .page-intro .lead, .panel h2, .back-link { overflow-wrap: anywhere; }
.page-intro h1, .panel h2 { hyphens: auto; hyphenate-limit-chars: 14 6 6; }
@media (max-width: 600px) {
  .page-intro { grid-template-columns: minmax(0, 1fr); }
}
/* One padding for the panels of the offer flow: 24px, 18px on a phone. */
.offer-source-panel, .offer-revisions { padding: 24px; }
@media (max-width: 640px) {
  .offer-source-panel, .offer-revisions { padding: 18px; }
}
/* A very long title (company names of 60+ characters) gets a calmer size: 3 to 4 lines instead of 6 to 7. */
.page-intro h1.title-long { font-size: clamp(1.5rem, 2.3vw, 2.125rem); line-height: 1.14; letter-spacing: -.015em; }
@media (max-width: 600px) {
  .page-intro h1.title-long { font-size: 1.5rem; line-height: 1.18; }
}
@media (max-width: 600px) {
  /* The state of a page is a pill, not a bar across the screen. */
  .page-intro > .status-pill { justify-self: start; }
}
