/*
 * EWAY-Design (neu) – Rahmen: Kopfzeile, Navigation + Kontextmenüs, Aside, Seitenkopf,
 * Benutzermenü, Footer, Drawer, Dialog, Meldungen, Anmeldeseiten, Wartebildschirm.
 * Plan: plans/layout.md · HTML-Aufbau: inc/php_functions/ui.php · Vorschau: system/styleguide
 * Wirkt nur auf Elemente mit ew-Klassen.
 */

/* ---------- Grundlage ---------- */

.ew-root {
    background-color: var(--ew-bg);
    color: var(--ew-text);
    font-family: var(--ew-font);
    font-size: 13px;
    line-height: 1.45;
    color-scheme: var(--ew-scheme);
}

.ew-icon { font-size: 16px; line-height: 1; vertical-align: -2px; color: inherit; }
.ew-icon.bi { font-size: 16px; }   /* Metronic setzt i.bi auf 1rem (13 px) und schlägt .ew-icon – Bootstrap Icons wie Keenicons (seit 2026-11-27, KI-Symbol bi-robot) */
.ew-text-soft { color: var(--ew-text-soft) !important; }
.ew-text-muted { color: var(--ew-text-muted) !important; }
.ew-text-accent { color: var(--ew-accent-text) !important; }
.ew-text-danger { color: var(--ew-danger) !important; }
.ew-text-success { color: var(--ew-success) !important; }
.ew-text-warning { color: var(--ew-warning) !important; }
.ew-small { font-size: 12px; }
.ew-mono { font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

:where(.ew-root) a { color: inherit; text-decoration: none; }
.ew-link { color: var(--ew-accent-text) !important; font-weight: 500; }
.ew-link:hover { text-decoration: underline !important; }

:where(.ew-root) :focus-visible { outline: none; box-shadow: var(--ew-focus-ring); }

/* altes Design unterstreicht jedes h1 (inc/styles/text.php) – im neuen Design nicht */
.ew-root h1,
.ew-root h2,
h1.ew-page-title { text-decoration: none; }


/* ---------- Kopfzeile ---------- */

.ew-header {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--ew-header-height);
    padding: 1px 20px 0;   /* oben 1 px wie die Linie unten: Inhalt mittig über die ganze Höhe samt Linie (Wunsch Nutzer 2026-11-02, saß 1–2 px zu hoch) */
    background-color: var(--ew-bg-header);
    border-bottom: 1px solid var(--ew-line);
    color: var(--ew-text);
}
.ew-header-logo { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; margin-right: 8px; }
.ew-header-logo img { max-height: 32px; max-width: min(180px, 100%); display: block; }
/* Logo je Darstellung (ui_header mit logo_light) */
.ew-header-logo .ew-logo-light,
[data-ew-theme="light"] .ew-header-logo .ew-logo-dark { display: none; }
[data-ew-theme="light"] .ew-header-logo .ew-logo-light { display: block; }
.ew-header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.ew-header .ew-header-burger { display: none; }

/* Hauptmenü */
.ew-nav { display: flex; flex: 1 1 auto; align-items: center; gap: 2px; min-width: 0; }
.ew-nav-item { position: relative; flex: none; }
.ew-nav-item.ew-nav-hidden { display: none !important; }   /* steht im Menü „Mehr“ (ui.js) */
.ew-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--ew-radius);
    background: transparent;
    color: var(--ew-text-soft) !important;
    font: 500 13px/1 var(--ew-font);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--ew-transition), color var(--ew-transition);
}
/* Beschriftung auf Versalhöhe bis Grundlinie zugeschnitten: align-items setzt dann die Großbuchstaben genau in die Mitte –
   ohne Zuschnitt hängt die Lage von den Schriftmetriken des Browsers ab (Wunsch Nutzer 2026-11-02; ältere Browser wie vorher) */
.ew-nav-link > .ew-nav-label { display: block; text-box: trim-both cap alphabetic; }
.ew-nav-link:hover,
.ew-nav-link.show { background-color: var(--ew-hover); color: var(--ew-text) !important; }
.ew-nav-link.active { background-color: var(--ew-accent-tint); color: var(--ew-accent-text) !important; }   /* Burger-Menü; breit: Strich, s. u. */
.ew-nav-link.ew-danger { color: var(--ew-danger) !important; }
.ew-nav-link.ew-danger.active,
.ew-nav-link.ew-danger:hover { background-color: var(--ew-danger-tint); }
.ew-nav-caret { font-size: 11px; color: var(--ew-text-muted); transition: transform var(--ew-transition); }
.ew-nav-link.active .ew-nav-caret { color: var(--ew-accent-text); }
.ew-nav-link.show .ew-nav-caret { transform: rotate(180deg); }
/* Aktiver Punkt in der breiten Leiste: helle Schrift und Lime-Strich auf der Unterkante der Kopfzeile (Wunsch Nutzer 2026-11-02,
   vorher Lime-Tönung wie im Burger-Menü). Die Punkte sind so hoch wie die Kopfzeile (in der App 73 px aus dem Metronic-Rahmen,
   im Styleguide 60 px), der Strich hängt unten am Punkt und deckt die Linie darunter (−1 px). */
@media (min-width: 992px) {
    .ew-nav { align-self: stretch; align-items: stretch; }
    .ew-nav-item:not([hidden]) { display: flex; align-items: center; }
    .ew-nav-link.active { background-color: transparent; color: var(--ew-text) !important; }
    .ew-nav-link.active:hover,
    .ew-nav-link.active.show { background-color: var(--ew-hover); }
    .ew-nav-link.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background-color: var(--ew-accent-line); }
    .ew-nav-link.active .ew-nav-caret { color: var(--ew-text-soft); }
    .ew-nav-link.ew-danger.active { background-color: transparent; color: var(--ew-danger) !important; }
    .ew-nav-link.ew-danger.active:hover,
    .ew-nav-link.ew-danger.active.show { background-color: var(--ew-danger-tint); }
    .ew-nav-link.ew-danger.active::after { background-color: var(--ew-danger); }
    /* Punkt nur als Symbol (ui_nav „icon_only“, seit 2026-11-20): Titel nur für Screenreader, ohne Pfeil */
    .ew-nav-link.ew-nav-icon-only { padding: 0 10px; }
    .ew-nav-link.ew-nav-icon-only > .ew-nav-label {
        position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
    }
    .ew-nav-link.ew-nav-icon-only > .ew-nav-caret { display: none; }
    .ew-nav-link.ew-nav-icon-only.active::after { left: 8px; right: 8px; }
}
.ew-nav-link > .ew-nav-icon { font-size: 18px; line-height: 1; }

@media (max-width: 991.98px) {
    .ew-nav-link.ew-nav-icon-only > .ew-nav-icon { display: none; }   /* Burger-Menü: Titel wie bei den anderen Punkten */
    .ew-header { position: relative; padding: 1px 12px 0; gap: 8px; }
    .ew-header .ew-header-burger { display: inline-flex; }
    .ew-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 105;
        flex-direction: column;
        align-items: stretch;
        padding: 8px;
        background-color: var(--ew-bg-header);
        border-bottom: 1px solid var(--ew-line-strong);
        box-shadow: var(--ew-shadow-float);
    }
    .ew-header.ew-nav-open .ew-nav { display: flex; }
    .ew-nav-link { width: 100%; justify-content: flex-start; height: 40px; }
    .ew-nav-caret { margin-left: auto; }
    .ew-nav .ew-dropdown { position: static !important; transform: none !important; inset: auto !important; box-shadow: none; margin: 2px 0 6px 12px !important; }
}
@media (max-width: 575.98px) {
    .ew-btn.ew-btn-collapse { padding: 0 9px; }
    .ew-btn.ew-btn-collapse > span { display: none; }   /* Text-Knöpfe in der Kopfzeile nur als Icon */
    .ew-header { gap: 6px; padding: 1px 8px 0; }
    .ew-header-tools { gap: 4px; }
    .ew-header-logo { margin-right: 0; }
    .ew-header-logo img { max-height: 24px; }
}


/* ---------- Kopfzeile der App (inc/site_top.php) ----------
 * Der Metronic-Rahmen #kt_app_header.app-header bleibt (feste Position, Höhe für Seite und Aside),
 * innen steht die ew-header. Überschreibt Verlauf/Rand aus inc/styles/nav_top.php. */

.app-header.ew-app-header {
    background: var(--ew-bg-header) !important;
    border-bottom: 1px solid var(--ew-line) !important;
    box-shadow: none !important;
}
.ew-app-header > .ew-header { width: 100%; height: 100%; border-bottom: 0; }

/* Werkzeuge rechts: Widgets der Apps (app_X/addons) und Benutzermenü (inc/menu_user.php) */
.ew-header-item { position: relative; display: flex; align-items: center; }
.ew-avatar-btn {
    position: relative;
    display: inline-flex;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}
.ew-avatar-btn:focus-visible { outline: none; box-shadow: var(--ew-focus-ring); }
.ew-avatar-btn .ew-avatar { width: 34px; height: 34px; }
.ew-location-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; }

/* Such-Panel (Metronic KTSearch bleibt, nur das Aussehen ist neu) */
.menu-sub-dropdown.ew-panel {
    padding: 14px;
    background-color: var(--ew-raised) !important;
    border: 1px solid var(--ew-line-strong);
    border-radius: var(--ew-radius-card);
    box-shadow: var(--ew-shadow-float);
    color: var(--ew-text);
    font: 13px/1.45 var(--ew-font);
}
.ew-search-panel { width: 380px; max-width: calc(100vw - 24px); }
.ew-search-panel .ew-search { margin-bottom: 12px; }
.ew-search-panel [data-kt-search-element="spinner"],
.ew-search-panel [data-kt-search-element="clear"] { position: absolute; right: 10px; color: var(--ew-text-muted); cursor: pointer; }
/* Treffer kommen als fertiges HTML (app_logomanager_pages/logo-app/_api_search.php) – hier angleichen */
.ew-search-panel .text-dark,
.ew-search-panel .text-gray-800 { color: var(--ew-text) !important; }
.ew-search-panel .text-muted { color: var(--ew-text-muted) !important; }
.ew-search-panel .bg-light-gray { background-color: var(--ew-hover) !important; color: var(--ew-text-soft) !important; }
.ew-search-panel .border-gray-300 { border-color: var(--ew-line-strong) !important; }
.ew-search-panel .border-hover:hover { border-color: var(--ew-accent) !important; background-color: var(--ew-hover); }



/* ---------- Kontextmenüs (Top-Navigation, ⋯-Menü, Benutzermenü) ----------
 * Bootstrap-Dropdown: data-bs-toggle="dropdown" + .dropdown-menu.ew-dropdown */

.dropdown-menu.ew-dropdown {
    --bs-dropdown-zindex: 1060;
    min-width: 220px;
    padding: 6px;
    margin: 6px 0 0 !important;
    background-color: var(--ew-raised);
    border: 1px solid var(--ew-line-strong);
    border-radius: var(--ew-radius-card);
    box-shadow: var(--ew-shadow-float);
    color: var(--ew-text);
    font: 13px/1.4 var(--ew-font);
    list-style: none;
}
.ew-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ew-text) !important;
    font: inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.ew-dropdown-item .ew-icon { color: var(--ew-text-soft); }
.ew-dropdown-item:hover,
.ew-dropdown-item:focus-visible { background-color: var(--ew-active); }
.ew-dropdown-item.active { background-color: var(--ew-accent-tint); color: var(--ew-accent-text) !important; }
.ew-dropdown-item.active .ew-icon { color: var(--ew-accent-text); }
.ew-dropdown-item.ew-danger,
.ew-dropdown-item.ew-danger .ew-icon { color: var(--ew-danger) !important; }
.ew-dropdown-item.ew-danger:hover { background-color: var(--ew-danger-tint); }
.ew-dropdown-tag {
    margin-left: auto;
    padding: 0 6px;
    border-radius: var(--ew-radius-badge);
    background-color: var(--ew-danger-tint);
    color: var(--ew-danger);
    font-size: 11px;
    font-weight: 600;
}
.ew-dropdown-tag.ew-nav-tag { margin-left: 2px; padding: 0 5px; }   /* „SA“ in der oberen Leiste */
.ew-dropdown-hint { margin-left: auto; color: var(--ew-text-muted); font-size: 12px; }

/* Bereich nur für den Superadmin, abgesetzt am Ende eines Menüs (z. B. Benutzermenü) */
.ew-dropdown-admin {
    margin: 6px 0 0;
    padding: 8px 4px 4px;
    border-radius: 8px;
    background-color: var(--ew-active);
}
.ew-dropdown-admin .ew-dropdown-label { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.ew-dropdown-admin .ew-dropdown-section { padding: 6px; }
.ew-dropdown-admin .ew-dropdown-item:hover { background-color: var(--ew-active); }
/* Trennlinie in Kontextmenüs: Bootstrap setzt <hr> auf opacity .25 – deshalb zurück auf 1 und die kräftigere Linienfarbe
   (vorher kaum zu sehen, Hinweis Nutzer 2026-11-12) */
.ew-dropdown-sep { height: 1px; margin: 5px 4px; background-color: var(--ew-line-strong); border: 0; opacity: 1; }
.ew-dropdown-heading { padding: 8px 10px 4px; color: var(--ew-text); font-size: 12px; font-weight: 600; }
.ew-dropdown-section { padding: 6px 10px; }

/* Smartphone: Kontextmenüs der Tabellen als Blatt von unten */
@media (max-width: 575.98px) {
    .dropdown-menu.ew-dropdown.ew-sheet.show {
        position: fixed !important;
        inset: auto 0 0 0 !important;
        transform: none !important;
        margin: 0 !important;
        padding: 10px 12px 18px;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 0 0 100vmax var(--ew-overlay);
    }
    .dropdown-menu.ew-dropdown.ew-sheet.show::before {
        content: "";
        display: block;
        width: 36px;
        height: 4px;
        margin: 0 auto 10px;
        border-radius: 2px;
        background-color: var(--ew-line-strong);
    }
    .ew-dropdown.ew-sheet .ew-dropdown-item { padding: 12px 10px; font-size: 14px; }
}


/* ---------- Aside ---------- */

.ew-aside {
    width: var(--ew-aside-width);
    padding: 16px 12px;
    background-color: var(--ew-bg-header);
    border-right: 1px solid var(--ew-line);
    color: var(--ew-text);
}
.ew-aside-heading {
    padding: 0 10px 6px;
    color: var(--ew-text);
    font-size: 13px;
    font-weight: 600;
}
.ew-aside-heading:not(:first-child) {
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--ew-line-strong);
}
.ew-aside-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    padding: 8px 10px;
    border-radius: var(--ew-radius);
    color: var(--ew-text-soft) !important;
    white-space: nowrap;
    transition: background-color var(--ew-transition), color var(--ew-transition);
}
.ew-aside-link .ew-icon { color: var(--ew-text-muted); }
.ew-aside-link:hover { background-color: var(--ew-hover); color: var(--ew-text) !important; }
.ew-aside-link.active { background-color: var(--ew-active); color: var(--ew-text) !important; }
.ew-aside-link.active .ew-icon { color: var(--ew-accent-text); }
.ew-aside-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background-color: var(--ew-accent);
}
.ew-aside-link .ew-badge { margin-left: auto; }
/* zwei Badges nebeneinander (z. B. rot „offen“ + Anzahl): beide rechts, 6 px Abstand */
.ew-aside-link .ew-badge + .ew-badge { margin-left: -4px; }
/* lange Texte mit Badge/Markierung kürzen statt über den Rand zu laufen (voller Text im title) */
.ew-aside-link > span:first-of-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ew-aside-link .ew-icon,
.ew-aside-link .ew-badge,
.ew-aside-link .ew-dot,
.ew-aside-link .ew-dropdown-tag { flex: none; }
.ew-aside-link.ew-danger,
.ew-aside-link.ew-danger .ew-icon { color: var(--ew-danger) !important; }
.ew-aside-link.ew-danger:hover,
.ew-aside-link.ew-danger.active { background-color: var(--ew-danger-tint); }
.ew-aside-link.ew-danger.active::before { background-color: var(--ew-danger); }

/* Seitenleiste der App (index.php): Metronic-Rahmen #kt_app_sidebar bleibt (feste Position, Drawer auf
 * dem Smartphone, Einklappen per Cookie data-kt-app-sidebar-minimize), innen steht die ew-aside. */
.app-sidebar.ew-app-aside {
    background-color: var(--ew-bg-header) !important;
    border-right: 1px solid var(--ew-line);
    box-shadow: none !important;
}
.ew-app-aside > .ew-aside {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 0;
}
.ew-aside-toggle {
    position: absolute;
    top: 28px;
    left: 100%;
    z-index: 3;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--ew-line-strong);
    border-radius: 50%;
    background-color: var(--ew-raised);
    color: var(--ew-text-soft);
    transform: translateX(-50%);
    cursor: pointer;
}
.ew-aside-toggle:hover { color: var(--ew-text); }
.ew-aside-toggle .ew-icon { font-size: 14px; vertical-align: 0; transition: transform var(--ew-transition); }
[data-kt-app-sidebar-minimize="on"] .ew-aside-toggle .ew-icon { transform: rotate(180deg); }

/* eingeklappt: nur Icons; beim Überfahren klappt Metronic die Leiste wieder auf */
[data-kt-app-sidebar-minimize="on"] .ew-app-aside:not(:hover) .ew-aside-link { justify-content: center; }
[data-kt-app-sidebar-minimize="on"] .ew-app-aside:not(:hover) .ew-aside-link > span { display: none; }
[data-kt-app-sidebar-minimize="on"] .ew-app-aside:not(:hover) .ew-aside-heading { height: 0; padding: 0; margin-bottom: 12px; overflow: hidden; color: transparent; }
[data-kt-app-sidebar-minimize="on"] .ew-app-aside:not(:hover) .ew-aside-heading:first-child { margin: 0; }


/* ---------- Seite ---------- */

/* Seitenhintergrund, sobald Kopfzeile und Aside einer App neu sind (index.php: body.ew-body, heute Lizenzserver
 * und die Seiten des Benutzermenüs – ohne ihn sind neue Seiten im hellen Modus dunkel auf dunkel) */
body.ew-body { background-color: var(--ew-bg) !important; }

/* Inhalt einer umgebauten Seite (ohne alte Toolbar): Abstand oben, Hintergrund vom body */
.ew-root.ew-page { padding: 24px 0 48px; background-color: transparent; }
.ew-page > .ew-card + .ew-card { margin-top: var(--ew-card-gap); }   /* Abstand zwischen Kacheln: tokens.css (Vorlage seit 2026-11-15, vorher 20 px) */
.ew-page > .ew-alert + .ew-card,
.ew-page > .ew-card + .ew-alert { margin-top: 20px; }
.ew-page > .ew-alert { margin-bottom: 20px; }


/* ---------- Seitenkopf ---------- */

.ew-page-header {
    display: flex;
    align-items: flex-start;  /* Knöpfe immer ganz oben rechts, auch bei langem Untertitel (seit 2026-11-09, Wunsch Nutzer; vorher flex-end) */
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.ew-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; color: var(--ew-text-muted); font-size: 12px; }
.ew-breadcrumb a:hover { color: var(--ew-text) !important; }
.ew-page-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ew-page-title { margin: 0; color: var(--ew-text); font-size: 22px; font-weight: 600; line-height: 1.25; }
.ew-page-sub { margin-top: 2px; color: var(--ew-text-soft); }
.ew-page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* Aktionen bleiben rechts neben Titel und Untertitel, auch wenn der Untertitel lang ist (seit 2026-11-09): der Titelblock zählt
   für den Umbruch nur mit 18rem und wächst dann; erst wenn auch das nicht passt (schmale Fenster), rutschen die Knöpfe darunter. */
.ew-page-header > :first-child { flex: 1 1 18rem; }
.ew-page-header > .ew-page-actions { flex: 0 1 auto; min-width: 0; max-width: 100%; }
/* Kennzahl rechts oben (ui_page_stat(), seit 2026-12-05 – Vertrag → Erweiterungen): immer gleich breit, damit die Seiten gleich aussehen */
.ew-page-stat { width: 250px; max-width: 100%; padding: 10px 14px 12px; border: 1px solid var(--ew-line-strong); border-radius: var(--ew-radius-card);
                background-color: var(--ew-surface); color: var(--ew-text); }
.ew-page-stat-label { display: flex; align-items: center; gap: 6px; color: var(--ew-text-soft); font-size: 12px; }
.ew-page-stat-value { margin-top: 4px; line-height: 1.2; white-space: nowrap; }
.ew-page-stat-num { font-size: 20px; font-weight: 600; }
.ew-page-stat-of { color: var(--ew-text-muted); font-size: 13px; }
.ew-page-stat-empty .ew-page-stat-num { color: var(--ew-text-muted); font-size: 15px; font-weight: 500; }
.ew-page-stat .ew-meter { margin-top: 8px; }
.ew-page-stat-sub { margin-top: 6px; color: var(--ew-text-muted); font-size: 12px; }
/* schrumpft nur, wenn die Knöpfe allein in ihrer Zeile nicht passen (Smartphone, seit 2026-11-12) – dann brechen sie um statt
   die Seite seitlich zu verbreitern; vorher flex 0 0 auto */


/* ---------- Benutzermenü ---------- */

.dropdown-menu.ew-dropdown.ew-user-menu { width: 280px; }
.ew-user-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; }
.ew-user-head .ew-user-name { font-weight: 600; }
.ew-user-head .ew-user-mail { color: var(--ew-text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ew-user-head .ew-badge { margin-top: 5px; }
.ew-dropdown-label { margin-bottom: 6px; color: var(--ew-text-muted); font-size: 12px; }


/* ---------- Footer ---------- */

.ew-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--ew-line);
    color: var(--ew-text-muted);
    font-size: 12px;
}
.ew-footer-links { display: flex; gap: 16px; margin-left: auto; }
.ew-footer-links a:hover { color: var(--ew-text) !important; }


/* ---------- Drawer (Metronic-Drawer mit Klasse ew-drawer oder statisch) ---------- */

.ew-drawer {
    display: flex;
    flex-direction: column;
    background-color: var(--ew-raised) !important;
    border-left: 1px solid var(--ew-line-strong);
    color: var(--ew-text);
    font: 13px/1.45 var(--ew-font);
}
.ew-drawer[data-kt-drawer="true"]:not(.drawer) { display: none; }   /* vor dem Start des Metronic-Drawers */
.ew-drawer-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--ew-line); }
.ew-drawer-title { font-size: 15px; font-weight: 600; }
.ew-drawer-body { flex: 1; padding: 18px 20px; overflow-y: auto; }
.ew-drawer-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--ew-line); }


/* ---------- Dialog (Bootstrap-Modal mit ew-modal, SweetAlert mit ew-swal) ---------- */

.ew-modal .modal-content,
.ew-dialog {
    background-color: var(--ew-raised);
    border: 1px solid var(--ew-line-strong);
    border-radius: 14px;
    box-shadow: var(--ew-shadow-float);
    color: var(--ew-text);
    font: 13px/1.45 var(--ew-font);
}
.ew-modal .modal-header { padding: 16px 20px; border-bottom: 1px solid var(--ew-line); }
.ew-modal .modal-title { margin: 0; color: var(--ew-text); font-size: 16px; font-weight: 600; }
.ew-modal .modal-body { padding: 16px 20px; }
/* Nachgeladene Inhalte (_api_*.php mit eigenem .ew-root): Hintergrund des Dialogs übernehmen */
.ew-modal .modal-body > .ew-root { background-color: transparent; }
/* … übergangsweise im alten, hellen Dialog #infobox (noch nicht umgebaute Seiten): eigene dunkle Fläche */
.modal:not(.ew-modal) .modal-body > .ew-root { padding: 16px; border-radius: var(--ew-radius-card); background-color: var(--ew-raised); }
.ew-modal .modal-footer { gap: 8px; padding: 12px 20px; border-top: 1px solid var(--ew-line); }
/* <form> um Body und Footer: wie der Dialog selbst als Spalte, sonst schneidet .modal-dialog-scrollable den Footer
   (Speichern) ab und der Body scrollt nicht (niedrige Fenster) */
.ew-modal .modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.ew-modal .modal-footer > * { margin: 0; }
.ew-dialog { max-width: 400px; padding: 22px; }
.ew-dialog-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-bottom: 14px; border-radius: 10px; font-size: 20px; }
.ew-dialog-title { margin-bottom: 4px; font-size: 16px; font-weight: 600; }
.ew-dialog-text { margin-bottom: 18px; color: var(--ew-text-soft); }
.ew-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.swal2-popup.ew-swal {
    width: 400px;
    padding: 22px;
    background-color: var(--ew-raised);
    border: 1px solid var(--ew-line-strong);
    border-radius: 14px;
    color: var(--ew-text);
    font-family: var(--ew-font);
    text-align: left;
}
.swal2-popup.ew-swal .swal2-icon { display: none !important; }
.swal2-popup.ew-swal .swal2-title { padding: 0; color: var(--ew-text); font-size: 16px; font-weight: 600; text-align: left; }
.swal2-popup.ew-swal .swal2-html-container { margin: 6px 0 0; padding: 0; color: var(--ew-text-soft); font-size: 13px; text-align: left; }
.swal2-popup.ew-swal .swal2-actions { justify-content: flex-end; gap: 8px; width: 100%; margin: 20px 0 0; }
/* Eingabe-Dialog (ui_prompt): Beschriftung und Feld bündig mit dem Titel, Feld so breit wie der Dialog (seit 2026-11-09) */
.swal2-popup.ew-swal .swal2-input-label { justify-content: flex-start; margin: 6px 0 0; color: var(--ew-text-soft); font-size: 13px; line-height: 1.5; text-align: left; }
.swal2-popup.ew-swal .swal2-input { box-sizing: border-box; width: 100%; max-width: 100%; margin: 14px 0 0; }
.swal2-popup.ew-swal .ew-dialog-icon { margin-bottom: 14px; }
.swal2-container.ew-swal-backdrop { background-color: var(--ew-overlay) !important; }

/* Hintergrund hinter Drawer, Fenster und Dialogen: abgedunkelt und unscharf (--ew-overlay-blur) –
 * für alle Seiten, auch die noch nicht umgebauten (Metronic-Drawer, Bootstrap-Modal, SweetAlert).
 * Bootstrap blendet .modal-backdrop über opacity ein; die Unschärfe würde mit abgeschwächt (Doppelbild) –
 * deshalb volle Deckkraft und die Abdunklung wie bisher (Schwarz 40 %) in der Farbe.
 * SweetAlert: nicht bei Toasts (Container dort nur 360 px breit) und nicht bei backdrop: false. */
.modal-backdrop { --bs-backdrop-bg: rgba(0, 0, 0, .4); --bs-backdrop-opacity: 1; }
.modal-backdrop,
.drawer-overlay,
body:not(.swal2-toast-shown):not(.swal2-no-backdrop) .swal2-container.swal2-backdrop-show {
    -webkit-backdrop-filter: blur(var(--ew-overlay-blur));
    backdrop-filter: blur(var(--ew-overlay-blur));
}


/* ---------- Meldungen (Toast) ---------- */

.ew-toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(340px, calc(100vw - 40px));
    pointer-events: none;
}
.ew-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    background-color: var(--ew-raised);
    border: 1px solid var(--ew-line-strong);
    border-radius: 10px;
    box-shadow: var(--ew-shadow-float);
    color: var(--ew-text);
    font: 13px/1.4 var(--ew-font);
    pointer-events: auto;
    animation: ew-toast-in .2s ease;
}
.ew-toast .ew-icon { font-size: 18px; }
.ew-toast-close { margin-left: auto; border: 0; background: transparent; color: var(--ew-text-muted); cursor: pointer; }
.ew-toast.ew-hide { opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; }
@keyframes ew-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }


/* ---------- Anmeldeseiten (do/: immer dunkel) ---------- */

.ew-auth { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 32px 16px; }
.ew-auth-logo { margin-bottom: 24px; }
.ew-auth-logo img { max-height: 40px; }
.ew-auth-card {
    width: 100%;
    max-width: 380px;
    padding: 28px 26px;
    background-color: var(--ew-surface);
    border: 1px solid var(--ew-line-strong);   /* Außenrahmen wie Karten und Kontextmenüs (Wunsch Nutzer 2026-10-24) */
    border-radius: 16px;
}
.ew-auth-title { margin: 0; color: var(--ew-text); font-size: 20px; font-weight: 600; }
.ew-auth-sub { margin: 2px 0 20px; color: var(--ew-text-muted); }
.ew-auth-footer { display: flex; gap: 16px; margin-top: 20px; color: var(--ew-text-muted); font-size: 12px; }
.ew-code { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 18px 0; }
.ew-code input { height: 48px; text-align: center; font-size: 20px; font-weight: 600; padding: 0; }

/* Rahmen do/auth_head.php + do/auth_footer.php (Login, 2FA, Passwort, Konto-Links) */
body.ew-auth-body { margin: 0; background-color: var(--ew-bg) !important; background-image: none !important; }
/* Hintergrund wie der Wartebildschirm: Lichtschleier auf einer festen Ebene hinter der Karte (Wunsch Nutzer 2026-11-04).
   Grundfläche als Verlauf statt als reine Farbe: Chrome malt einfarbige Bildschirmkacheln als bloße Farbfläche, auf dem Mac
   etwas dunkler als Kacheln mit Inhalt – auf der leeren Fläche erschien hinter der Karte ein hellerer Streifen. */
.ew-auth-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    isolation: isolate;
    pointer-events: none;
    background-color: var(--ew-bg);
    background-image: linear-gradient(var(--ew-bg), var(--ew-bg));
}
.ew-auth-head { margin-bottom: 20px; }
.ew-auth-head .ew-auth-sub { margin-bottom: 0; color: var(--ew-text-soft); overflow-wrap: anywhere; }
.ew-auth-head .ew-auth-sub strong { color: var(--ew-text); font-weight: 600; }
.ew-auth-icon-accent { background-color: var(--ew-accent-tint); color: var(--ew-accent-text); }
.ew-auth-icon-success { background-color: var(--ew-success-tint); color: var(--ew-success); }
.ew-auth-icon-danger { background-color: var(--ew-danger-tint); color: var(--ew-danger); }
.ew-auth-card .ew-alert { margin-bottom: 16px; }
.ew-auth-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.ew-auth-text { color: var(--ew-text-soft); }
.ew-auth-footer a { color: inherit; }
.ew-auth-footer a:hover { color: var(--ew-text); }
/* Passwortregeln (inc/js/password_rules.js) und „Passwort erzeugen“ (password_generator.js) im neuen Design */
.ew-auth-card [data-pw-rules] + ul,
.ew-auth-card [data-pw-confirm] + ul { margin-top: 6px !important; font-size: 12px !important; }
.ew-auth-card [data-pw-generate-info] { margin-top: 6px !important; color: var(--ew-text-soft) !important; font-size: 12px !important; }


/* ---------- Wartebildschirm (inc/wait.php, ui_wait(): immer dunkel, Lichtschleier) ----------
 * #wait, #wait_info und die Aufrufe $("#wait").show()/.hide() bleiben unverändert.
 * Seitenaufbau (#wait.ew-wait-boot): sofort sichtbar, ohne Einblenden – sonst sieht man kurz die halb aufgebaute Seite.
 * show(): gestaffelt einblenden, erst nach 0,2 s (kurze Aktionen blitzen nicht auf): Fläche → Lichter → Logo → Spinner.
 *   Klicks sind sofort gesperrt (die Ebene liegt auch während der Verzögerung darüber).
 * hide(): jQuery setzt display:none, die Überblendung (0,3 s) läuft per CSS; Browser ohne „allow-discrete“ blenden
 *   sofort aus. Klicks gehen ab hide() sofort wieder durch.
 */
.ew-wait-layer {
    position: fixed;
    inset: 0;
    z-index: 20000;
    transition: opacity .3s ease;
    transition: opacity .3s ease, display .3s ease allow-discrete;
}
.ew-wait-layer[style*="display: none"] { opacity: 0; pointer-events: none; }

.ew-wait {
    position: absolute;
    inset: 0;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: var(--ew-bg);
    color: var(--ew-text-soft);
    font: 13px/1.45 var(--ew-font);
    cursor: progress;
    animation: ew-wait-in .25s ease .2s both;
}
.ew-wait > .ew-lights { animation: ew-wait-in 1.2s ease .35s both; }
.ew-wait-logo { display: block; max-width: min(240px, 70vw); max-height: 96px; height: auto; animation: ew-wait-rise .7s cubic-bezier(.2, .7, .2, 1) .4s both; }
.ew-wait-status { display: flex; align-items: center; gap: 12px; margin-top: 24px; animation: ew-wait-rise .7s cubic-bezier(.2, .7, .2, 1) .6s both; }
.ew-wait-spinner { flex: none; width: 20px; height: 20px; animation: ew-wait-spin 1.1s linear infinite; }
.ew-wait-spinner circle { fill: none; stroke-width: 2; }
.ew-wait-track { stroke: var(--ew-line-strong); }
.ew-wait-arc { stroke: var(--ew-accent); stroke-linecap: round; stroke-dasharray: 14 56.55; animation: ew-wait-grow .8s ease .7s both; }
/* Zusatztext der Seiten (z. B. „Bilder werden verarbeitet …“, app_cms_pages/accessibility/pictext.php) */
.ew-wait-info { max-width: 420px; margin-top: 20px; text-align: center; animation: ew-wait-rise .5s ease .3s both; }
.ew-wait-info:empty { display: none; }
/* Hochformat (Smartphone): Lichtflecken nach der Höhe bemessen und näher an den Rand, sonst bleiben sie kaum sichtbar
   (auch der Hintergrund der Anmeldeseiten, .ew-auth-bg) */
@media (orientation: portrait) {
    .ew-wait-layer .ew-lights::before,
    .ew-wait-layer .ew-lights::after,
    .ew-auth-bg .ew-lights::before,
    .ew-auth-bg .ew-lights::after { width: 75vh; padding-bottom: 75vh; }
    .ew-wait-layer .ew-lights::before,
    .ew-auth-bg .ew-lights::before { top: -25%; }
    .ew-wait-layer .ew-lights::after,
    .ew-auth-bg .ew-lights::after { bottom: -30%; }
}

@keyframes ew-wait-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ew-wait-rise { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes ew-wait-grow { from { stroke-dasharray: 0 56.55; } to { stroke-dasharray: 14 56.55; } }
@keyframes ew-wait-spin { to { transform: rotate(360deg); } }

.ew-wait-boot .ew-wait,
.ew-wait-boot .ew-wait > .ew-lights,
.ew-wait-boot .ew-wait-logo,
.ew-wait-boot .ew-wait-status,
.ew-wait-boot .ew-wait-info,
.ew-wait-boot .ew-wait-arc { animation: none; }

@media (prefers-reduced-motion: reduce) {
    .ew-wait > .ew-lights,
    .ew-wait-logo,
    .ew-wait-status,
    .ew-wait-info,
    .ew-wait-arc { animation: none; }
    .ew-wait-spinner { animation-duration: 2.4s; }
}
