/* KNX Home Assistant – exakt nach Mockup-Vorgaben */
.kha-root { max-width: 1200px; margin: 0 auto; padding: 24px 16px 80px; }

/* ===== Schrittanzeige ===== */
.kha-steps {
    display: flex; align-items: center; margin-bottom: 28px;
}
.kha-step {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; color: var(--muted, #999); cursor: pointer; white-space: nowrap;
}
.kha-step-active { color: var(--fg, #222); font-weight: 600; }
.kha-step-done { color: var(--accent, #2563eb); }
.kha-step-num {
    width: 26px; height: 26px; border-radius: 50%; border: 1px solid currentColor;
    display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.kha-step-active .kha-step-num { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; }
.kha-step-done .kha-step-num { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; }
.kha-step-line { flex: 1; height: 1px; background: var(--line, #ddd); margin: 0 10px; }
.kha-step-line-done { background: var(--accent, #2563eb); }

/* ===== Karte ===== */
.kha-card {
    border: 1px solid var(--line, #e0e0e0);
    border-radius: 12px; padding: 24px 28px;
}
.kha-card-title { font-size: 17px; font-weight: 600; margin: 0 0 18px; }
.kha-subtitle { font-size: 13px; color: var(--muted, #888); margin: -10px 0 16px; }
.kha-group-label {
    font-size: 11px; color: var(--muted, #888);
    text-transform: uppercase; letter-spacing: 0.7px;
    margin: 20px 0 8px; border-bottom: 1px solid var(--line, #eee); padding-bottom: 4px;
}
.kha-sub-h { font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.kha-nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }

/* ===== Formular ===== */
.kha-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kha-field { display: flex; flex-direction: column; gap: 4px; }
.kha-field-full { grid-column: 1 / -1; }
.kha-field label { font-size: 11.5px; color: var(--muted, #888); }
.kha-field input, .kha-field select, .kha-field textarea {
    border: 1px solid var(--line, #ddd); border-radius: 6px;
    padding: 8px 10px; font-size: 13.5px; background: var(--panel, #fff);
    width: 100%; box-sizing: border-box;
}
.kha-field textarea { resize: vertical; }

/* ===== Topologie-Kacheln ===== */
.kha-topo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.kha-topo-card {
    border: 1px solid var(--line, #e0e0e0); border-radius: 8px;
    padding: 14px 16px; cursor: pointer; transition: border-color 0.15s;
}
.kha-topo-card strong { font-size: 13.5px; display: block; margin-bottom: 4px; }
.kha-topo-card p { font-size: 12px; color: var(--muted, #888); margin: 0; }
.kha-topo-card:hover { border-color: var(--accent, #2563eb); }
.kha-topo-active {
    border: 2px solid var(--accent, #2563eb);
    background: var(--accent-soft, #eff6ff);
}
.kha-topo-active strong { color: var(--accent, #2563eb); }

/* ===== Funktionsbausteine ===== */
.kha-feature-group {
    border: 1px solid var(--line, #e0e0e0); border-radius: 8px;
    margin-bottom: 8px; overflow: hidden;
}
.kha-feature-group summary {
    padding: 11px 16px; font-size: 13.5px; font-weight: 500;
    cursor: pointer; display: flex; justify-content: space-between;
    align-items: center; list-style: none; transition: background .12s;
}
.kha-feature-group summary:hover { background: var(--row-hover, rgba(0,0,0,.04)); }
.kha-feature-group summary::-webkit-details-marker { display: none; }
.kha-feature-group summary::before {
    content: '\276F'; display: inline-block; margin-right: 10px; font-size: 11px;
    transition: transform .15s ease; color: var(--muted, #888); flex-shrink: 0;
}
.kha-feature-group[open] summary::before { transform: rotate(90deg); }
.kha-feature-group-body { padding: 0 16px 16px; }
.kha-active-count { font-size: 11.5px; color: var(--accent, #2563eb); }

/* Formular-Design: Checkbox + zugehoeriges Detail bleiben in EINER Karte
   zusammen (kein "Hin- und Herspringen" zwischen Checkbox-Raster oben und
   einer separaten Detail-Liste weiter unten wie frueher). */
.kha-feature-list { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-top: 1px solid var(--line, #e0e0e0); }
.kha-feature-card { border: 1px solid var(--line, #e0e0e0); border-radius: 6px; overflow: hidden; transition: border-color .12s; }
.kha-feature-card-on { border-color: var(--accent, #2563eb); }
.kha-feature-card-group { background: var(--paper, #f7faf4); }
.kha-feature-card-grouplabel { margin: 0; padding: 8px 14px 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted, #888); }
.kha-feature-item-full {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; font-size: 13px; cursor: pointer;
}
.kha-feature-item-full input { margin: 0; flex-shrink: 0; }
.kha-feature-detail-inline {
    display: flex; gap: 14px; flex-wrap: wrap;
    padding: 10px 14px; border-top: 1px solid var(--line, #e0e0e0);
    background: var(--paper, #f7faf4);
}
.kha-feature-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer;
}
.kha-feature-item input { margin: 0; flex-shrink: 0; }

/* ===== Gebäude / Haus ===== */
.kha-building-wrap { position: relative; filter: drop-shadow(0 3px 8px rgba(0,0,0,.15)); }

/* ===== Zweispaltiges Layout: Raeume links (vertikale Liste), Details rechts ===== */
.kha-split-layout { display: flex; gap: 18px; align-items: flex-start; }
.kha-split-left { flex: 0 0 300px; min-width: 260px; max-width: 340px; }
.kha-split-right { flex: 1 1 auto; min-width: 0; position: sticky; top: 12px; }
.kha-split-right-hint {
    border: 1px dashed var(--line, #e0e0e0); border-radius: 8px;
    padding: 24px; text-align: center; color: var(--muted, #888); font-size: 13px;
}
@media (max-width: 900px) {
    .kha-split-layout { flex-direction: column; }
    .kha-split-left { flex: 1 1 auto; max-width: none; }
    .kha-split-right { position: static; }
}

/* ===== Schnellzugriff-Leiste (unterhalb des Raumnamens) ===== */
.kha-quickbar {
    border: 1px solid var(--line, #e0e0e0); border-radius: 8px;
    padding: 12px 14px; margin: 10px 0 16px; background: var(--panel, #fff);
}
.kha-quickbar-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.kha-quickbar-head-clickable { cursor: pointer; margin-bottom: 0; }
.kha-quickbar-toggle {
    background: none; border: 1px solid var(--line, #ccc); border-radius: 999px;
    padding: 2px 10px; font-size: 11px; color: var(--muted, #888); cursor: pointer;
}
.kha-quickbar-toggle:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.kha-quickbar-title { font-weight: 600; font-size: 13.5px; }
.kha-quickbar-hint { font-size: 11px; color: var(--muted, #888); }
.kha-quickbar-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 6px; margin-top: 8px;
}
.kha-quick-tile {
    position: relative; border: 1px solid var(--line, #e0e0e0); border-radius: 6px;
    padding: 8px 4px 6px; text-align: center; cursor: pointer; user-select: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    transition: border-color .12s, background .12s;
}
.kha-quick-tile:hover { border-color: var(--accent, #2563eb); }
.kha-quick-tile-on { border-color: var(--accent, #2563eb); background: var(--row-hover, rgba(37,99,235,.06)); }
.kha-quick-ico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.kha-quick-lbl { font-size: 10px; font-weight: 500; line-height: 1.15; }
.kha-quick-count {
    position: absolute; top: 2px; right: 4px; font-size: 10px; font-weight: 700;
    color: var(--accent, #2563eb); background: var(--panel, #fff); border-radius: 8px; padding: 0 3px;
}
.kha-quick-minus {
    position: absolute; top: 2px; right: 18px; background: none; border: none;
    font-size: 12px; font-weight: 700; color: var(--error, #e00); cursor: pointer; padding: 0; line-height: 1;
}
.kha-quick-minus:hover { color: #ff0000; }
.kha-quick-fav {
    position: absolute; top: 2px; left: 3px; background: none; border: none;
    font-size: 11px; color: var(--line, #ccc); cursor: pointer; padding: 0; line-height: 1;
}
.kha-quick-fav-on { color: #d1495b; }
.kha-quick-fav:hover { color: #d1495b; }

/* Kompaktere Variante - Position unterhalb der Raeume/Etagen */
.kha-quickbar-sm { padding: 8px 10px; margin-bottom: 12px; }
.kha-quickbar-sm .kha-quickbar-title { font-size: 12px; }
.kha-quickbar-sm .kha-quickbar-hint { font-size: 10px; }
.kha-quickbar-sm .kha-quickbar-grid { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 4px; margin-top: 6px; }
.kha-quickbar-sm .kha-quick-tile { padding: 4px 2px 3px; }
.kha-quickbar-sm .kha-quick-ico svg { width: 14px; height: 14px; }
.kha-quickbar-sm .kha-quick-lbl { font-size: 8px; }
.kha-roof { display: block; width: 100%; margin-bottom: -2px; }
.kha-roof svg { width: 100%; height: 60px; display: block; }
.kha-foundation { height: 11px; background: var(--pine,#64748b); border-radius: 0 0 6px 6px; margin-top: -1px; }
.kha-floors-stack { display: flex; flex-direction: column; }

.kha-floor-block {
    border: 2px solid var(--pine, #64748b);
    border-top: none; padding: 8px 12px;
}
.kha-floor-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.kha-floor-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kha-floor-btn { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--muted, #aaa); padding: 2px 4px; }
.kha-floor-del { color: #e00; }
.kha-rename-inp { font-size: 13px; font-weight: 600; border: 1px solid var(--accent, #2563eb); border-radius: 4px; padding: 2px 8px; }

.kha-room-grid-b {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
}
.kha-room-tile {
    position: relative; border: 1px solid var(--line, #e0e0e0); border-radius: 4px;
    padding: 6px 34px 6px 8px; text-align: left; cursor: pointer; min-height: unset;
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px;
    transition: border-color 0.12s;
}
.kha-room-tile:hover { border-color: var(--accent, #2563eb); }
.kha-room-sel { border: 2px solid var(--accent, #2563eb); }
.kha-room-ico svg { width: 16px; height: 16px; stroke: currentColor; fill: none; flex-shrink: 0; }
.kha-room-lbl { font-size: 12px; font-weight: 500; line-height: 1.15; flex: 1; text-align: left; }
.kha-room-star { margin-left: auto; margin-right: 4px; }
.kha-room-x {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%); background: none; border: none;
    font-size: 10px; color: #ccc; cursor: pointer; padding: 0; line-height: 1;
}
.kha-room-x:hover { color: #e00; }
.kha-room-pen {
    position: absolute; top: 3px; left: 4px; background: none; border: none;
    font-size: 10px; color: #ccc; cursor: pointer; padding: 0; line-height: 1;
}
.kha-room-dots { display: flex; gap: 3px; }
.kha-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent, #2563eb); }

.kha-room-add {
    border: 1px dashed var(--line, #ccc); border-radius: 4px;
    min-height: unset; padding: 6px 8px; display: flex; flex-direction: row;
    align-items: center; justify-content: flex-start; gap: 8px;
    cursor: pointer; color: var(--muted, #999); font-size: 12px;
}
.kha-room-add:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.kha-room-add-plus { font-size: 16px; line-height: 1; }
.kha-more-btn { background: none; border: none; color: var(--accent, #2563eb); font-size: 12px; cursor: pointer; margin-top: 8px; }

.kha-add-floor-btn {
    display: flex; justify-content: center; align-items: center; height: 28px; cursor: pointer;
}
.kha-add-floor-btn span {
    width: 28px; height: 28px; background: var(--panel, #fff); border: 1px solid var(--line, #ccc);
    border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.kha-add-floor-btn span:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }

.kha-floor-empty { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.kha-floor-preset {
    border: 1px dashed var(--line, #ccc); border-radius: 6px;
    padding: 14px 16px; text-align: center; cursor: pointer; font-size: 13px; color: var(--muted, #888);
}
.kha-floor-preset:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }


/* ===== Raum-Picker ===== */
.kha-picker-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center; z-index: 200;
}
.kha-picker-box {
    background: var(--panel, #fff); border-radius: 12px;
    padding: 20px 22px; width: 460px; max-height: 70vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.kha-picker-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px; font-size: 14px; font-weight: 600;
}
.kha-picker-head button { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted, #888); }
.kha-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kha-picker-item {
    border: 1px solid var(--line, #e0e0e0); border-radius: 6px;
    padding: 10px 6px 8px; text-align: center; cursor: pointer; font-size: 11.5px;
}
.kha-picker-item:hover { border-color: var(--accent, #2563eb); }
.kha-picker-item { position: relative; }
.kha-picker-item-checked { border-color: var(--accent, #2563eb); background: var(--accent-soft, rgba(37,99,235,.08)); }
.kha-picker-check { position: absolute; top: 4px; left: 4px; cursor: pointer; }
.kha-picker-check input { margin: 0; cursor: pointer; }
.kha-picker-ico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; margin-bottom: 4px; }
.kha-picker-custom { display: flex; gap: 8px; }
.kha-picker-custom input { flex: 1; }

/* ===== Live-GA-Vorschau (Grundausstattungs-Dialog) ===== */
.kha-ga-preview { border-top: 1px dashed var(--line, #e0e0e0); padding-top: 10px; }
.kha-ga-preview-list { list-style: none; margin: 0; padding: 0; max-height: 160px; overflow-y: auto; }
.kha-ga-preview-list li { font-size: 12px; padding: 3px 0; color: var(--muted, #888); }
.kha-ga-preview-list li code { color: var(--fg, #222); font-weight: 600; margin-right: 6px; }
.kha-ga-preview-more { font-style: italic; }

/* ===== Raum-Detailansicht ===== */
.kha-room-detail {
    border: 1px solid var(--accent, #2563eb); border-radius: 10px;
    padding: 18px 22px; margin-top: 20px;
}
.kha-room-detail-head { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 12px; flex-wrap: wrap; }

.kha-room-summary { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 14px; }
.kha-room-summary-chip {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--line, #e0e0e0); border-radius: 999px;
    padding: 3px 10px 3px 6px; font-size: 12px; background: var(--paper, #f7faf4);
}
.kha-room-summary-ico svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }
.kha-room-name-edit { display: flex; align-items: center; gap: 8px; }
.kha-room-title-inp {
    font-size: 15px; font-weight: 600; border: none; border-bottom: 1px solid var(--line, #ddd);
    background: none; padding: 2px 4px; min-width: 140px;
}
.kha-stars-row { display: flex; align-items: center; gap: 4px; }
.kha-star { background: none; border: none; cursor: pointer; font-size: 22px; color: #ddd; padding: 0; line-height: 1; }
.kha-star-on { color: #ff8c00; }
.kha-star-lbl { font-size: 12px; color: var(--muted, #888); margin-left: 6px; }

/* Tabs (4 Reiter) */
.kha-tabs { display: flex; border-bottom: 1px solid var(--line, #e0e0e0); margin-bottom: 16px; }
.kha-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    padding: 9px 16px; font-size: 13px; cursor: pointer; color: var(--muted, #888);
    display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.kha-tab-on { color: #ff8c00; border-bottom-color: #ff8c00; font-weight: 600; }
.kha-tab:hover:not(.kha-tab-on) { color: var(--fg, #444); }

/* Stepper-Karten (Details + Sicherheit) - responsiv: mehr Spalten bei mehr Platz statt fixer 2-Spalten-Tabelle */
.kha-stepper-table {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 6px; margin-bottom: 4px;
}
.kha-stepper-row {
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
    padding: 7px 10px; border: 1px solid var(--line, #e0e0e0); border-radius: 6px;
}
.kha-stepper-row-clickable { cursor: pointer; transition: border-color .12s, background .12s; }
.kha-stepper-row-clickable:hover { border-color: var(--accent, #2563eb); background: var(--row-hover, rgba(37,99,235,.05)); }
.kha-stepper-row-on { border-color: var(--accent, #2563eb); }
.kha-stepper-led {
    background: none; border: none; cursor: pointer; font-size: 13px; padding: 0;
    line-height: 1; opacity: .3; filter: grayscale(1); flex-shrink: 0;
}
.kha-stepper-led:disabled { cursor: default; opacity: .15; }
.kha-stepper-led-on { opacity: 1; filter: none; }
.kha-stepper-ico-sm svg { width: 14px; height: 14px; stroke: currentColor; fill: none; flex-shrink: 0; }
.kha-stepper-lbl { flex: 1; font-size: 12px; min-width: 70px; }
.kha-stepper-pill {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border-strong, #ccc); border-radius: 999px;
    padding: 2px 8px;
}
.kha-stepper-pill button { background: none; border: none; cursor: pointer; font-size: 13px; padding: 0; line-height: 1; color: var(--fg, #333); }
.kha-stepper-pill button:hover { color: var(--accent, #2563eb); }
.kha-stepper-pill span { min-width: 14px; text-align: center; font-weight: 600; font-size: 12px; }
.kha-variant-sm { font-size: 11.5px; margin-top: 4px; width: 100%; border-radius: 4px; }

/* Produktkarten (Bedienung) */
.kha-product-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.kha-product-card {
    position: relative; border: 1px solid var(--line, #e0e0e0); border-radius: 8px;
    padding: 14px 10px; text-align: center;
}
.kha-product-on { border: 2px solid var(--accent, #2563eb); }
.kha-product-img { height: 56px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.kha-product-img svg { width: 28px; height: 28px; stroke: currentColor; fill: none; }
.kha-product-name { font-size: 12px; margin: 0 0 8px; line-height: 1.3; }
.kha-product-led {
    position: absolute; top: 5px; right: 6px; background: none; border: none;
    font-size: 13px; cursor: pointer; padding: 0; line-height: 1; opacity: .3;
    filter: grayscale(1);
}
.kha-product-led:disabled { cursor: default; opacity: .15; }
.kha-product-led-on { opacity: 1; filter: none; }

/* Toggle-Zeilen (Komfort) */
.kha-toggle-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    border: 1px solid var(--line, #e0e0e0);
}
.kha-toggle-row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; font-size: 13px; cursor: pointer;
    border-right: 1px solid var(--line, #e0e0e0);
    border-bottom: 1px solid var(--line, #e0e0e0);
}
.kha-toggle-row:nth-child(even) { border-right: none; }
.kha-toggle-on { background: var(--accent-soft, #eff6ff); color: var(--accent, #2563eb); }
.kha-check-ico { margin-left: auto; }

/* ===== Ergebnis ===== */
.kha-result-summary {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; margin-bottom: 16px;
}
.kha-result-tile {
    border: 1px solid var(--line, #e0e0e0); border-radius: 8px;
    padding: 12px; text-align: center;
}
.kha-result-tile strong { display: block; font-size: 22px; font-weight: 700; }
.kha-result-tile span { font-size: 11.5px; color: var(--muted, #888); }
.kha-result-ico { display: block; margin: 0 auto 4px; width: fit-content; color: var(--accent, #2563eb); }
.kha-result-ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.kha-result-tile-accent .kha-result-ico { color: var(--accent-strong, #2563eb); }

/* Kacheln farblich unterscheiden - dieselbe Palette wie die Gewerk-Farben in der Baumansicht */
.kha-tile-c1 { border-color: #64748b40; } .kha-tile-c1 .kha-result-ico { color: #64748b; }
.kha-tile-c2 { border-color: #3FA86E40; } .kha-tile-c2 .kha-result-ico { color: #3FA86E; }
.kha-tile-c3 { border-color: #9155c440; } .kha-tile-c3 .kha-result-ico { color: #9155c4; }
.kha-tile-c4 { border-color: #2f9e8f40; } .kha-tile-c4 .kha-result-ico { color: #2f9e8f; }
.kha-tile-c5 { border-color: #d1683f40; } .kha-tile-c5 .kha-result-ico { color: #d1683f; }
.kha-tile-c6 { border-color: #4d8fd140; } .kha-tile-c6 .kha-result-ico { color: #4d8fd1; }
.kha-tile-c7 { border-color: #c9932a40; } .kha-tile-c7 .kha-result-ico { color: #c9932a; }
.kha-tile-c8 { border-color: #c4514f40; } .kha-tile-c8 .kha-result-ico { color: #c4514f; }
@media (max-width: 560px) {
    .kha-result-summary, .kha-export-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Export-Buttons (Schritt 5) ===== */
.kha-export-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; margin: 4px 0 20px;
}
.kha-export-btn {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
    grid-template-areas: "icon label" "icon sub";
    column-gap: 12px; row-gap: 2px; align-items: center;
    border: 1px solid var(--line, #e0e0e0); border-radius: 8px;
    padding: 12px 14px; background: var(--panel, #fff); color: var(--fg, #222);
    cursor: pointer; text-align: left; font: inherit; width: 100%;
    transition: border-color .15s, background .15s, transform .1s;
}
.kha-export-btn:hover { border-color: var(--accent, #2563eb); background: var(--row-hover, #f2f6ff); }
.kha-export-btn:active { transform: scale(0.98); }
.kha-export-btn:disabled { opacity: .55; cursor: default; pointer-events: none; }
.kha-export-icon {
    grid-area: icon; align-self: center; width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; background: var(--muted, #888); color: #fff;
}
.kha-export-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.kha-export-label { grid-area: label; font-weight: 600; font-size: 13.5px; }
.kha-export-sub { grid-area: sub; font-size: 11px; color: var(--muted, #888); }
.kha-ga-export-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.kha-topo-badge {
    padding: 4px 12px; border-radius: 999px; font-size: 12px;
    background: var(--accent-soft, #eff6ff); color: var(--accent, #2563eb);
    border: 1px solid var(--accent, #93c5fd);
}
.kha-ga-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kha-ga-table th { text-align: left; padding: 7px 10px; border-bottom: 2px solid var(--line, #ddd); color: var(--muted, #888); font-weight: 500; }
.kha-ga-table td { padding: 6px 10px; border-bottom: 1px solid var(--line, #f0f0f0); }
.kha-ga-addr { font-family: monospace; color: var(--accent, #2563eb); }
.kha-ga-dpt, .kha-ga-type { color: var(--muted, #888); }

/* ===== Buttons =====
   Bewusst als 1:1-Alias auf das App-weite .btn/.btn-primary/.btn-secondary-
   System aufgebaut (dieselben Variablen, dieselben Werte) - vorher hatte
   der Smart Home Planer ein zweites, leicht abweichendes Button-Aussehen
   (anderer Innenabstand, anderes Hover-Verhalten: Abdunkeln vs. nur
   Transparenz). Markup/@onclick-Handler bleiben unveraendert, nur die
   Optik ist jetzt identisch zum Rest der App. */
.kha-btn-primary, .kha-btn-secondary {
    display: inline-block; border: 1px solid transparent; border-radius: var(--radius, 8px);
    padding: 9px 16px; font: inherit; font-weight: 600; font-size: 13.5px;
    cursor: pointer; text-decoration: none; text-align: center;
}
.kha-btn-primary:disabled, .kha-btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.kha-btn-primary { background: var(--accent, #2563eb); color: #fff; }
.kha-btn-primary:hover:not(:disabled) { background: var(--accent-strong, #1d4ed8); }
.kha-btn-secondary { background: var(--panel, #fff); color: var(--ink, #333); border-color: var(--line, #ddd); }
.kha-btn-secondary:hover:not(:disabled) { border-color: var(--accent, #2563eb); color: var(--accent-strong, #2563eb); }

/* RAL-Hinweis */
.kha-ral-hint { font-size: 11.5px; color: var(--muted, #888); margin-top: 12px; line-height: 1.5; }

.kha-demo-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border: 1px dashed var(--accent, #2563eb); border-radius: 8px;
    padding: 10px 14px; margin-bottom: 16px; font-size: 12.5px; background: var(--accent-soft, #eff6ff);
}

/* Gewerke-Kontakte */
.kha-contact-row {
    display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 8px; align-items: flex-end; margin-bottom: 8px;
    padding-bottom: 8px; border-bottom: 0.5px solid var(--line, #eee);
}
/* Bottom-Up: neueste Etage oben */
.kha-floors-stack { display: flex; flex-direction: column-reverse; }
.kha-add-floor-btn { order: -1; }

/* Fixierter Topbar */
.kha-topbar { position:sticky;top:0;z-index:100;display:flex;align-items:center;justify-content:space-between;padding:10px 20px;background:var(--panel,#fff);border-bottom:1px solid var(--line,#e0e0e0);box-shadow:0 1px 4px rgba(0,0,0,.08); }
.kha-topbar-title { font-size:15px;font-weight:700;display:flex;align-items:center;gap:6px; }
.kha-topbar-actions { display:flex;gap:8px; }
.kha-topbar-save { font-size:12.5px;padding:6px 14px;display:inline-flex;align-items:center;gap:6px; }
.kha-topbar-ico { display:inline-flex; }
.kha-topbar-ico svg { width:16px;height:16px;stroke:currentColor;fill:none; }

/* Tabs – aktiver Tab ORANGE (sichtbar im Darkmode) */
.kha-tab-on { color:#ff8c00!important; border-bottom-color:#ff8c00!important; font-weight:600; }

/* Naming-Editor */
.kha-naming-order { display:flex;gap:8px;flex-wrap:wrap;margin:8px 0; }
.kha-naming-chip { display:flex;align-items:center;gap:4px;border:1px solid var(--line,#ddd);border-radius:6px;padding:6px 10px;background:var(--paper,#f8f8f8); }
.kha-naming-arrow { background:none;border:none;cursor:pointer;font-size:12px;padding:0 2px;color:var(--muted,#888); }
.kha-naming-arrow:disabled { opacity:0.3;cursor:default; }
.kha-naming-preview { padding:10px 14px;background:var(--paper,#f8f8f8);border-radius:6px;font-size:13px;margin-top:8px;color:var(--ink,var(--fg,#222)); }

/* Setup-Dialog Sterne */
.kha-stars-setup { display:flex;gap:8px;margin-bottom:12px;flex-wrap:wrap; }
.kha-star-setup-btn { border:1px solid var(--line,#ddd);border-radius:6px;padding:8px 14px;cursor:pointer;font-size:13px;background:none; }
.kha-star-setup-on { border-color:#ff8c00;background:rgba(255,140,0,.1);color:#ff8c00;font-weight:600; }


/* GA-Baumansicht */
.kha-tree { font-family:monospace;font-size:12.5px;background:var(--paper,#f0f0f0);border:1px solid var(--line,#e0e0e0);border-radius:8px;padding:14px 16px;max-height:400px;overflow-y:auto;margin-bottom:16px;color:var(--ink,var(--fg,#222)); }
.kha-tree-floor { margin-bottom:10px; }
.kha-tree-floor-lbl { font-weight:700;color:var(--accent,#2563eb); }
.kha-tree-trade { margin-left:14px;margin-top:4px; }
.kha-tree-trade-lbl { color:var(--muted,#888);display:block;margin-bottom:2px; }
.kha-tree-addr { display:flex;gap:12px;margin-left:28px;padding:1px 0; }
.kha-tree-ga { min-width:60px;color:var(--accent,#2563eb); }
.kha-tree-name { color:var(--fg,#222); }

/* Expliziter Dark-Mode-Kontrast-Fix: --fg/--ink duerfen zwar korrekt aufgeloest
   werden, hier aber zusaetzlich hart abgesichert, falls irgendwo eine
   Zwischenregel/veraltete CSS-Kopie dazwischenfunkt - helles Grau statt
   dunklem Text auf dunklem Grund. */
:root[data-theme="dark"] .kha-tree-name { color: #d5ddd8; }
:root[data-theme="dark"] .kha-tree-trade-lbl { color: #9cb2a5; }

/* Farbcodierung je Gewerk in der Baumansicht (0=Licht,1=Beschattung,2=Heizung,4=Sicherheit,5=Alarm,6=Steckdosen) */
.kha-cat-0 .kha-tree-trade-lbl, .kha-cat-0 .kha-tree-ga { color: #c9932a; }
.kha-cat-1 .kha-tree-trade-lbl, .kha-cat-1 .kha-tree-ga { color: #4d8fd1; }
.kha-cat-2 .kha-tree-trade-lbl, .kha-cat-2 .kha-tree-ga { color: #d1683f; }
.kha-cat-3 .kha-tree-trade-lbl, .kha-cat-3 .kha-tree-ga { color: #4a9d5f; }
.kha-cat-4 .kha-tree-trade-lbl, .kha-cat-4 .kha-tree-ga { color: #9155c4; }
.kha-cat-5 .kha-tree-trade-lbl, .kha-cat-5 .kha-tree-ga { color: #c4514f; }
.kha-cat-6 .kha-tree-trade-lbl, .kha-cat-6 .kha-tree-ga { color: #2f9e8f; }
.kha-tree-trade-ico { display: inline-flex; vertical-align: -3px; }
.kha-tree-trade-ico svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }

/* Nav-Highlight: KNX Home Assistant prominent */
.nav-highlight { color: var(--accent-strong) !important; font-weight: 600; border-left: 3px solid var(--accent); transition: background .12s, color .12s; }
.nav-highlight .nav-ico { color: var(--accent-strong); }
.nav-highlight:hover { background: var(--pine-soft); color: #fff !important; }
.nav-highlight:hover .nav-ico { color: #fff; }
.nav-highlight.active { background: var(--pine-soft); color: #fff !important; box-shadow: inset 3px 0 0 var(--accent); }
.nav-highlight.active .nav-ico { color: #fff; }

/* Accordion Chevron */
.kha-floor-chevron { font-size: 11px; margin-right: 6px; color: var(--muted,#888); transition: transform 0.15s; }
.kha-floor-header { cursor: pointer; }

/* Add-Floor zwischen Etagen (keine Stapel-Probleme) */
.kha-add-floor-btn-between {
    display: flex; justify-content: center; align-items: center; height: 24px;
}
.kha-add-floor-btn-between span {
    width: 24px; height: 24px; background: var(--panel,#fff);
    border: 1px solid var(--line,#ccc); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer; line-height: 1;
}
.kha-add-floor-btn-between span:hover { border-color: var(--accent,#2563eb); color: var(--accent,#2563eb); }
.kha-add-floor-btn-bottom {
    text-align: center; padding: 10px; font-size: 13px;
    color: var(--muted,#888); cursor: pointer; border: 1px dashed var(--line,#ddd);
    border-radius: 6px; margin-top: 6px;
}
.kha-add-floor-btn-bottom:hover { border-color: var(--accent,#2563eb); color: var(--accent,#2563eb); }

/* Export-Icons farbig */
.kha-icon-lox  { background: #3FA86E !important; }
.kha-icon-xml  { background: #2E8CE0 !important; }
.kha-icon-lh   { background: #9333ea !important; }
.kha-icon-doc  { background: #f59e0b !important; }
.kha-icon-yaml { background: #0891b2 !important; }
.kha-icon-net  { background: #64748b !important; }
.kha-export-btn-ha { border-color: #0891b2; }
.kha-export-btn-ha:hover { background: rgba(8,145,178,.08); }

/* Popup-Overlay immer oben */
.kha-picker-overlay { z-index: 1000; }

.kha-loading { text-align:center; padding:40px; color:var(--muted,#888); font-size:14px; }

/* GA-Tabellen-Sortierung (Schritt 5) */
.kha-sort-btn { background:none;border:none;cursor:pointer;padding:0 0 0 5px;color:var(--muted,#aaa);font-size:11px;vertical-align:middle;line-height:1; }
.kha-sort-btn:hover { color:var(--fg,#333); }
.kha-sort-asc  { color:#ff8c00; }
.kha-sort-desc { color:#ff8c00; }

/* Room-copy-Button */
.kha-room-copy { position:absolute;top:50%;right:20px;transform:translateY(-50%);background:none;border:none;font-size:10px;color:#ccc;cursor:pointer;padding:0;line-height:1; }
.kha-room-copy:hover { color:var(--accent,#2563eb); }

/* Hinweis: der GA-Baum-Hintergrund folgt jetzt direkt var(--paper) in der
   Basisregel oben und braucht daher keine separate prefers-color-scheme-
   Regel mehr - die reagierte ohnehin nur auf die Betriebssystem-Einstellung,
   nicht auf den In-App-Dunkelmodus-Schalter (data-theme="dark"), und griff
   deshalb beim In-App-Toggle nie. */
