/*
 * Wiz-Tech Toolkit: Design-Tokens und Bausteine für alle Toolkit-Module.
 * Farben nutzen light-dark(), damit sie dem Hell-/Dunkel-Schalter des TYPO3-Backends folgen.
 * Alle Klassen tragen das Präfix "tk-" und gelten nur innerhalb von .tk.
 */
@font-face { font-family: "Bricolage Grotesque"; src: url("../Fonts/bricolage-grotesque-variable.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../Fonts/ibm-plex-sans-variable.woff2") format("woff2"); font-weight: 100 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../Fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../Fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

.tk {
  --tk-bg: light-dark(#F3F5F3, #0F1513);
  --tk-surface: light-dark(#FFFFFF, #161E1B);
  --tk-surface-2: light-dark(#E9EEEB, #1E2925);
  --tk-ink: light-dark(#16201C, #E4EBE8);
  --tk-ink-2: light-dark(#4A5853, #A2B1AB);
  --tk-ink-3: light-dark(#6B7974, #7E8D87);
  --tk-line: light-dark(#D8DFDB, #2A3631);
  --tk-accent: light-dark(#1C6B58, #5DB89C);
  --tk-accent-ink: light-dark(#FFFFFF, #0C1411);
  --tk-accent-soft: light-dark(#DCEDE6, #1B3A30);
  --tk-source: light-dark(#6A56E0, #A99BFF);
  --tk-source-soft: light-dark(#ECE9FD, #28234A);
  --tk-ok: light-dark(#2C7A4B, #6CC28E);
  --tk-ok-soft: light-dark(#DDF0E3, #173226);
  --tk-warn: light-dark(#9A600C, #E0A54A);
  --tk-warn-soft: light-dark(#F7EBD3, #3A2C14);
  --tk-bad: light-dark(#B23A2E, #EC7C70);
  --tk-bad-soft: light-dark(#F6DEDA, #3D1D1A);
  --tk-info: light-dark(#2D5C9E, #7EA6E0);
  --tk-info-soft: light-dark(#DEE7F4, #1A2840);
  --tk-f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --tk-f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --tk-f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --tk-r: 6px;
  --tk-gap: 16px;

  font-family: var(--tk-f-body);
  font-size: .875rem;
  line-height: 1.5;
  color: var(--tk-ink);
  display: grid;
  gap: var(--tk-gap);
  max-width: 1400px;
}
.tk a:not(.btn) { color: var(--tk-accent); }

/* Kopf */
.tk-header { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.tk-header h1 { font: 700 1.75rem/1.15 var(--tk-f-display); letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.tk-header p { margin: 4px 0 0; color: var(--tk-ink-3); font-size: .9rem; }
.tk-eyebrow { font: 500 .7rem/1 var(--tk-f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--tk-accent); }

/* Raster */
.tk-grid { display: grid; gap: var(--tk-gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--tk-col, 320px)), 1fr)); align-items: start; }
.tk-grid > * { min-width: 0; }

/* Karte */
.tk-card { background: var(--tk-surface); border: 1px solid var(--tk-line); border-radius: var(--tk-r); padding: 18px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.tk-card--flush { padding: 0; overflow: hidden; gap: 0; }
.tk-card--flush > .tk-card__head { padding: 14px 16px 10px; }
.tk-card__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-card__title { font: 500 .72rem/1.2 var(--tk-f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--tk-ink-3); margin: 0; }
.tk-card__body { display: grid; gap: 10px; min-width: 0; }
.tk-card p { margin: 0; }

/* Kennzahl */
.tk-kpi__value { font: 700 1.6rem/1.1 var(--tk-f-display); font-variant-numeric: tabular-nums; }
.tk-kpi__value--empty { color: var(--tk-ink-3); }
.tk-kpi__hint { font-size: .8rem; color: var(--tk-ink-3); }

/* Statuspille */
.tk-pill { font: 500 .72rem/1 var(--tk-f-body); padding: 4px 8px; border-radius: 99px; display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; background: var(--tk-surface-2); color: var(--tk-ink-2); }
.tk-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tk-pill--ok { background: var(--tk-ok-soft); color: var(--tk-ok); }
.tk-pill--warning { background: var(--tk-warn-soft); color: var(--tk-warn); }
.tk-pill--critical { background: var(--tk-bad-soft); color: var(--tk-bad); }
.tk-pill--info { background: var(--tk-info-soft); color: var(--tk-info); }
.tk-pill--source { background: var(--tk-source-soft); color: var(--tk-source); }

/* Leerzustand */
.tk-empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 28px 16px; color: var(--tk-ink-3); font-size: .875rem; }
.tk-empty__title { color: var(--tk-ink-2); font-weight: 600; font-size: .95rem; }
.tk-empty__text { max-width: 52ch; }
.tk-empty__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* Liste mit Zeilen */
.tk-list { display: grid; margin: 0; padding: 0; list-style: none; }
.tk-list__item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--tk-line); }
.tk-list__item:first-child { border-top: 0; padding-top: 0; }
.tk-list__item small { grid-column: 2; color: var(--tk-ink-3); }
.tk-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--tk-line); display: grid; place-items: center; grid-row: span 2; }
.tk-check--done { background: var(--tk-ok); border-color: var(--tk-ok); }
.tk-check--done::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--tk-accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* Schlüssel/Wert */
.tk-kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 7px 16px; margin: 0; font-size: .875rem; }
.tk-kv dt { color: var(--tk-ink-3); font-weight: 400; }
.tk-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Tabelle */
.tk-table-wrap { overflow-x: auto; }
.tk-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tk-table th { font: 500 .68rem var(--tk-f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--tk-ink-3); background: var(--tk-surface-2); text-align: left; padding: 8px 14px; white-space: nowrap; }
.tk-table td { padding: 10px 14px; border-top: 1px solid var(--tk-line); vertical-align: middle; }
.tk-table tbody tr:hover { background: color-mix(in srgb, var(--tk-surface-2) 55%, transparent); }
.tk-table .tk-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Hinweis */
.tk-notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--tk-r); background: var(--tk-accent-soft); font-size: .875rem; }
.tk-notice--warning { background: var(--tk-warn-soft); }
.tk-notice--critical { background: var(--tk-bad-soft); }

.tk-mono { font-family: var(--tk-f-mono); font-size: .85em; }
.tk-muted { color: var(--tk-ink-3); }
.tk-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tk-progress { height: 6px; border-radius: 3px; background: var(--tk-surface-2); overflow: hidden; }
.tk-progress > span { display: block; height: 100%; background: var(--tk-accent); border-radius: 3px; }

/* Reiter und Filter */
.tk-tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--tk-line); }
.tk-tabs__item { padding: 8px 12px; color: var(--tk-ink-2) !important; text-decoration: none !important; font-weight: 500; border-radius: 4px 4px 0 0; display: inline-flex; gap: 6px; align-items: center; }
.tk-tabs__item:hover { background: var(--tk-surface-2); color: var(--tk-ink) !important; }
.tk-tabs__item--active { color: var(--tk-ink) !important; box-shadow: inset 0 -2px 0 var(--tk-accent); }
.tk-tabs__count { font: 500 .7rem/1 var(--tk-f-mono); padding: 3px 6px; border-radius: 99px; background: var(--tk-surface-2); color: var(--tk-ink-3); }
.tk-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.tk-search { display: flex; gap: 6px; align-items: center; min-width: min(100%, 340px); }
.tk-search input { flex: 1; }

/* Verlauf */
.tk-timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.tk-timeline li { display: grid; grid-template-columns: 136px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--tk-line); }
.tk-timeline li:first-child { border-top: 0; padding-top: 0; }
.tk-timeline time { font: .75rem/1.5 var(--tk-f-mono); color: var(--tk-ink-3); }
.tk-timeline small { display: block; color: var(--tk-ink-3); }

/* Kopf einer Detailansicht */
.tk-subtitle { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--tk-ink-3); }
.tk-back { font-size: .8rem; color: var(--tk-ink-3) !important; text-decoration: none !important; }
.tk-back:hover { color: var(--tk-accent) !important; }
.tk-link-row { color: var(--tk-ink) !important; text-decoration: none !important; font-weight: 600; }
.tk-link-row:hover { color: var(--tk-accent) !important; }
.tk-span-2 { grid-column: 1 / -1; }

/* Übernommene Ansichten mit Bootstrap-Struktur (z. B. Monitor-Details) im Toolkit-Look */
.tk-legacy h2 { font: 500 .72rem/1.2 var(--tk-f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--tk-ink-3); margin: 12px 0 0; }
.tk-legacy .row { row-gap: var(--tk-gap); }
.tk-legacy .card { background: var(--tk-surface); border: 1px solid var(--tk-line); border-radius: var(--tk-r); box-shadow: none; }
.tk-legacy .card-header { background: none; border-bottom: 1px solid var(--tk-line); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--tk-f-display); }
.tk-legacy .tk-table-wrap { background: var(--tk-surface); border: 1px solid var(--tk-line); border-radius: var(--tk-r); }
.tk-legacy .tk-table th[scope="row"] { background: none; width: 40%; }
.tk-table--compact td, .tk-table--compact th { padding: 7px 12px; }
.tk-text-critical { color: var(--tk-bad); }

/* Auswahlbaum (z. B. ClickUp Space › Folder › Liste) */
.tk-tree, .tk-tree ul { list-style: none; margin: 0; padding: 0; }
.tk-tree ul { padding-left: 22px; border-left: 1px solid var(--tk-line); margin-left: 22px; }
.tk-tree > li { padding: 8px 12px; border-top: 1px solid var(--tk-line); }
.tk-tree > li:first-child { border-top: 0; }
.tk-tree__node { display: flex; gap: 10px; align-items: center; padding: 5px 8px; border-radius: 4px; cursor: pointer; margin: 0; }
.tk-tree__node:hover { background: var(--tk-surface-2); }
.tk-tree__node:has(input:checked) { background: var(--tk-source-soft); color: var(--tk-source); font-weight: 600; }
.tk-tree__node--used { cursor: not-allowed; opacity: .65; }
.tk-tree__level { font: 500 .68rem var(--tk-f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--tk-ink-3); width: 46px; flex: none; }
.tk-table tfoot td { background: var(--tk-surface-2); }

.tk-stack { display: grid; gap: var(--tk-gap); align-content: start; min-width: 0; }

/* Scores (0–100) */
.tk-score { display: inline-grid; place-items: center; min-width: 2.4em; padding: 3px 6px; border-radius: 4px; font: 600 .8rem var(--tk-f-mono); }
.tk-score--ok { background: var(--tk-ok-soft); color: var(--tk-ok); }
.tk-score--warning { background: var(--tk-warn-soft); color: var(--tk-warn); }
.tk-score--critical { background: var(--tk-bad-soft); color: var(--tk-bad); }

/* Befundlisten zum Aufklappen */
.tk-issues { display: grid; }
.tk-issue { border-top: 1px solid var(--tk-line); }
.tk-issue > summary { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 16px; cursor: pointer; list-style: none; }
.tk-issue > summary::-webkit-details-marker { display: none; }
.tk-issue > summary:hover { background: var(--tk-surface-2); }
.tk-issue[open] > summary { background: var(--tk-surface-2); }
.tk-issue__title { font-weight: 600; }
.tk-issue > ul, .tk-issue > dl, .tk-issue > p { margin: 0; padding: 10px 16px 14px 16px; }
.tk-issue > ul { list-style: none; display: grid; gap: 6px; }
.tk-code { margin: 6px 0 0; padding: 8px 10px; border-radius: 4px; background: var(--tk-surface-2); font: .75rem/1.5 var(--tk-f-mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Verlaufsdiagramm */
.tk-chart { width: 100%; height: auto; max-height: 260px; display: block; }
.tk-chart__grid { stroke: var(--tk-line); stroke-width: 1; }
.tk-chart__budget { stroke: var(--tk-ink-3); stroke-width: 1; stroke-dasharray: 4 4; }
.tk-chart__line { fill: none; stroke: var(--tk-accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.tk-chart__dot { fill: var(--tk-accent); }
.tk-chart__label { fill: var(--tk-ink-3); font: 12px var(--tk-f-mono); }
.tk-chart__value { fill: var(--tk-ink); font: 600 13px var(--tk-f-mono); }

.tk-kpi-link { color: inherit !important; text-decoration: none !important; display: grid; }
.tk-kpi-link:hover .tk-card { border-color: var(--tk-accent); }

/* Säulendiagramm */
.tk-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 160px; align-items: end; }
.tk-bars__col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 4px; min-width: 0; }
.tk-bars__track { display: flex; align-items: flex-end; border-bottom: 1px solid var(--tk-line); }
.tk-bars__bar { width: 100%; background: var(--tk-accent-soft); border-radius: 3px 3px 0 0; min-height: 1px; }
.tk-bars__bar--current { background: var(--tk-accent); }
.tk-bars__label { font: .68rem var(--tk-f-mono); color: var(--tk-ink-3); text-align: center; }

/* Mehrstufiger Assistent (z. B. Neues Projekt) */
.tk-wizard { display: grid; gap: var(--tk-gap); }
.tk-wizard [hidden] { display: none !important; }
.tk-stepper { display: flex; gap: 4px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.tk-stepper__item { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px 7px 7px; border: 1px solid var(--tk-line); border-radius: 99px; background: var(--tk-surface); color: var(--tk-ink-2); font: 500 .8rem/1 var(--tk-f-body); cursor: pointer; }
.tk-stepper__item:hover { border-color: var(--tk-accent); color: var(--tk-ink); }
.tk-stepper__number { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--tk-surface-2); font: 600 .72rem/1 var(--tk-f-mono); }
.tk-stepper__item--done .tk-stepper__number { background: var(--tk-accent-soft); color: var(--tk-accent); }
.tk-stepper__item--active { border-color: var(--tk-accent); color: var(--tk-ink); background: var(--tk-accent-soft); }
.tk-stepper__item--active .tk-stepper__number { background: var(--tk-accent); color: var(--tk-accent-ink); }
.tk-wizard__step { display: grid; gap: var(--tk-gap); }
.tk-wizard__group { display: grid; gap: 12px; }
.tk-wizard__heading { font: 600 .9rem/1.3 var(--tk-f-display); margin: 6px 0 0; }
.tk-wizard__nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--tk-bg) 30%); }
.tk-wizard__spacer { flex: 1; }
.tk-wizard__summary { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.tk-wizard__summary-block { display: grid; gap: 10px; align-content: start; padding: 14px; border: 1px solid var(--tk-line); border-radius: var(--tk-r); }
.tk-form { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.tk-field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.tk-field .form-label { margin: 0; font-weight: 500; }
.tk-field .form-text { margin: 0; color: var(--tk-ink-3); font-size: .78rem; }
.tk-field .invalid-feedback { display: block; }
.tk-field--wide { grid-column: 1 / -1; }
.tk-required { color: var(--tk-bad); }
.tk-choice { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.tk-choice__item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--tk-line); border-radius: var(--tk-r); cursor: pointer; margin: 0; }
.tk-choice__item:hover { border-color: var(--tk-accent); }
.tk-choice__item:has(input:checked) { border-color: var(--tk-accent); background: var(--tk-accent-soft); }
.tk-choice__item input { margin-top: 3px; }
.tk-choice__item span { display: grid; gap: 2px; }
.tk-choice__item small { color: var(--tk-ink-3); }
.tk-switch { display: flex; gap: 10px; align-items: flex-start; margin: 0; }
.tk-switch .form-check-input { margin: 2px 0 0; flex: none; }
.tk-switch span { display: grid; gap: 2px; }
.tk-switch small { color: var(--tk-ink-3); }
.tk-checks { display: grid; gap: 6px; }

/* Einrichtungsstand in der Projektansicht */
.tk-setup { display: grid; margin: 0; padding: 0; list-style: none; }
.tk-setup__item { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--tk-line); }
.tk-setup__item:first-child { border-top: 0; padding-top: 0; }
.tk-setup__item small { grid-column: 2; color: var(--tk-ink-3); }
.tk-setup__item .tk-check { grid-row: span 2; }
.tk-setup__item form, .tk-setup__item .tk-setup__action { grid-row: span 2; grid-column: 3; }
.tk-check--open { border-color: var(--tk-warn); }
