/* Fillvero – design system "Precision in Service of the Planet".
   Tokens first, then base, layout, components, page patterns. No dark mode by design. */

/* ---------- Fonts (self-hosted, OFL; no requests to third parties) ---------- */
@font-face { font-family: "DM Sans"; font-weight: 300; font-display: swap; src: url("fonts/dm-sans-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url("fonts/dm-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 500; font-display: swap; src: url("fonts/dm-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 600; font-display: swap; src: url("fonts/dm-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 700; font-display: swap; src: url("fonts/dm-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

/* ---------- Tokens ---------- */
:root {
  --color-bg: #FAFAFA;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F4F6F4;
  --color-border: #E4E9E4;
  --color-border-strong: #C8D4C8;

  --color-primary: #1A3D2B;
  --color-primary-mid: #2D6A4F;
  --color-accent: #40916C;
  --color-accent-light: #D8EDDF;

  --color-text-primary: #111B17;
  --color-text-body: #374740;
  --color-text-muted: #6B7E74;
  --color-text-inverse: #FFFFFF;

  --color-success: #2D9B60;
  --color-warning: #C88A2B;
  --color-error: #C0392B;
  --color-success-bg: #E3F4EA;
  --color-warning-bg: #FBF1E0;
  --color-highlight: #FBE38E;  /* text marker for the evidence passage in an excerpt */
  --color-error-bg: #F9E5E3;

  /* Document kinds (knowledge base): muted hues away from the traffic-light colours.
     Text on background >= 4.5:1. "document" and "filled_questionnaire" reuse
     neutral and accent-light. */
  --kind-policy-bg: #E4ECF7;       --kind-policy-fg: #1F4A80;
  --kind-report-bg: #EEE8F7;       --kind-report-fg: #53348C;
  --kind-certificate-bg: #DCF0EF;  --kind-certificate-fg: #17605B;
  --kind-initiative-bg: #F8E5EE;   --kind-initiative-fg: #8A2C56;
  --kind-kpi-bg: #F7E7DC;          --kind-kpi-fg: #8A4214;
  --kind-evidence-bg: #E3E8EE;     --kind-evidence-fg: #34465A;

  --font-display: "DM Sans", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(17, 27, 23, .06);
  --shadow-md: 0 4px 16px rgba(17, 27, 23, .08);
  --shadow-lg: 0 8px 32px rgba(17, 27, 23, .10);
  --shadow-xl: 0 16px 48px rgba(17, 27, 23, .12);

  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --sidebar-width: 240px;
  --topbar-height: 64px;
}

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

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text-body);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--color-text-primary); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 40px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 32px; font-weight: 600; line-height: 1.2; }
h3 { font-size: 24px; font-weight: 600; line-height: 1.3; }
p { margin: 0 0 16px; }
a { color: var(--color-accent); text-decoration: none; transition: color var(--transition-base); }
a:hover { color: var(--color-primary-mid); text-decoration: underline; }
small, .caption { font-size: 12px; font-weight: 500; }
.muted { color: var(--color-text-muted); }
.mono { font-family: var(--font-mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: var(--color-accent-light); }

/* ---------- App layout: sidebar 240 + topbar 64 + content ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--color-primary); color: rgba(255, 255, 255, .75);
  display: flex; flex-direction: column; padding: 24px 16px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--color-text-inverse); font: 600 18px/1.2 var(--font-display);
  padding: 0 12px 32px; text-decoration: none;
}
.brand:hover { color: var(--color-text-inverse); text-decoration: none; }
/* Logo (D-038): full wordmark in the sidebar, only the symbol where space is short */
.brand-logo { display: block; width: auto; height: 34px; }
.brand-symbol { display: none; width: 30px; height: 30px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.nav-bottom { margin-top: auto; padding-bottom: 16px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-md); border-left: 3px solid transparent;
  color: rgba(255, 255, 255, .75); font-weight: 500; font-size: 15px;
  transition: background var(--transition-base), color var(--transition-base);
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: var(--color-text-inverse); text-decoration: none; }
.nav a[aria-current="page"] {
  background: rgba(255, 255, 255, .12); color: var(--color-text-inverse);
  border-left-color: var(--color-accent);
}
.nav svg, .brand svg { flex: none; }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 12px; line-height: 1.5; }
.sidebar-foot strong { color: var(--color-text-inverse); font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
  padding: 0 64px;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--color-text-muted); min-width: 0; }
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb [aria-current] { color: var(--color-text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-meta { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--color-text-muted); white-space: nowrap; }
.content { padding: 48px 64px 96px; max-width: calc(1200px + 128px); width: 100%; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; flex-wrap: wrap; }
.page-header .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 8px; }
.page-header p { color: var(--color-text-muted); margin: 8px 0 0; max-width: 680px; }
.page-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Buttons (always pill) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 12px 28px; border-radius: var(--radius-pill);
  font: 600 15px/1 var(--font-body); cursor: pointer; white-space: nowrap;
  border: 1.5px solid transparent; text-decoration: none;
  transition: background var(--transition-base), transform var(--transition-base),
    box-shadow var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-accent); color: var(--color-text-inverse); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-mid); color: var(--color-text-inverse); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-accent-light); color: var(--color-primary); }
.btn-ghost { background: transparent; color: var(--color-text-body); }
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.btn-outline { background: transparent; color: var(--color-text-body); border-color: var(--color-border-strong); }
.btn-success { background: var(--color-success); color: var(--color-text-inverse); }
.btn-success:hover { background: #1E6B42; color: var(--color-text-inverse); }
.btn-outline:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.btn-sm { min-height: 36px; padding: 8px 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary[disabled]:hover { background: var(--color-accent); }
.btn svg { flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 32px;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card + .card, .stack > * + * { margin-top: 24px; }
.card-title { font: 600 20px/1.3 var(--font-display); color: var(--color-text-primary); margin: 0 0 8px; }
.card-lead { color: var(--color-text-muted); margin-bottom: 24px; }

/* KPI cards: 4-up row, mono value, caption label, optional progress ring */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-bottom: 48px; }
.kpi { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 28px; }
.kpi-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.kpi-value { font: 500 36px/1.1 var(--font-mono); color: var(--color-primary); margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-value .unit { font-size: 18px; color: var(--color-text-muted); margin-left: 2px; }
.kpi-note { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.ring { flex: none; width: 64px; height: 64px; transform: rotate(-90deg); }
.ring-track { stroke: var(--color-surface-alt); }
.ring-value { stroke: var(--color-accent); stroke-linecap: round; transition: stroke-dashoffset 1200ms cubic-bezier(.22, .61, .36, 1); }

/* ---------- Tags / badges ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  font: 600 12px/1.4 var(--font-body); white-space: nowrap;
  background: var(--color-accent-light); color: var(--color-primary);
}
.tag-neutral { background: var(--color-surface-alt); color: var(--color-text-body); }
.tag-success { background: var(--color-success-bg); color: #1E6B42; }
.tag-warning { background: var(--color-warning-bg); color: #8A5C14; }
.tag-error { background: var(--color-error-bg); color: #9A2B20; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-green { background: var(--color-success); }
.dot-yellow { background: var(--color-warning); }
.dot-red { background: var(--color-error); }
.lights { display: inline-flex; align-items: center; gap: 12px; font: 500 14px var(--font-mono); color: var(--color-text-body); }
.lights span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Inputs ---------- */
label, .label { display: block; font-size: 14px; font-weight: 500; color: var(--color-text-primary); margin-bottom: 8px; }
.field { margin-bottom: 24px; }
.hint { display: block; font-size: 12px; color: var(--color-text-muted); margin-top: 6px; font-weight: 400; }
input[type="text"], input[type="search"], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  font: 400 15px/1.5 var(--font-body); color: var(--color-text-primary);
  background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
select { border-radius: var(--radius-md); appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236B7E74' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(64, 145, 108, .15);
}
input[readonly], textarea[readonly], select[disabled] { background: var(--color-surface-alt); color: var(--color-text-body); cursor: default; }
/* Number field with the questionnaire's unit as a fixed suffix (D-048). */
.input-unit { display: flex; align-items: stretch; }
.input-unit input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit-label {
  display: flex; align-items: center; padding: 0 14px; white-space: nowrap;
  font: 500 14px/1 var(--font-mono); color: var(--color-text-muted); background: var(--color-surface);
  border: 1.5px solid var(--color-border); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
/* Locked (approved) answer: the unit turns grey with the field. */
.input-unit input[readonly] + .input-unit-label { background: var(--color-surface-alt); }
.is-invalid, .is-invalid:focus { border-color: var(--color-error); box-shadow: 0 0 0 3px rgba(192, 57, 43, .12); }
.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--color-text-body); cursor: pointer; }
.checkbox input { flex: none; width: 18px; height: 18px; accent-color: var(--color-accent); margin: 0; }

/* File drop zone (native input stays usable without JS) */
.dropzone {
  position: relative; display: block; border: 1.5px dashed var(--color-border-strong); border-radius: var(--radius-lg);
  background: var(--color-surface-alt); padding: 32px; text-align: left; cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--color-accent); background: var(--color-accent-light); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone-inner { display: flex; align-items: center; gap: 16px; pointer-events: none; }
.dropzone-icon { width: 48px; height: 48px; border-radius: var(--radius-md); background: var(--color-surface); display: grid; place-items: center; color: var(--color-primary-mid); flex: none; box-shadow: var(--shadow-sm); }
.dropzone-title { font-weight: 600; color: var(--color-text-primary); }
.dropzone-files { font: 500 13px var(--font-mono); color: var(--color-primary-mid); margin-top: 4px; word-break: break-all; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 16px 20px; border-radius: var(--radius-md); margin-bottom: 24px; font-size: 15px; border: 1px solid transparent; }
.alert svg { flex: none; margin-top: 2px; }
.alert-success { background: var(--color-success-bg); color: #1E4D34; border-color: #C5E6D2; }
.alert-warning { background: var(--color-warning-bg); color: #6B4910; border-color: #F0DDB8; }
.alert-error { background: var(--color-error-bg); color: #7A2219; border-color: #EFC7C2; }
.alert-info { background: var(--color-surface-alt); color: var(--color-text-body); border-color: var(--color-border); }
.alert ul { margin: 8px 0 0; padding-left: 18px; }
.alert p:last-child { margin-bottom: 0; }
.alert.is-dismissible { position: relative; padding-right: 48px; }
.alert-close { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: inherit; opacity: 0.6; cursor: pointer; }
.alert-close:hover { opacity: 1; background: var(--color-border); }
.alert[hidden] { display: none; }
.alert-close:focus-visible { opacity: 1; outline: 2px solid var(--color-accent); outline-offset: 1px; }
.alert .alert-close svg { margin-top: 0; }

/* ---------- Tables ---------- */
.table-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
thead th {
  background: var(--color-surface-alt); color: var(--color-text-muted);
  font: 600 12px/1.4 var(--font-body); text-transform: uppercase; letter-spacing: .06em;
  text-align: left; padding: 14px 20px; border-bottom: 1px solid var(--color-border);
}
tbody td { padding: 20px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--transition-base); }
tbody tr:hover { background: var(--color-surface-alt); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* Row actions (team): only as wide as the button, flush right, so every table of the page ends its actions on the same edge */
td.cell-action, th.cell-action { width: 1%; text-align: right; white-space: nowrap; }
.cell-title { font-weight: 600; color: var(--color-text-primary); }
.cell-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
/* Export preview: position, value and previous value in the type of the question text */
.preview-table td:not(:first-child) { font-family: var(--font-body); font-size: 12px; }
.progress { height: 6px; border-radius: var(--radius-pill); background: var(--color-surface-alt); overflow: hidden; min-width: 96px; }
.progress > span { display: block; height: 100%; background: var(--color-accent); border-radius: inherit; transition: width 1200ms cubic-bezier(.22, .61, .36, 1); }
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-row .mono { font-size: 13px; color: var(--color-text-body); min-width: 42px; text-align: right; }

/* ---------- Tabs / segmented filter ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; background: var(--color-surface-alt); border-radius: var(--radius-pill); width: fit-content; margin-bottom: 24px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500; color: var(--color-text-body); text-decoration: none;
  transition: background var(--transition-base), color var(--transition-base), box-shadow var(--transition-base);
}
.tabs a:hover { color: var(--color-text-primary); background: rgba(255, 255, 255, .6); }
.tabs a[aria-current="page"] { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-sm); font-weight: 600; }
.tabs .count { font: 500 12px var(--font-mono); color: var(--color-text-muted); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.toolbar .tabs { margin-bottom: 0; }
/* Knowledge base: documents as a single pill, then the two answer views as one switch */
.view-switch { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.tabs-switch { gap: 0; }
.tabs a.tab-warning::before, .tabs a.tab-success::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tabs a.tab-warning::before { background: var(--color-warning); }
.tabs a.tab-success::before { background: var(--color-success); }
.tabs a.tab-warning[aria-current="page"] { background: var(--color-warning-bg); color: var(--color-text-primary); }
.tabs a.tab-success[aria-current="page"] { background: var(--color-success-bg); color: var(--color-text-primary); }
.search { display: flex; gap: 8px; min-width: 280px; }
/* Search field with a magnifier inside on the left (decorative: filtering starts while typing) */
.search-field { position: relative; display: block; flex: 1; }
/* Source filter: funnel left of the search field, its menu opens below the whole search bar */
.search { position: relative; align-items: center; }
.filter-menu { flex: none; }
/* D-083: selection mode toggle left of the funnel */
.search > .select-toggle { flex: none; width: 44px; height: 44px; }
.select-toggle.is-active { background: var(--color-accent-light); color: var(--color-primary); }
.lib-table tr.is-selected td { background: var(--color-surface-alt); }
.filter-menu > summary.icon-btn { width: 44px; height: 44px; color: var(--color-text-muted); }
.filter-menu > summary::before { display: none; }
.filter-menu[open] > summary, .search:has(input[name="quelle"]:checked:not([value=""])) .filter-menu > summary { background: var(--color-accent-light); color: var(--color-primary); }
.filter-menu[open] > summary[data-tip]::after { opacity: 0; }
.filter-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 15; width: min(380px, calc(100vw - 32px));
  max-height: 360px; overflow-y: auto; margin: 0; padding: 12px 16px 16px; display: grid; gap: 4px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.filter-title { padding: 0; margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.filter-panel .checkbox { padding: 6px 0; font-size: 14px; min-width: 0; }
.filter-panel .filter-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-panel .count { font: 500 12px var(--font-mono); color: var(--color-text-muted); }
.filter-panel noscript .btn { margin-top: 8px; }
.search-field svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.search-field input { padding-left: 42px; }
.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-right: -4px; border-radius: 50%; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' fill='none' stroke='%236B7E74' stroke-width='1.75' stroke-linecap='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.search-field input::-webkit-search-cancel-button:hover { background-color: var(--color-surface-alt); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' fill='none' stroke='%23111B17' stroke-width='1.75' stroke-linecap='round'/%3E%3C/svg%3E"); }
/* Sortable column headers: the arrow right of the label shows the direction */
.sort-link { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.sort-link:hover, .sort-link.is-active { color: var(--color-text-primary); text-decoration: none; }
.sort-arrow { width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; flex: none; transition: transform var(--transition-base); }
.sort-arrow.sort-auf { transform: translateY(2px) rotate(-135deg); }
.sort-arrow.sort-ab { transform: translateY(-2px) rotate(45deg); }
.sort-arrow.sort-none { opacity: 0; transform: translateY(-2px) rotate(45deg); }
.sort-link:hover .sort-arrow.sort-none { opacity: .4; }

/* ---------- Details / sources ---------- */
details { border-radius: var(--radius-sm); }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; color: var(--color-primary-mid); font-size: 13px; font-weight: 500; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--transition-base); flex: none; }
details[open] > summary::before { transform: rotate(45deg); }
.excerpt { margin: 8px 0 0; padding: 12px 14px; background: var(--color-surface-alt); border-left: 3px solid var(--color-border-strong); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13px; line-height: 1.55; color: var(--color-text-body); white-space: pre-line; }

/* ---------- Review table ---------- */
.legend { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; color: var(--color-text-muted); margin-bottom: 24px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.review-table td:nth-child(1) { width: 120px; }
.review-table td:nth-child(2) { width: 32%; }
.review-table td:nth-child(3) { width: 34%; }
.review-row { border-left: 3px solid transparent; }
.review-row.level-green { box-shadow: inset 3px 0 0 var(--color-success); }
.review-row.level-yellow { box-shadow: inset 3px 0 0 var(--color-warning); }
.review-row.level-red { box-shadow: inset 3px 0 0 var(--color-error); }
.review-row.is-approved { background: #FBFDFB; }
.review-row.is-approved:hover { background: var(--color-surface-alt); }
.qref { font: 500 15px var(--font-mono); color: var(--color-primary); }
.qtext { color: var(--color-text-primary); font-weight: 500; }
.qsection { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 4px; }
.answer-form { display: grid; gap: 10px; }
.answer-form textarea { min-height: 72px; }
.option-list { display: grid; gap: 8px; margin: 0; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); }
.option-list .checkbox { font-size: 14px; }
.answer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.exclude-form { margin-top: 8px; }
.exclude-form .btn-sm { padding: 6px 0; min-height: 0; font-size: 13px; color: var(--color-text-muted); }
.exclude-form .btn-sm:hover { background: transparent; color: var(--color-text-primary); text-decoration: underline; }
.review-row.is-excluded .qtext { color: var(--color-text-muted); }
/* Compact, so "Freigabe zurücknehmen" and "Generieren" fit side by side in the column. */
.answer-actions .btn-sm { padding: 8px 12px; font-size: 13px; gap: 6px; }
.field-error { font-size: 13px; color: var(--color-error); margin: 0; }
.missing { font-size: 13px; color: var(--color-text-muted); margin: 0; }
.missing-info { font-size: 13px; color: var(--color-error); margin: 0; }
.calculation-note { font-size: 13px; color: var(--color-warning); margin: 0; }
/* Conflicting evidence and checked answers (D-079): the reviewer chooses. */
.alert-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.conflict-box { margin: 8px 0 0; padding: 10px 12px; min-width: 0; border: 0; border-left: 3px solid var(--color-warning); background: var(--color-warning-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; display: grid; gap: 8px; }
.conflict-title { margin: 0; padding: 0; font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.conflict-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--color-text-body); }
.conflict-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.conflict-box .checkbox { font-size: 13px; }
.conflict-box > .cell-sub { margin: 0; }
.source + .source { margin-top: 10px; }
.source-name { font-size: 13px; color: var(--color-text-body); line-height: 1.45; }
.source-item { margin-top: 10px; }
.source-item .cell-sub { margin-bottom: 4px; }
.source-item .excerpt { margin-top: 0; }
/* Further findings (D-078): found but not cited, opened on their own. */
.more-sources { margin-top: 12px; }
.more-sources > summary { color: var(--color-text-body); }
.more-sources > .cell-sub { margin-top: 6px; }
.more-sources .excerpt + .cell-sub { margin-top: 8px; }
.more-sources .source-item > .cell-sub { margin-top: 4px; }
.notes { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--color-text-muted); }
.status-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 10px; }

/* ---------- Empty states, steps, job ---------- */
.empty { text-align: left; padding: 48px; }
.empty .card-title { font-size: 24px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; counter-reset: step; }
.steps li { display: flex; gap: 16px; align-items: flex-start; counter-increment: step; }
.steps li::before {
  content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--color-accent-light); color: var(--color-primary); display: grid; place-items: center;
  font: 600 13px var(--font-mono);
}
.steps strong { color: var(--color-text-primary); display: block; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.narrow { max-width: 720px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--color-accent-light); border-top-color: var(--color-accent); animation: spin 900ms linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Import progress (D-040): the bar grows between polls (htmx keeps the span's id), a
   light sweep shows that work goes on; without a known step the bar slides. */
.progress-live { height: 10px; margin: 16px 0 8px; }
.progress-live > span { position: relative; overflow: hidden; }
.progress-live > span::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: var(--color-surface); opacity: .3; animation: progress-sweep 1600ms ease-in-out infinite;
}
.progress-live.is-indeterminate > span { width: 30%; animation: progress-slide 1400ms ease-in-out infinite; }
.progress-live.is-indeterminate > span::after { display: none; }
@keyframes progress-sweep { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.progress-meta { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--color-text-body); margin-bottom: 16px; }
.progress-meta .mono { color: var(--color-text-primary); }
.progress-meta > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.job { display: flex; gap: 24px; align-items: flex-start; }
/* Cancel (D-080) and, without JavaScript, refresh under a running job */
.job-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.job-actions form { margin: 0; }
.job-details { margin: 16px 0 0; padding: 0; list-style: none; font-size: 14px; }
.job-details li { padding: 8px 0; border-top: 1px solid var(--color-border); }
.job-details li.is-error { display: flex; align-items: flex-start; gap: 8px; color: var(--color-error); font-weight: 500; }
.job-details li.is-error > svg { flex: none; margin-top: 2px; }
.definition { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; font-size: 14px; margin: 0; }
.definition dt { color: var(--color-text-muted); }
.definition dd { margin: 0; color: var(--color-text-primary); }

/* Plan cards (settings → Tarif und Abrechnung, /start): one choice among all plans and
   intervals (D-124); the chosen tile and its card stand out, one button below. */
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: stretch; border: 0; margin: 0; padding: 0; min-width: 0; }
.plan-grid > .card { margin-top: 0; }
.plan-card { display: flex; flex-direction: column; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.plan-card:has(input:checked) { border-color: var(--color-accent); box-shadow: var(--shadow-md); }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-head .card-title { margin: 0; }
.plan-tagline { color: var(--color-text-muted); margin: 8px 0 0; }
.plan-features { list-style: none; margin: 24px 0 32px; padding: 0; display: grid; gap: 12px; }
.plan-features li { display: flex; align-items: center; gap: 10px; color: var(--color-text-body); }
.plan-features svg { flex: none; color: var(--color-success); }
.plan-buy { margin-top: auto; }
.plan-intervals { display: grid; gap: 10px; }
.plan-interval {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.plan-interval:hover { border-color: var(--color-border-strong); }
.plan-interval:has(input:checked) { border-color: var(--color-accent); background: var(--color-surface-alt); }
.plan-interval:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.plan-interval input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-accent); }
.plan-interval input:focus-visible { outline: none; }
.plan-interval-name { display: flex; flex-direction: column; gap: 2px; font-weight: 500; color: var(--color-text-primary); }
.plan-interval-sub { font-size: 13px; font-weight: 400; color: var(--color-text-muted); }
.plan-interval-sub.is-saving { font-weight: 600; color: #1E6B42; } /* same as .tag-success (contrast) */
.plan-price { font-size: 15px; color: var(--color-text-primary); white-space: nowrap; text-align: right; }
.plan-price .mono { font-size: 22px; font-weight: 500; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.plan-per { font-size: 13px; color: var(--color-text-muted); }
.plan-actions { display: flex; justify-content: flex-end; margin-top: 24px; }
.plan-cta { min-width: 260px; justify-content: center; }
/* Booked plan (D-102): facts, usage bars, portal button */
.plan-current .plan-head { align-items: flex-start; }
.plan-current-name { font-size: 28px; margin-top: 4px; }
.plan-current-facts { margin: 24px 0 0; }
.plan-current-alert { display: flex; align-items: flex-start; gap: 8px; margin: 16px 0 0; font-size: 14px; color: #8A5C14; } /* as .tag-warning */
.plan-current-alert svg { flex: none; margin-top: 2px; }
.plan-usage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: 32px 0 0; padding: 24px 0; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.plan-usage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 14px; color: var(--color-text-body); }
.plan-usage-head .mono { font-size: 16px; color: var(--color-primary); }
.plan-usage-label { font-weight: 600; color: var(--color-text-primary); }
.plan-usage .progress { height: 8px; }
.progress.is-full > span { background: var(--color-warning); }
.plan-usage-note { margin-top: 6px; font-size: 13px; color: var(--color-text-muted); }
.plan-current-foot { display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap; margin-top: 24px; }
.plan-current-foot .muted { flex: 1 1 280px; }
.plan-note { margin-top: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 32px 32px 64px; }
  .topbar { padding: 0 32px; }
  .grid-2 { grid-template-columns: 1fr; }
  .plan-grid { grid-template-columns: 1fr; }
  .plan-cta { width: 100%; }
}
@media (max-width: 860px) {
  .plan-usage { grid-template-columns: 1fr; }
  .plan-current-foot .btn { width: 100%; justify-content: center; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 12px 16px; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; font-size: 16px; }
  .brand-logo { display: none; }
  .brand-symbol { display: block; }
  .sidebar-nav { flex-direction: row; }
  .nav { flex-direction: row; }
  .nav-bottom { margin-top: 0; padding-bottom: 0; }
  .nav a { padding: 8px 12px; border-left: 0; border-bottom: 3px solid transparent; border-radius: var(--radius-md); white-space: nowrap; }
  .nav a[aria-current="page"] { border-bottom-color: var(--color-accent); }
  .sidebar-foot { display: none; }
  .topbar { padding: 0 16px; height: 56px; }
  .topbar-meta .org { display: none; }
  .content { padding: 24px 16px 64px; }
  h1 { font-size: 30px; }
  .kpis { gap: 12px; margin-bottom: 32px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 26px; }
  .ring { width: 44px; height: 44px; }
  .card { padding: 24px; }
  .search { min-width: 0; width: 100%; }
  /* Tables become stacked cards */
  .table-card { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100% !important; }
  .stack-table tr { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
  .stack-table td { border-bottom: 0; padding: 12px 20px; }
  .stack-table td:first-child { padding-top: 20px; }
  .stack-table td:last-child { padding-bottom: 20px; }
  .stack-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 4px; }
  .stack-table td.num { text-align: left; }
  .stack-table td.cell-action { text-align: left; }
  .review-row .status-stack { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- Fixes from the visual review ---------- */
.kpis > *, .grid-2 > * { margin-top: 0 !important; }   /* grid cells, not a stack */
h1, .cell-title, .qtext, .source-name, .breadcrumb [aria-current] { overflow-wrap: anywhere; }
.page-header > div:first-child { min-width: 0; }
.kpi > div:first-child { min-width: 0; }
@media (max-width: 860px) {
  .sidebar { gap: 4px; padding: 10px 12px; }
  .brand { padding-right: 4px; }
  .brand-symbol { width: 28px; height: 28px; }
  .sidebar-nav, .nav { gap: 2px; }
  .nav a { gap: 6px; padding: 8px 10px; font-size: 14px; }
  .nav a svg { display: none; }
  .kpi { flex-wrap: wrap; align-items: flex-start; }
  .kpi-label { font-size: 11px; letter-spacing: .04em; }
  .ring { width: 36px; height: 36px; }
  .page-actions { width: 100%; }
  .page-actions form, .page-actions .btn { flex: 1 1 auto; }
  .page-actions form .btn { width: 100%; }
  .legend { gap: 12px; }
  .tabs { width: 100%; }
  .view-switch { width: 100%; }
  .view-switch .tabs { width: fit-content; }
}
/* Skip link becomes visible for keyboard users */
a.visually-hidden:focus { position: fixed; top: 12px; left: 12px; width: auto; height: auto; clip: auto; z-index: 100; padding: 12px 20px; background: var(--color-surface); color: var(--color-primary); border-radius: var(--radius-pill); box-shadow: var(--shadow-lg); }
/* Tenant switcher and user in the topbar */
.org-switch select { min-height: 36px; padding: 6px 36px 6px 12px; font-size: 14px; width: auto; }
.topbar-meta form { margin: 0; }
.topbar-meta .user { color: var(--color-text-body); font-weight: 500; }
@media (max-width: 860px) { .topbar-meta .user { display: none; } }

/* ---------- Auth pages (checkout pattern: logo only, centred card max 480px) ---------- */
.auth-page { background: var(--color-surface-alt); min-height: 100vh; display: flex; flex-direction: column; }
.auth-nav { height: 64px; display: flex; align-items: center; padding: 0 32px; }
.auth-brand { display: inline-flex; align-items: center; }
.auth-brand img { display: block; width: auto; height: 36px; }
.auth-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 16px 96px; }
.auth-card { width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); }
.auth-card .btn-block { margin-top: 8px; }
.auth-alt { text-align: center; margin: 24px 0 0; }
.consent { display: flex; flex-direction: column; gap: 14px; }
/* Passkeys (D-117) */
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0 16px; color: var(--color-text-muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--color-border); }
.passkey-remember { margin-top: 14px; font-size: 14px; }
.passkey-form { margin-top: 16px; }
.passkey-form .field { max-width: 360px; }
/* Choice of trial or plan after the sign-up (D-116) */
.auth-card-plain { max-width: 960px; background: transparent; border: 0; box-shadow: none; padding: 0; }
.start-lead { margin-bottom: 32px; }
.start-trial { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.start-trial.is-featured { border-color: var(--color-border-strong); box-shadow: var(--shadow-md); }
.start-trial .btn { flex: none; }
@media (max-width: 860px) { .start-trial { flex-direction: column; align-items: stretch; } }
.consent .checkbox { align-items: flex-start; }
.consent .checkbox input { margin-top: 3px; }
.auth-title { font-size: 32px; font-weight: 700; margin-bottom: 12px; }
.auth-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--color-accent-light); color: var(--color-primary-mid); display: grid; place-items: center; margin-bottom: 16px; }
.auth-trust { display: flex; gap: 8px; align-items: center; max-width: 480px; margin: 24px 0 0; font-size: 13px; color: var(--color-text-muted); }
.auth-trust svg { flex: none; }
input[type="email"] { width: 100%; min-height: 44px; padding: 10px 14px; font: 400 15px/1.5 var(--font-body); color: var(--color-text-primary); background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); transition: border-color var(--transition-base), box-shadow var(--transition-base); }
/* Team page */
.section-title { font-size: 24px; margin: 48px 0 16px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { width: auto; min-width: 150px; }
.name-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.person-form { flex-wrap: wrap; }
.person-form input[type="text"] { width: auto; flex: 1 1 120px; min-width: 0; min-height: 36px; padding: 6px 10px; font-size: 14px; }
@media (max-width: 560px) { .name-fields { grid-template-columns: 1fr; } }
/* Audit log */
input[type="date"] { width: 100%; min-height: 44px; padding: 10px 14px; font: 400 15px/1.5 var(--font-body); color: var(--color-text-primary); background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); }
.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 16px; align-items: end; padding: 24px; margin-bottom: 24px; }
.filter-bar .field { margin-bottom: 0; }
.filter-actions { display: flex; gap: 8px; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
@media (max-width: 1100px) { .filter-bar { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .filter-bar { grid-template-columns: 1fr; } }

/* Spacing utilities (8px grid) - replace inline style attributes, which the CSP forbids */
.m-0 { margin: 0; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-48 { margin-top: 48px; }
.mb-16 { margin-bottom: 16px; }
.mb-48 { margin-bottom: 48px; }

/* Progress bar widths in 5 % steps (exact value is set by app.js from data-width) */
.progress > span.w-0 { width: 0%; }
.progress > span.w-5 { width: 5%; }
.progress > span.w-10 { width: 10%; }
.progress > span.w-15 { width: 15%; }
.progress > span.w-20 { width: 20%; }
.progress > span.w-25 { width: 25%; }
.progress > span.w-30 { width: 30%; }
.progress > span.w-35 { width: 35%; }
.progress > span.w-40 { width: 40%; }
.progress > span.w-45 { width: 45%; }
.progress > span.w-50 { width: 50%; }
.progress > span.w-55 { width: 55%; }
.progress > span.w-60 { width: 60%; }
.progress > span.w-65 { width: 65%; }
.progress > span.w-70 { width: 70%; }
.progress > span.w-75 { width: 75%; }
.progress > span.w-80 { width: 80%; }
.progress > span.w-85 { width: 85%; }
.progress > span.w-90 { width: 90%; }
.progress > span.w-95 { width: 95%; }
.progress > span.w-100 { width: 100%; }

/* htmx indicator (htmx's own inline <style> is disabled for the CSP) */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Quality-of-life features (D-022) ---------- */
/* Destructive action: error colour, outline only (the accent stays for interaction). */
.btn-danger { background: transparent; color: var(--color-error); border-color: var(--color-error); }
.btn-danger:hover { background: var(--color-error-bg); color: var(--color-error); }
/* Filled variants for the management box of a questionnaire (not the call to action:
   that stays the single .btn-primary of the view) */
.btn-filled { background: var(--color-accent); color: var(--color-text-inverse); border-color: var(--color-accent); }
.btn-filled:hover { background: var(--color-primary-mid); border-color: var(--color-primary-mid); color: var(--color-text-inverse); }
.btn-danger-filled { background: var(--color-error); color: var(--color-text-inverse); border-color: var(--color-error); }
.btn-danger-filled:hover { color: var(--color-text-inverse); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.due-tag { margin-left: 8px; }
.filter-bar select { min-height: 44px; }
.scope-bar { grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, 1fr) auto; }
.scope-bar .btn svg { margin-right: 2px; }
.evidence-filter {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -8px 0 24px; padding: 8px 8px 8px 16px;
  border-radius: var(--radius-pill); background: var(--color-surface-alt); color: var(--color-text-body); font-size: 14px; width: fit-content;
}
.evidence-filter svg { color: var(--color-text-muted); flex: none; }

/* Bulk selection in the review table */
.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 24px;
  padding: 16px 20px; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.bulk-bar .checkbox { margin: 0; font-size: 14px; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.bulk-actions select { width: auto; min-width: 200px; min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; }
.bulk-count { font-size: 13px; color: var(--color-text-muted); }
.bulk-bar .hint { flex-basis: 100%; }
/* Questionnaire actions directly above the question table */
.select-item { display: inline-flex; margin: 0 0 8px; cursor: pointer; }
.select-item input { width: 18px; height: 18px; accent-color: var(--color-accent); margin: 0; }
.review-row.is-selected { background: var(--color-surface-alt); }

/* Assignee of a single question */
.assign { margin-top: 12px; }
.assign-form { display: flex; align-items: center; gap: 8px; }
.assign-form label { margin: 0; font-size: 12px; color: var(--color-text-muted); font-weight: 500; }
.assign-form select { width: auto; max-width: 100%; min-height: 32px; padding: 4px 32px 4px 10px; font-size: 13px; background-position: right 10px center; }

/* Unsaved edits and the question the reviewer moved on to */
.dirty-note { margin: 0; font-size: 12px; font-weight: 600; color: #8A5C14; } /* same as .tag-warning (contrast) */
.review-row.is-dirty { box-shadow: inset 3px 0 0 var(--color-warning); }
/* Automatic save (app.js): the note replaces "Ungespeicherte Änderung" and the save button */
.save-state { margin: 0; font-size: 12px; color: var(--color-text-muted); }
.save-state:empty { display: none; }
.save-state.field-error { color: var(--color-error); }
.js .dirty-note, .js [data-manual-save], .js [data-manual-submit] { display: none; }

/* Evidence passage inside a source excerpt */
mark.evidence { background: var(--color-highlight); color: var(--color-text-primary); border-radius: 3px; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

/* Questionnaire management */
.manage-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 16px; align-items: start; margin-top: 16px; }
.manage-grid .field { margin-bottom: 0; }
.manage-actions { padding-top: 30px; display: flex; align-items: center; gap: 12px; min-height: 44px; }
/* Re-prefill, audit protocol, archive, delete: one row of buttons below the fields */
.manage-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--color-border); }
.manage-buttons form { display: flex; align-items: center; gap: 12px; margin: 0; }
.manage-buttons .checkbox { margin: 0; }
.js [data-no-js] { display: none; }
.js-only { display: none; }
.js .js-only { display: inline; }

/* Knowledge base: usage, inline edit, document management */
.usage { margin-top: 10px; font-size: 12px; color: var(--color-text-muted); }
.usage ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.usage a { font-size: 13px; }
/* Library rows list their questionnaires only while expanded */
.lib-table tr:not(:has(details.source[open])) .usage { display: none; }
/* Collapsed: only the number of questionnaires; expanded, the list replaces it */
.usage-count { margin-top: 4px; font-size: 11px; color: var(--color-text-muted); }
.lib-table tr:has(details.source[open]) .usage-count { display: none; }
/* Library entry: question and answer read as text; "Bearbeiten" turns them into fields in place */
textarea.inline-text {
  display: block; width: auto; min-width: 12ch; max-width: 100%; min-height: 0; resize: none; overflow: hidden; field-sizing: content;
  margin: -3px 0 0 -7px; padding: 2px 6px; border: 1.5px solid transparent; border-radius: var(--radius-sm);
  background: transparent; box-shadow: none; font: inherit; line-height: 1.5; color: var(--color-text-body);
}
textarea.inline-text.qtext { color: var(--color-text-primary); font-weight: 500; }
textarea.inline-text[readonly] { cursor: default; }
textarea.inline-text[readonly]:focus { outline: none; box-shadow: none; border-color: transparent; }
tr.is-editing textarea.inline-text, textarea.inline-text:not([readonly]):hover { border-color: var(--color-border); }
textarea.inline-text:not([readonly]):focus { outline: none; border-color: var(--color-accent); background: var(--color-surface); box-shadow: 0 0 0 3px rgba(64, 145, 108, .15); }
.inline-edit-form { display: contents; }

/* Row actions as round icon buttons (replace, delete) */
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-pill);
  border: 0; background: transparent; padding: 0; cursor: pointer;
  color: var(--color-text-muted); transition: background var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover { background: var(--color-surface-alt); color: var(--color-text-body); }
.icon-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.icon-btn-danger { color: var(--color-error); }
.icon-btn-danger:hover { background: var(--color-error-bg); color: var(--color-error); }
.icon-btn-success { color: var(--color-success); }
.icon-btn-success:hover { background: var(--color-success-bg); color: var(--color-success); }
.row-actions form { margin: 0; display: contents; }
.row-actions [hidden] { display: none; }
/* Which buttons a library row shows is decided by CSS (html.js is set before the first
   paint), so the no-JavaScript "Speichern" never flashes. */
[data-lib-edit], [data-lib-cancel],
.js [data-lib-save], .js tr.is-editing [data-lib-edit], .js tr.is-editing [data-lib-hide] { display: none; }
.js [data-lib-edit], .js tr.is-editing [data-lib-save], .js tr.is-editing [data-lib-cancel] { display: inline-flex; }
/* Short explanation above an icon button (data-tip), right-aligned so it stays inside the
   table card; shown on hover and keyboard focus. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20;
  padding: 6px 10px; border-radius: var(--radius-sm); background: var(--color-text-primary); color: var(--color-text-inverse);
  font: 500 12px/1.3 var(--font-body); letter-spacing: 0; text-transform: none; white-space: nowrap;
  opacity: 0; transform: translateY(2px); pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: none; transition-delay: 250ms; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 24px; }

/* Modal: the replace/delete form over a blurred page (native <dialog>, opened by app.js) */
.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto;
  padding: 40px; border: 0; border-radius: var(--radius-lg);
  background: var(--color-surface); color: var(--color-text-body); box-shadow: var(--shadow-xl);
}
.modal::backdrop { background: rgba(17, 27, 23, .32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal[open] { animation: modal-in var(--transition-base); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Confirmed answer: the row lights up green, a check is drawn into a badge, then the row
   slides out (app.js removes it and moves the count to the "Geprüfte Antworten" tab). */
.lib-table tr.is-confirmed td { animation: confirm-row 1.5s ease-out both; }
@keyframes confirm-row { 0% { background: var(--color-surface); } 15%, 70% { background: var(--color-success-bg); } 100% { background: var(--color-success-bg); } }
.confirm-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill);
  background: var(--color-success); color: var(--color-text-inverse); font: 600 13px var(--font-body);
  animation: confirm-pop 450ms cubic-bezier(.34, 1.56, .64, 1) both;
}
.confirm-badge svg path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: confirm-draw 350ms 200ms ease-out forwards; }
@keyframes confirm-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes confirm-draw { to { stroke-dashoffset: 0; } }
.lib-table tr.is-leaving { transition: opacity 300ms ease-in, transform 300ms ease-in; opacity: 0; transform: translateX(24px); }
.tabs .count.is-bumped { animation: count-bump 600ms ease-out; }
@keyframes count-bump { 0% { transform: none; } 30% { transform: scale(1.5); color: var(--color-success); } 100% { transform: none; } }
.tabs .count { display: inline-block; }
.modal-close { position: absolute; top: 16px; right: 16px; }
.modal-file { font-weight: 600; color: var(--color-text-primary); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; word-break: break-word; }
.modal-page { max-width: 640px; }
.modal-wide { width: min(880px, calc(100vw - 32px)); }

/* Document details (modal) */
.doc-detail .card-title { padding-right: 40px; overflow-wrap: anywhere; }
.doc-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 20px; font-size: 13px; color: var(--color-text-muted); }
.doc-section { margin-top: 28px; }
.doc-section h3 { font-size: 16px; margin-bottom: 6px; }
.entry-group { margin-top: 12px; }
.entry-group > summary { margin-bottom: 8px; }
.entry-list, .usage-list, .chunk-list { list-style: none; margin: 0; padding: 0; }
.entry-list li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--color-border); font-size: 14px; }
.entry-q { font-weight: 600; color: var(--color-text-primary); }
.entry-a { color: var(--color-text-body); }
.usage-list li { padding: 6px 0; font-size: 14px; }
.chunks > summary { font-size: 15px; font-weight: 600; color: var(--color-text-primary); }
.chunk-search { margin: 12px 0; }
.chunk-list li { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--color-border); }
.chunk-list li:first-child { border-top: 0; }
.chunk-loc { font-family: var(--font-mono); font-size: 12px; color: var(--color-text-muted); }
.chunk-text { font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; }
.readability-tag { margin-left: 8px; padding: 2px 8px; font-size: 11px; text-decoration: none; }
body.has-modal { overflow: hidden; }
@media (max-width: 860px) { .modal { padding: 24px; } }

/* Document kind badges; for editors the badge itself is the <select> */
.kind-document { background: var(--color-surface-alt); color: var(--color-text-body); }
.kind-filled_questionnaire { background: var(--color-accent-light); color: var(--color-primary); }
.kind-policy { background: var(--kind-policy-bg); color: var(--kind-policy-fg); }
.kind-report { background: var(--kind-report-bg); color: var(--kind-report-fg); }
.kind-certificate { background: var(--kind-certificate-bg); color: var(--kind-certificate-fg); }
.kind-initiative { background: var(--kind-initiative-bg); color: var(--kind-initiative-fg); }
.kind-kpi { background: var(--kind-kpi-bg); color: var(--kind-kpi-fg); }
.kind-evidence { background: var(--kind-evidence-bg); color: var(--kind-evidence-fg); }
.kind-form { display: flex; align-items: center; gap: 8px; margin: 0; }
/* Reporting year (D-037): looks like text, becomes a field on click, like the name */
.year-form { display: flex; justify-content: center; margin: 0; }
input.year-input, input.year-input:focus {
  width: 6ch; min-height: 0; padding: 2px 4px; text-align: center; font: 500 14px var(--font-mono);
  color: var(--color-text-body); background: transparent; border: 1.5px solid transparent;
  border-radius: var(--radius-sm); box-shadow: none; outline: none; cursor: text;
}
input.year-input:hover { border-color: var(--color-border); }
input.year-input:focus { border-color: var(--color-accent); background: var(--color-surface); box-shadow: 0 0 0 3px rgba(64, 145, 108, .15); }
input.year-input:invalid:not(:focus) { border-color: var(--color-error); }
/* Expiry date (D-058): same inline field, wide enough for 31.12.2027 */
input.year-input.valid-input { width: calc(10ch + 12px); }
.valid-tag { display: inline-block; margin-top: 4px; }
.expiry-list { margin: 6px 0 0; padding-left: 18px; }
/* Upload overview (D-039): one row per new document, fields always visible */
/* own class: .review-table belongs to the questionnaire review */
.upload-table td { vertical-align: top; }
.upload-table th:nth-child(1) { width: 42%; }
.upload-table th:nth-child(2) { width: 22%; }
.upload-table th:nth-child(3) { width: 11%; }
.upload-table th:nth-child(4) { width: 14%; white-space: nowrap; }
.upload-table th:nth-child(5) { width: 11%; white-space: nowrap; }
@media (min-width: 861px) {
  /* centred under its heading, on the line of the fields */
  .upload-table td.num, .upload-table th.cell-center { text-align: center; }
  .upload-table td.num { line-height: 44px; }
}
.upload-table select { min-width: 150px; }
input.review-year { width: 10ch; text-align: center; font-family: var(--font-mono); }
input.review-year:invalid:not(:focus) { border-color: var(--color-error); }
input.review-year.review-valid { width: calc(10ch + 36px); }
/* D-041: same name as an existing document */
.name-clash { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 8px; margin-top: 8px; padding: 8px 12px; font-size: 13px; color: var(--color-text-body); background: var(--color-warning-bg); border-radius: var(--radius-sm); }
.name-clash > svg { flex: none; margin-top: 2px; color: var(--color-warning); }
.name-clash > span { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.name-clash .checkbox { flex-basis: 100%; }
/* Outdated documents (D-037): greyed out, the clock toggle shows the state */
.doc-table tr.is-outdated td:not([data-label="Aktionen"]) { opacity: .55; }
.icon-btn.is-on { background: var(--color-surface-alt); color: var(--color-text-primary); }
/* Seven columns and four row actions: tighter cells; on narrower desktops the import date
   and then the section count (both also in the details) give way, so the actions are
   never cut off. */
@media (min-width: 861px) {
  .doc-table th, .doc-table td { padding-left: 12px; padding-right: 12px; }
  .doc-table th:first-child, .doc-table td:first-child { padding-left: 20px; }
  .doc-table th:last-child, .doc-table td:last-child { padding-right: 12px; }
  .doc-table .row-actions { gap: 2px; }
}
@media (min-width: 861px) and (max-width: 1439px) {
  .doc-table th:nth-child(6), .doc-table td[data-label="Importiert"] { display: none; }
}
@media (min-width: 861px) and (max-width: 1199px) {
  .doc-table th:nth-child(5), .doc-table td[data-label="Abschnitte"] { display: none; }
}
select.kind-select {
  width: auto; min-height: 0; padding: 4px 28px 4px 12px; border: 0;
  field-sizing: content; /* as wide as the chosen kind, where supported */
  border-radius: var(--radius-pill); font: 600 12px/1.4 var(--font-body);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236B7E74' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  transition: box-shadow var(--transition-fast);
}
select.kind-select:hover { box-shadow: 0 0 0 2px var(--color-border-strong); }
select.kind-select:focus { box-shadow: 0 0 0 3px rgba(64, 145, 108, .25); }

/* Document name: looks like text, becomes a field on click (Enter/leaving saves, Esc reverts) */
.name-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0; }
.name-box {
  display: inline-flex; align-items: baseline; max-width: 100%;
  margin-left: -8px; padding: 2px 6px; border: 1.5px solid transparent; border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.name-box:hover { border-color: var(--color-border); }
.name-box:focus-within { border-color: var(--color-accent); background: var(--color-surface); box-shadow: 0 0 0 3px rgba(64, 145, 108, .15); }
input.name-input, input.name-input:focus {
  width: auto; max-width: 100%; min-height: 0; field-sizing: content; min-width: 4ch;
  padding: 0; border: 0; border-radius: 0; box-shadow: none; outline: none;
  background: transparent; font: 600 15px/1.5 var(--font-body); color: var(--color-text-primary);
  cursor: text;
}
.name-suffix { flex: none; white-space: nowrap; overflow-wrap: normal; font: 600 15px/1.5 var(--font-body); color: var(--color-text-muted); }
.name-box { min-width: 0; flex-wrap: wrap; }
input.name-input { flex: none; }

/* Document table: every cell centred vertically; kind, sections and date also
   horizontally (on wide screens; stacked cards stay left-aligned) */
.doc-table tbody td, .lib-table tbody td[data-label="Aktionen"] { vertical-align: middle; }
/* Questionnaire overview: every cell centred vertically. Headings centred here and in
   the knowledge base tables (documents, unchecked and checked answers). */
.questionnaire-table tbody td { vertical-align: middle; }
.invitation-table tbody td { vertical-align: middle; }
/* Member rows: everything on the line of the name fields (36px high), e-mail below */
.member-table tbody td { vertical-align: top; }
.member-table select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; }
.member-table td[data-label="Letzte Anmeldung"] { line-height: 36px; white-space: nowrap; }
@media (max-width: 860px) {
  .member-table td[data-label="Letzte Anmeldung"] { line-height: inherit; }
}
/* Member rows (D-105): without JavaScript both actions; with it "Entfernen" until a field
   of the row changes, then a green "Speichern" (app.js sets is-dirty and btn-primary). */
.member-actions { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; }
.js .member-table tr:not(.is-dirty) .member-save,
.js .member-table tr.is-dirty .member-remove { display: none; }
.questionnaire-table thead th, .doc-table thead th, .lib-table thead th { text-align: center; }
.lib-table tbody tr:not(.is-editing), .lib-table tbody tr:not(.is-editing) textarea.inline-text[readonly] { cursor: pointer; }
.lib-table tbody tr.is-expanded td { vertical-align: top; }
/* The disclosure triangle sits before the question (the whole row expands on click)
   and turns while the row is open; the passage in the excerpt is marked yellow. */
.lib-table details.source > summary::before { display: none; }
.row-toggle { display: none; }
@media (min-width: 861px) {
  .lib-table td[data-label="Frage"] { position: relative; padding-left: 40px; }
  .row-toggle { display: block; }
}
.row-toggle {
  position: absolute; left: 18px; top: 28px; width: 7px; height: 7px;
  border-right: 1.5px solid var(--color-text-muted); border-bottom: 1.5px solid var(--color-text-muted);
  transform: rotate(-45deg); transition: transform var(--transition-base);
}
.lib-table tr:has(details.source[open]) .row-toggle { transform: rotate(45deg); }
.lib-table tr:hover .row-toggle { border-color: var(--color-text-primary); }
/* Review (D-046): the triangle before the number opens all evidence of the row; it is a
   button and needs JavaScript (app.js), without it each document opens on its own. */
.review-table .row-toggle { padding: 0; background: none; border-top: 0; border-left: 0; border-radius: 0; cursor: pointer; top: 24px; }
.review-table .row-toggle::after { content: ""; position: absolute; inset: -12px; }
html:not(.js) .review-table .row-toggle { display: none; }
@media (min-width: 861px) {
  .js .review-table td[data-label="Nr."] { position: relative; padding-left: 40px; }
  .js .review-table details.source > summary::before { display: none; }
}
.review-table tr:is(.is-expanded, :has(details.source[open])) .row-toggle { transform: rotate(45deg); }
.review-table .row-toggle:hover { border-color: var(--color-text-primary); }
.js .review-table tr.review-row:has(.row-toggle) { cursor: pointer; }
.js .review-table tr.review-row:has(.row-toggle):hover .row-toggle { border-color: var(--color-text-primary); }
/* "Keine Frage? Ausblenden" (D-053), the notes (D-073) and the further findings (D-078)
   only in an expanded row; without JavaScript, in a row without a triangle and in the
   card view they stay visible. */
@media (min-width: 861px) {
  .js .review-table tr.review-row:not(.is-expanded) .exclude-form { display: none; }
  .js .review-table tr.review-row:has(.row-toggle):not(.is-expanded) :is(.item-notes, .more-sources) { display: none; }
  /* The notes open with the row (app.js), so they need no heading of their own. */
  .js .review-table tr.review-row:has(.row-toggle) .item-notes > summary { display: none; }
  .js .review-table tr.review-row:has(.row-toggle) .item-notes > .note-list:first-of-type { margin-top: 0; }
  /* Nothing to unfold without evidence: the row grows a little, so expanding shows. */
  .js .review-table tr.review-row:not(:has(details.source)) td { transition: padding-bottom var(--transition-base); }
  .js .review-table tr.review-row.is-expanded:not(:has(details.source)) td { padding-bottom: 44px; }
}
.review-table tr.review-row :is(textarea:not([readonly]), input:not([type="checkbox"], [type="hidden"], [readonly]), .excerpt) { cursor: text; }
/* Answer tables: fixed column widths, so switching between unchecked and checked answers
   does not move the table (the widths no longer depend on the content). */
@media (min-width: 861px) {
  .lib-table { table-layout: fixed; }
  .lib-table .col-question { width: 30%; }
  .lib-table .col-answer { width: 26%; }
  .lib-table .col-actions { width: 156px; }
  .lib-table td[data-label="Aktionen"] { padding-left: 12px; padding-right: 12px; }
  .lib-table [data-lib-save] { padding: 6px 14px; }
  .lib-table td { overflow-wrap: anywhere; }
}
@media (min-width: 861px) {
  .doc-table .cell-center { text-align: center; }
  .doc-table .cell-center .kind-form { justify-content: center; }
}

@media (max-width: 1100px) {
  .scope-bar, .manage-grid { grid-template-columns: 1fr 1fr; }
  .manage-actions { padding-top: 0; }
}
@media (max-width: 860px) {
  .scope-bar, .manage-grid { grid-template-columns: 1fr; }
  .bulk-actions { margin-left: 0; width: 100%; }
  .bulk-actions select { flex: 1 1 100%; }
  .row-actions { justify-content: flex-start; }
}

/* Detected structure (D-067): the edit form opens below its row */
.structure-table td { vertical-align: top; }
/* Same type size as the export preview table (question, field, type) */
.structure-table td:not([data-label="Nr."]) { font-size: 12px; }
.structure-table td, .structure-table td .mono { font-family: var(--font-body); }
.structure-edit > summary { list-style: none; cursor: pointer; }
.structure-edit > summary::-webkit-details-marker { display: none; }
.structure-form { margin-top: 12px; }
/* Team page: what each role may do */
.role-guide { margin: 0; }
.role-guide > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); align-items: baseline; gap: 16px; padding: 12px 0; border-top: 1px solid var(--color-border); }
.role-guide > div:first-child { border-top: 0; padding-top: 0; }
.role-guide dd { margin: 0; font-size: 14px; color: var(--color-text-body); }
/* One colour per role, wherever a role is shown as a tag */
.role-viewer { background: var(--color-surface-alt); color: var(--color-text-body); }
.role-editor { background: var(--kind-policy-bg); color: var(--kind-policy-fg); }
.role-approver { background: var(--color-success-bg); color: #1E6B42; }
.role-admin { background: var(--kind-report-bg); color: var(--kind-report-fg); }
/* Fixed column widths: the edit form opening in the last column moves nothing */
@media (min-width: 861px) {
  .structure-table { table-layout: fixed; }
  .structure-table .col-nr { width: 72px; }
  .structure-table .col-field { width: 18%; }
  .structure-table .col-type { width: 16%; }
  .structure-table .col-edit { width: 260px; }
  /* "Ändern" and "freigegeben" at the right edge; the opened form stays left-aligned */
  .structure-table td[data-label="Ändern"] { text-align: right; }
  .structure-table .structure-form { text-align: left; }
  /* the button's own padding would leave "Ändern" short of the edge "freigegeben" uses */
  .structure-table .structure-edit > summary.btn-sm { margin-right: -18px; }
  .structure-table td { overflow-wrap: anywhere; }
}
/* D-086: a number field that probably asks for several figures */
.several-values { margin-top: 8px; display: grid; gap: 4px; justify-items: start; }
.several-values form { margin: 0; }
.structure-form .field { margin-bottom: 10px; }
.structure-form label { font-size: 12px; }
.structure-cells { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
[data-show-for][hidden] { display: none; }
/* Justification of a choice answer without a comment field in the file (D-071) */
.reason-label { display: block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--color-text-body); }
.open-list { margin: 0; padding-left: 0; list-style: none; max-height: 320px; overflow: auto; }
.open-list li { padding: 4px 0; }
/* Internal notes on a question (D-073) */
.item-notes { margin-top: 8px; font-size: 13px; }
.item-notes > summary { cursor: pointer; color: var(--color-text-body); font-weight: 600; }
.note-list { list-style: none; margin: 6px 0; padding: 0; }
.note-list li { padding: 6px 0; border-bottom: 1px solid var(--color-border); }
.note-text { margin: 2px 0 0; white-space: pre-wrap; }
.item-notes form { margin-top: 6px; }

/* Guided first session (D-099) */
.onboarding-steps { list-style: none; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin: 0 0 24px; padding: 0; counter-reset: none; }
.onboarding-steps a { display: flex; flex-direction: column; gap: 6px; padding: 10px 0 0; border-top: 3px solid var(--color-border); color: var(--color-text-muted); text-decoration: none; font-size: 13px; line-height: 1.3; }
.onboarding-steps a:hover { color: var(--color-text-primary); }
.onboarding-steps .is-done a { border-top-color: var(--color-primary-mid); color: var(--color-text-body); }
.onboarding-steps [aria-current="step"] a { border-top-color: var(--color-accent); color: var(--color-text-primary); font-weight: 600; }
.onboarding-number { font-size: 12px; }
.onboarding-card { max-width: 920px; }
.onboarding-card p { margin: 0 0 12px; color: var(--color-text-body); }
.onboarding-legend { margin: 8px 0 16px; }
.onboarding-legend > div { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: baseline; gap: 16px; padding: 10px 0; border-top: 1px solid var(--color-border); }
.onboarding-legend > div:first-child { border-top: 0; }
.onboarding-legend dd { margin: 0; font-size: 14px; color: var(--color-text-body); }
.onboarding-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; max-width: 920px; margin-top: 24px; }
.onboarding-nav form { margin: 0; }
.onboarding-skip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 920px; margin-top: 16px; }
@media (max-width: 860px) {
  .onboarding-steps { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .onboarding-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }  /* stays readable for screen readers */
}

/* Onboarding pictures (D-100): screenshots and rebuilt sections */
.onboarding-shot { margin: 20px 0 8px; }
.onboarding-shot-frame { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.onboarding-shot img { display: block; width: 100%; height: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); background: var(--color-surface); }
.onboarding-shot figcaption { margin-top: 8px; font-size: 12px; color: var(--color-text-muted); }
.mock-flow { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0 8px; padding: 0; }
.mock-flow li { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-alt); font-size: 13px; color: var(--color-text-muted); }
.mock-flow strong { font-size: 15px; color: var(--color-text-primary); }
.mock-flow-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-bottom: 6px; border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-accent); box-shadow: var(--shadow-sm); }
.mock-answer { margin: 20px 0 8px; padding: 16px; border: 1px solid var(--color-border); border-left: 4px solid var(--color-warning); border-radius: var(--radius-md); background: var(--color-surface); }
.mock-caption { margin-bottom: 12px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.mock-answer-question { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.mock-answer-question p { flex-basis: 100%; margin: 4px 0 12px; color: var(--color-text-primary); font-weight: 500; }
.mock-answer-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.mock-answer-value, .mock-answer-source { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.mock-answer-value strong { font-size: 18px; color: var(--color-text-primary); }
.mock-answer-source { padding: 12px; border-radius: var(--radius-sm); background: var(--color-surface-alt); }
.mock-answer-source q { margin-top: 4px; color: var(--color-text-body); }
.mock-answer-source mark { background: var(--color-highlight); padding: 0 2px; border-radius: 3px; }
@media (max-width: 860px) {
  .mock-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mock-answer-body { grid-template-columns: 1fr; }
  .onboarding-shot img { width: 640px; max-width: none; } /* swipe sideways, text stays readable */
}
