/* ═══════════════════════════════════════════════════════════════════════
   CONFIG-FORM FRAMEWORK + allgemeine UI-Utilities
   ───────────────────────────────────────────────────────────────────────
   Zentrale Styles (global eingebunden via templates/includes/base.html).

   Config-Form-Kern:
   • .cfg-tabs           → Tab-Navigation (Hash-URL-sync, Keyboard)
   • .cfg-grid           → 2-Spalten-Grid für Karten
   • .cfg-card(-header/-body/-actions) → Karte, Title links, Help-Icon IMMER rechts
   • .cfg-field          → Standard-Formularfelder (Label + Input/Select/Textarea)
   • .cfg-toggle         → Toggle-Switch-Zeile im Body (Label links · Switch rechts)
   • .cfg-toggle-switch  → Reiner Switch (auch standalone nutzbar)
   • .cfg-check-row      → Check-Zeile (Toggle links · Threshold-Inputs rechts)
   • .cfg-help-modal     → Zentriertes Help-Popup (Glass-Backdrop, modern)
   • .cfg-saving-indicator → Dezenter Auto-Save-Status (bottom-left)
   • .cfg-help-btn       → Help-Icon (rund, Fragezeichen) in Card-Header
   • .cfg-card-action-btn → Sekundärer Action-Button im Card-Header (z. B. „Berechnen")

   Wiederverwendbare UI-Utilities (nicht Config-spezifisch, aber hier gebündelt):
   • .kw-pill + Varianten --green/--red/--orange/--blue/--gray/--primary
                         → Farbige Status-Bubbles (200/404/Ja/Nein/…)
                         Single Source of Truth — keyword-set.css referenziert nur noch.
   • .rules-table, .rule-type-badge--include/--exclude,
     .rule-add-row, .rule-add-btn, .rule-delete-btn
                         → DnD-Regel-Tabellen (Priorisierungs-Regeln, URL-Regeln, …)
   • .preview-stat, .preview-rule-row
                         → Live-Preview-Panels (z. B. Regel-Treffer-Vorschau)
   ═══════════════════════════════════════════════════════════════════════ */


/* ── TAB NAVIGATION ────────────────────────────────────────────────── */
.cfg-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background: hsl(var(--muted) / 0.4);
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 2px);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.cfg-tab-btn {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid transparent;
    border-radius: calc(var(--radius));
    background: transparent;
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cfg-tab-btn i { font-size: 0.75rem; opacity: 0.8; }

.cfg-tab-btn:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--background) / 0.6);
}

.cfg-tab-btn.is-active {
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    border-color: hsl(var(--border));
    box-shadow: 0 1px 2px hsl(var(--foreground) / 0.04);
}

.cfg-tab-btn.is-active i { opacity: 1; color: hsl(var(--primary)); }

.cfg-tab-panel { display: none; }
.cfg-tab-panel.is-active { display: block; }

@media (max-width: 720px) {
    .cfg-tabs { flex-wrap: wrap; }
    .cfg-tab-btn { flex: 1 1 45%; }
}


/* ── GRID ──────────────────────────────────────────────────────────── */
.cfg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

.cfg-grid > .cfg-card--full { grid-column: 1 / -1; }

@media (max-width: 900px) {
    .cfg-grid { grid-template-columns: 1fr; }
}


/* ── CARD ──────────────────────────────────────────────────────────── */
.cfg-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cfg-card:focus-within {
    border-color: hsl(var(--border));
    box-shadow: 0 1px 3px hsl(var(--foreground) / 0.05);
}

.cfg-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid hsl(var(--border) / 0.7);
    background: hsl(var(--muted) / 0.25);
}

.cfg-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    min-width: 0;
}

.cfg-card-title > i {
    color: hsl(var(--primary));
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.cfg-card-title-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cfg-card-subtitle {
    font-size: 0.6875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-left: 0.25rem;
}

.cfg-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cfg-card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cfg-card-body--flush { padding: 0; }


/* ── HELP ICON (IMMER rechts im Header) ────────────────────────────── */
.cfg-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid hsl(var(--border));
    border-radius: 50%;
    background: hsl(var(--background));
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.cfg-help-btn:hover {
    color: hsl(var(--primary));
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.06);
    transform: translateY(-1px);
}

.cfg-help-btn:focus-visible {
    outline: 2px solid hsl(var(--primary) / 0.35);
    outline-offset: 2px;
}

.cfg-help-btn i { font-size: 0.75rem; }


/* ── TOGGLE-SWITCH im Header rechts ────────────────────────────────── */
.cfg-toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    width: 2.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.cfg-toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.cfg-toggle-switch-slider {
    position: absolute;
    inset: 0;
    background: hsl(var(--muted-foreground) / 0.35);
    border-radius: 1rem;
    transition: background 0.2s ease;
}

.cfg-toggle-switch-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.25rem - 4px);
    height: calc(1.25rem - 4px);
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.cfg-toggle-switch input:checked + .cfg-toggle-switch-slider {
    background: hsl(var(--primary));
}

.cfg-toggle-switch input:checked + .cfg-toggle-switch-slider::before {
    transform: translateX(1rem);
}

.cfg-toggle-switch input:focus-visible + .cfg-toggle-switch-slider {
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.3);
}


/* ── TOGGLE-ZEILE im Body (Label links · Switch rechts) ────────────── */
.cfg-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: hsl(var(--muted) / 0.3);
    border: 1px solid hsl(var(--border) / 0.6);
    border-radius: calc(var(--radius) - 2px);
}

.cfg-toggle--prominent {
    background: hsl(var(--primary) / 0.04);
    border-color: hsl(var(--primary) / 0.25);
}

.cfg-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.cfg-toggle-label-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.cfg-toggle-label-hint {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.4;
}

/* ── DISABLED + LOCK-PILL ─────────────────────────────────────────── */
.cfg-toggle.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: hsl(var(--muted) / 0.18);
}

.cfg-toggle.is-disabled .cfg-toggle-switch { cursor: not-allowed; pointer-events: none; }

.cfg-toggle-lock-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: hsl(var(--muted-foreground) / 0.12);
    color: hsl(var(--muted-foreground));
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
}

.cfg-toggle-lock-pill i { font-size: 0.625rem; }


/* ── PERMISSION APP-CARD (App + Sub-Features) ─────────────────────── */
.perm-app-card { display: flex; flex-direction: column; gap: 0; }

.perm-app-card .cfg-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.perm-app-card.is-locked {
    opacity: 0.7;
}

.perm-app-card.is-app-off .perm-feature-list {
    opacity: 0.55;
    pointer-events: none;
    filter: grayscale(0.4);
}

.perm-feature-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-left: 0.75rem;
    margin-top: 0.25rem;
    border-left: 2px solid hsl(var(--border) / 0.6);
    transition: opacity 0.15s ease, filter 0.15s ease;
}

.perm-feature-list-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.1rem;
}

.perm-app-card .perm-app-locked-hint {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.perm-app-card .perm-app-locked-hint i { color: hsl(var(--muted-foreground) / 0.7); }


/* ── FORM FIELDS (Label + Input/Select/Textarea) ───────────────────── */
.cfg-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.cfg-field-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    letter-spacing: 0.01em;
}

.cfg-field-label-hint {
    font-size: 0.6875rem;
    font-weight: 400;
    color: hsl(var(--muted-foreground));
}

.cfg-field-hint {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.5;
    margin: 0;
}

.cfg-field-hint i { font-size: 0.625rem; margin-right: 0.25rem; }

.cfg-field-error {
    font-size: 0.6875rem;
    color: hsl(var(--destructive));
    line-height: 1.4;
}

.cfg-input,
.cfg-select,
.cfg-textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.8125rem;
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    box-sizing: border-box;
}

.cfg-input,
.cfg-select {
    height: 2.125rem;
    padding: 0 0.625rem;
}

.cfg-textarea {
    padding: 0.5rem 0.625rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 4rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
}

.cfg-input:hover,
.cfg-select:hover,
.cfg-textarea:hover { border-color: hsl(var(--foreground) / 0.25); }

.cfg-input:focus,
.cfg-select:focus,
.cfg-textarea:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
    background: hsl(var(--background));
}

.cfg-field--saved .cfg-input,
.cfg-field--saved .cfg-select,
.cfg-field--saved .cfg-textarea {
    animation: cfg-field-saved-flash 0.8s ease;
}

@keyframes cfg-field-saved-flash {
    0%   { box-shadow: 0 0 0 0 hsl(142 70% 45% / 0); border-color: hsl(var(--input)); }
    30%  { box-shadow: 0 0 0 3px hsl(142 70% 45% / 0.25); border-color: hsl(142 70% 45%); }
    100% { box-shadow: 0 0 0 0 hsl(142 70% 45% / 0); }
}

/* 2-Col-Gridded row inside body */
.cfg-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.cfg-row--3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 520px) {
    .cfg-row,
    .cfg-row--3 { grid-template-columns: 1fr; }
}


/* ── HELP MODAL (zentral, modern, glass) ───────────────────────────── */
.cfg-help-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.cfg-help-modal.is-open { display: flex; }

.cfg-help-modal-backdrop {
    position: absolute;
    inset: 0;
    background: hsl(var(--background) / 0.55);
    backdrop-filter: blur(6px) saturate(140%);
    -webkit-backdrop-filter: blur(6px) saturate(140%);
    animation: cfg-help-backdrop-in 0.18s ease;
}

.cfg-help-modal-panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    box-shadow:
        0 1px 2px hsl(var(--foreground) / 0.04),
        0 24px 48px -12px hsl(var(--foreground) / 0.18),
        0 4px 16px -4px hsl(var(--foreground) / 0.1);
    animation: cfg-help-panel-in 0.22s cubic-bezier(0.2, 0, 0, 1);
    overflow: hidden;
}

.cfg-help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem 0.75rem;
}

.cfg-help-modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.cfg-help-modal-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    font-size: 0.8125rem;
}

.cfg-help-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.cfg-help-modal-close:hover { color: hsl(var(--foreground)); background: hsl(var(--muted) / 0.6); }

.cfg-help-modal-body {
    padding: 0.25rem 1.25rem 1.25rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: hsl(var(--foreground) / 0.85);
    overflow-y: auto;
}

.cfg-help-modal-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    padding: 0.0625rem 0.375rem;
    border-radius: 3px;
    background: hsl(var(--muted) / 0.6);
    color: hsl(var(--foreground));
}

.cfg-help-modal-body strong { color: hsl(var(--foreground)); font-weight: 600; }

.cfg-help-modal-body p { margin: 0 0 0.75rem; }
.cfg-help-modal-body p:last-child { margin-bottom: 0; }


@keyframes cfg-help-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes cfg-help-panel-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}


/* ── AUTO-SAVE STATUS (dezent, optional) ───────────────────────────── */
.cfg-saving-indicator {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    box-shadow: 0 1px 2px hsl(var(--foreground) / 0.04);
    z-index: 8500;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.cfg-saving-indicator.is-visible { opacity: 1; transform: translateY(0); }

.cfg-saving-indicator i { font-size: 0.6875rem; }


/* ── CHECK-ROW (Toggle + optionale Threshold-Inputs rechts) ────────── */
.cfg-check-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cfg-check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    min-height: 2.5rem;
    transition: background-color 0.12s ease;
}

.cfg-check-row:hover { background: hsl(var(--muted) / 0.4); }

.cfg-check-row-toggle {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
}

.cfg-check-row-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.cfg-check-row-fields {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.cfg-check-row-field {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cfg-check-row-field label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.cfg-check-row-field input {
    width: 6.75rem;
    height: 2rem;
    padding: 0 0.625rem;
    font-size: 0.875rem;
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cfg-check-row-field input:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
}

@media (max-width: 640px) {
    .cfg-check-row { flex-wrap: wrap; }
    .cfg-check-row-fields { width: 100%; padding-left: 2.5rem; }
}


/* ── RULES-TABLE (Priorisierungs-Regeln u. ä. Listen mit DnD) ──────── */
.rules-table {
    width: 100%;
    border-collapse: collapse;
}

.rules-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: hsl(var(--muted-foreground));
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--muted) / 0.25);
}

.rules-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid hsl(var(--border) / 0.3);
    vertical-align: middle;
    font-size: 0.8125rem;
}

.rules-table tr:last-child td { border-bottom: none; }
.rules-table tr:hover { background: hsl(var(--muted) / 0.3); }

.rules-table .drag-handle {
    cursor: grab;
    color: hsl(var(--muted-foreground) / 0.5);
    width: 30px;
}

.rules-table .drag-handle:active { cursor: grabbing; }
.rules-table tr.dragging { opacity: 0.4; }

.rule-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.rule-type-badge--include {
    background: hsl(142 71% 45% / 0.12);
    color: hsl(142 71% 45%);
}

.rule-type-badge--exclude {
    background: hsl(0 84% 60% / 0.12);
    color: hsl(0 84% 60%);
}

.rule-add-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid hsl(var(--border));
    background: hsl(var(--muted) / 0.2);
    flex-wrap: wrap;
}

.rule-add-row .cfg-input,
.rule-add-row .cfg-select { height: 2rem; }

.rule-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: 2rem;
    padding: 0 0.75rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.rule-add-btn:hover { background: hsl(var(--primary) / 0.88); }

.rule-delete-btn {
    background: transparent;
    border: none;
    padding: 0.25rem;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    font-size: 0.75rem;
    border-radius: calc(var(--radius) - 4px);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.rule-delete-btn:hover {
    color: hsl(var(--destructive));
    background: hsl(var(--destructive) / 0.08);
}


/* ── STATUS-/STATE-PILLS (schöne farbige Bubbles) ──────────────────── */
.kw-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.1875rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.kw-pill--green   { background: hsl(142 71% 45% / 0.14); color: hsl(142 76% 30%); }
.kw-pill--red     { background: hsl(0 84% 60% / 0.14);   color: hsl(0 84% 45%);  }
.kw-pill--orange  { background: hsl(38 92% 50% / 0.15);  color: hsl(30 90% 38%); }
.kw-pill--blue    { background: hsl(217 91% 60% / 0.14); color: hsl(217 91% 48%); }
.kw-pill--gray    { background: hsl(var(--muted));       color: hsl(var(--muted-foreground)); }
.kw-pill--primary { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); }

[data-theme='dark'] .kw-pill--green  { color: hsl(142 76% 60%); }
[data-theme='dark'] .kw-pill--red    { color: hsl(0 84% 70%); }
[data-theme='dark'] .kw-pill--orange { color: hsl(38 92% 65%); }
[data-theme='dark'] .kw-pill--blue   { color: hsl(217 91% 72%); }


/* ── PREVIEW-Panel (Stats + Treffer pro Regel) ─────────────────────── */
.preview-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.8125rem;
}

.preview-stat-label { color: hsl(var(--muted-foreground)); }
.preview-stat-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.preview-rule-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.625rem;
    margin: 0.25rem 0;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.8125rem;
    background: hsl(var(--foreground) / 0.02);
}


/* ── CARD-HEADER ACTION-BUTTON (z. B. „Berechnen") ─────────────────── */
.cfg-card-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: 1.75rem;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.cfg-card-action-btn:hover {
    border-color: hsl(var(--primary));
    color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.04);
}


/* ── FIELD-Groups & Utility ────────────────────────────────────────── */
.cfg-card-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(var(--muted-foreground));
    margin: 0 0 0.375rem;
}

.cfg-divider {
    height: 1px;
    background: hsl(var(--border) / 0.6);
    margin: 0.125rem 0;
}
