/* Navigation der Warenwirtschaft. Journal-Seiten haben einen eigenen Rahmen. */
.mobil-leiste, .mobil-bereich, .bereich-eingeklappt.nur-mobil { display: none; }

@media screen {
    .lc-app:not(.chromeless) { height: 100dvh; min-height: 0; }
    .lc-app:not(.chromeless) .lc-sidebar:not(.open) { display: none; }
    .lc-app:not(.chromeless) .lc-main { height: 100%; width: 100%; }
    .lc-app .mobil-leiste {
        display: flex; align-items: center; justify-content: space-between;
        width: 100%; gap: .5rem; min-height: 48px;
    }
    .mobil-leiste > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobil-leiste button, .lc-sidebar .mobil-bereich {
        min-height: 44px; padding: .5rem .8rem;
        color: inherit; font: inherit; font-weight: 600; border-radius: .6rem;
    }
    .mobil-leiste button { background: transparent; border: 1px solid currentColor; }
    .lc-app .lc-topbar { min-height: 0; padding: 4px 12px; }
    .lc-app .lc-topbar > .page-title { display: none; }
    /* Einige Werkzeuge setzen display:flex direkt am Element. */
    .lc-app:not(.mobil-werkzeuge-offen) .lc-topbar > :not(.mobil-leiste) { display: none !important; }
    .lc-app.mobil-werkzeuge-offen .lc-topbar { max-height: 70dvh; overflow: auto; }
    .lc-app .lc-tabs { flex-wrap: nowrap; overflow-x: auto; flex-shrink: 0; }
    .lc-app .lc-tabs .lc-tab { flex: none; }
    .lc-app .lc-tabs-hint { display: none; }

    .lc-app .lc-sidebar:not(.open) .lc-nav, .lc-app .lc-sidebar:not(.open) .lc-brand,
    .lc-app .lc-sidebar:not(.open) .mobil-menuekopf { display: none; }
    .lc-app.bereich-fenster .lc-sidebar:not(.open) {
        position: fixed; left: -260px; width: 248px; transform: none;
    }
    .lc-app.mobil-menue-offen .lc-main { display: none; }
    .lc-app.mobil-menue-offen .lc-sidebar.open {
        position: static; inset: auto; transform: none; flex: 1; width: 100%; height: 100%;
        padding: 0 max(10px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(10px, env(safe-area-inset-left));
    }
    .mobil-menuekopf { padding: 6px 10px; border-bottom: 1px solid #53617a; }
    .lc-sidebar.open .lc-brand { display: none; }
    .lc-sidebar.open .lc-nav { display: block; overflow-y: auto; overscroll-behavior: contain; }
    .lc-sidebar.open .bereich-nav, .lc-sidebar.open .bereich-hauptnavigation,
    .lc-sidebar.open .bereich-scroll { display: block; overflow: visible; }
    .lc-sidebar.open .bereich-hauptnavigation > a[aria-expanded],
    .lc-sidebar.open .bereich-eingeklappt.nur-desktop { display: none; }
    .lc-sidebar.open .bereich-eingeklappt.nur-mobil { display: block; }
    .lc-sidebar.open .mobil-bereich {
        display: flex; width: 100%; align-items: center; gap: 10px; text-align: left;
        background: transparent; border: 0;
    }
    .lc-sidebar.open .mobil-bereich[aria-expanded="true"] { background: rgba(104, 150, 255, .22); }
    .mobil-pfeil { margin-left: auto; }
    .lc-sidebar.open .lc-nav a { min-height: 44px; font-size: .95rem; }

    .lc-app .lc-content { padding-inline: clamp(10px, 3vw, 20px); min-width: 0; }
    .lc-content .row-2, .lc-content .row-3 { grid-template-columns: minmax(0, 1fr); }
    .lc-content .lc-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 8px; }
    .lc-content .lc-stat { min-width: 0; padding: 12px; overflow-wrap: anywhere; }
    .lc-content .lc-stat .label { padding-right: 18px; }
    .lc-content .lc-stat .value { font-size: 1.35rem; }
    .lc-content .lc-card { min-width: 0; }
    .lc-content .lc-card > .hd, .lc-content .page-head { flex-wrap: wrap; gap: 8px; overflow-wrap: anywhere; }
    .lc-content .lc-card > .bd { padding-inline: 12px; }
    :root .lc-app .lc-content .page-head > .lc-btn,
    :root .lc-app .lc-content .lc-modal .ft .lc-btn { min-height: 44px; }
    .lc-content .lc-editorkopf { position: static; }
    .lc-app .lc-content .lc-reiter { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
    :root .lc-app .lc-content .lc-reiter > button { flex: 0 0 auto; min-width: max-content; min-height: 44px; white-space: nowrap; }
    .lc-content .lc-field { min-width: 0; }
    .lc-content .lc-field :is(input:not([type=checkbox],[type=radio]), select, textarea) {
        max-width: 100%; min-height: 44px; font-size: 16px;
    }
    .lc-content [data-mobil-kundenkopf="zu"] > [data-mobil-nebenaktion] { display: none; }
    .lc-content :not([data-mobil-liste]) > .lc-table-wrap { max-width: 100%; overflow-x: auto; }

    .mobil-spaltenwahl { min-height: 44px; margin: 8px; }
    [data-mobil-liste] > .lc-table-wrap > table,
    [data-mobil-liste] > .lc-table-wrap > table > :is(thead, tbody) { display: block; width: 100%; min-width: 0; }
    [data-mobil-liste="karten"] > .lc-table-wrap > table > thead { display: none; }
    [data-mobil-liste] > .lc-table-wrap > table > thead > tr { display: flex; flex-wrap: wrap; padding: 0 8px 8px; }
    [data-mobil-liste] > .lc-table-wrap > table > thead th { position: static; min-height: 44px; width: auto; }
    [data-mobil-liste] > .lc-table-wrap > table > thead th:last-child { margin-left: auto; }
    [data-mobil-liste] > .lc-table-wrap > table > tbody > tr {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr));
        gap: 8px 12px; margin: 0 8px 10px; padding: 12px;
        border: 1px solid var(--lc-border); border-radius: 9px;
    }
    [data-mobil-liste] .lc-table > tbody > tr > td {
        display: block; min-width: 0; padding: 0; border: 0; text-align: start;
        white-space: normal !important; overflow-wrap: anywhere;
    }
    [data-mobil-liste] .lc-table > tbody > tr > td:empty { display: none; }
    [data-mobil-liste] td[data-mobil-titel]::before {
        content: attr(data-mobil-titel); display: block; color: var(--lc-muted); font: 600 .77rem/1.5 system-ui;
    }
    [data-mobil-liste] td:is([colspan], [data-mobil-feld="firma"], [data-mobil-feld="company"]) { grid-column: 1 / -1; }
}

/* Servicefallliste auf dem Telefon. Das Layout aktiviert dieses Stylesheet nur auf Handys. */
@media screen {
    .lc-content [data-sf-handykopf] { gap: 8px; align-items: center; }
    .lc-content [data-sf-handykopf] > h1 { margin: 0; }
    .lc-content [data-sf-handykopf] > .spacer { flex-basis: 100%; height: 0; }
    .lc-content .sf-handy-sicht { display: grid; gap: 4px; margin-bottom: 8px; }
    .sf-handy-sicht > span { font-size: .8rem; font-weight: 600; color: var(--lc-muted); }
    .lc-content :is(.sf-handy-sicht, .sf-handy-listenwahl, .sf-werkzeuge[data-sf-filter]) select {
        min-width: 0; width: 100%; max-width: 100% !important; min-height: 44px; font-size: 16px;
    }
    .lc-content .sf-werkzeuge[data-sf-filter] {
        display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch;
    }
    .sf-werkzeuge[data-sf-filter] > * { grid-column: 1 / -1; min-width: 0; }
    .lc-content .sf-werkzeuge[data-sf-filter] > .sf-suche {
        grid-column: 1; grid-row: 1; min-width: 0; width: 100%; max-width: none;
    }
    .sf-werkzeuge[data-sf-filter] .sf-suche input { min-width: 0; font-size: 16px; }
    .sf-werkzeuge[data-sf-filter] > .sf-handy-filterknopf { grid-column: 2; grid-row: 1; min-height: 44px; }
    .sf-werkzeuge[data-sf-filter="zu"] > :not(.sf-suche, .sf-handy-filterknopf) { display: none !important; }
    .sf-werkzeuge[data-sf-filter] :is(.lc-laenderfilter, .sf-garantiefilter) { flex-wrap: wrap; }
    .sf-werkzeuge[data-sf-filter] > .sf-versand { margin-inline-start: 0; }
    .lc-content .sf-ub:is(.sf-ub-zu, .sf-ub-vorgabe) { padding: 0 8px; }
    .lc-content .sf-ub:is(.sf-ub-zu, .sf-ub-vorgabe) .sf-ub-kopf > :not(.sf-ub-schalter),
    .lc-content .sf-ub-vorgabe :is(.sf-ub-nur-breit, .sf-ub-kacheln, .sf-ub-laedt) { display: none; }
    .lc-content .sf-ub .sf-ub-schalter { min-height: 44px; text-align: start; }
    .lc-content .sf-ub-vorgabe .sf-ub-nur-schmal { display: inline-flex; align-items: center; gap: 4px; }
    .sf-handy-listenwahl { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
    .lc-content .sf-handy-listenwahl > .lc-btn { min-height: 44px; white-space: nowrap; }
    .lc-content [data-sf-karten] .lc-sf-haupt > table.lc-table,
    .lc-content [data-sf-karten] .lc-sf-haupt > table > tbody { display: block; width: 100%; min-width: 0; }
    .lc-content [data-sf-karten] .lc-sf-haupt thead { display: none; }
    .lc-content [data-sf-karten] .lc-sf-haupt tbody tr {
        display: grid; grid-template-columns: minmax(0, 1fr); padding: 10px 12px; gap: 4px;
        background: var(--lc-surface); border-bottom: 1px solid var(--lc-border);
    }
    .lc-content [data-sf-karten] .lc-sf-haupt tbody td {
        width: auto; max-width: none; min-width: 0; padding: 0; border: 0;
        text-align: start; white-space: normal; overflow-wrap: anywhere; overflow: visible;
    }
    .lc-content [data-sf-karten] .lc-sf-haupt tbody td:not(.sf-nrzelle, :nth-child(2), .sf-schlagwoerter, .lc-sf-aktion),
    .lc-content [data-sf-karten] .lc-sf-haupt .lc-sf-aktion:not(:has(*)) { display: none; }
    .lc-content [data-sf-karten] .lc-sf-haupt .sf-nrzelle { justify-self: start; padding: 3px 8px; border-radius: 6px; }
    .lc-content [data-sf-karten] .lc-sf-haupt td:nth-child(2) { font-weight: 650; }
}

@media screen {
    .lc-app .lc-sidebar.open .lc-nav :is(a, .mobil-bereich) {
        min-width: 0; min-height: 44px; padding: 9px 12px;
        font-size: 1rem; line-height: 1.35; white-space: normal; overflow-wrap: anywhere;
    }
    .lc-sidebar.open .mobil-bereich strong { min-width: 0; text-align: start; }
    .lc-sidebar.open :is(.chip, .mobil-pfeil) { flex-shrink: 0; }
    .lc-sidebar.open .bereich-eingeklappt { margin: 2px 0 12px 12px; }
    .lc-sidebar.open .bereich-menuegruppe h3 {
        margin: 10px 12px 2px; font-size: .85rem; line-height: 1.45; letter-spacing: .02em;
    }
    .handy-einstellungsauswahl {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
        gap: 10px; padding: 12px; margin-bottom: 14px; border: 1px solid var(--lc-border);
        border-radius: 9px; background: var(--lc-surface);
    }
    .handy-einstellungsauswahl label { display: grid; gap: 4px; min-width: 0; font-weight: 600; }
    .lc-content .handy-einstellungsauswahl select { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; }
    .handy-reitermenue {
        border: 1px solid var(--lc-border); border-radius: 9px;
        background: var(--lc-surface); margin-bottom: 12px;
    }
    .handy-reitermenue summary {
        min-height: 48px; padding: 8px 12px; cursor: pointer; overflow-wrap: anywhere;
    }
    .handy-reitermenue summary span { font-size: .9rem; }
    .handy-reitermenue summary strong { display: block; margin-inline-start: 1rem; }
    .lc-app .lc-content .handy-reitermenue .lc-reiter {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
        gap: 4px; padding: 6px; overflow: visible;
    }
    :root .lc-app .lc-content .handy-reitermenue .lc-reiter > button {
        min-width: 0; height: auto; padding: 8px 12px; text-align: start;
        white-space: normal; overflow-wrap: anywhere; line-height: 1.4;
    }
    .lc-content .handy-reitermenue .reiter-beschriftung { white-space: normal; }

    /* Eigene Sichtenschalter nutzen je nach Fachseite Links oder Schaltflächen. */
    html[data-design] .lc-app .lc-content :is(.er-reiter, .crm-gruppierung),
    html[data-design] .lc-app .lc-content :not(.lc-filterbar, .hd):has(> .lc-btn.lc-ansichtsreiter):not(:has(> :not(.lc-btn.lc-ansichtsreiter))) {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
        max-width: 100%; border-radius: 10px; align-items: stretch;
    }
    html[data-design] .lc-app .lc-content :is(.lc-btn.lc-ansichtsreiter, .er-reiter > .lc-btn, .crm-gruppierung > .lc-btn) {
        flex: 1 1 11rem; min-width: 0; max-width: 100%; min-height: 44px !important;
        height: auto; white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
    }
}


/* Das Layout lädt diese Regeln ausschließlich auf Smartphones. */
@media screen {
    .lc-modal-back {
        padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
                 max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
        align-items: center;
    }
    .lc-modal-backdrop + .lc-modal {
        top: max(6px, env(safe-area-inset-top));
    }
    html[data-design] :is(.lc-modal, .lc-card[role="dialog"], dialog[open]) {
        box-sizing: border-box;
        min-width: 0 !important;
        max-width: min(100%, calc(100vw - 12px)) !important;
        max-height: calc(100dvh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
        overflow: auto;
        overscroll-behavior: contain;
    }
    html[data-design] :is(.lc-modal, [role="dialog"], [role="alertdialog"], dialog[open],
                          main[data-lc-detail], .lc-content:has(.lc-editorkopf)) {
        overflow-wrap: anywhere;
        & :is(button, .lc-btn, summary):not(.lc-back, [data-lc-back]) {
            min-height: 44px !important;
            height: auto;
            max-width: 100%;
            white-space: normal !important;
            overflow-wrap: anywhere;
            line-height: 1.35;
            font-size: max(14px, .95rem) !important;
        }
        & :is(input:not([type="checkbox"],[type="radio"],[type="hidden"],[type="range"],[type="color"]), select, textarea) {
            min-width: 0 !important;
            max-width: 100% !important;
            min-height: 44px !important;
            font-size: max(16px, 1rem) !important;
            box-sizing: border-box;
        }
        & :is(label, small, .muted, .lc-field > span, .lc-hint, .hint) {
            font-size: max(14px, .9rem) !important;
            line-height: 1.45;
        }
        & :is(.lc-field, fieldset, .lc-search, .lc-filterbar) {
            min-width: 0 !important;
            max-width: 100%;
        }
        & :is(.hd, .ft, .lc-filterbar, .lc-toolbar, .page-head) {
            flex-wrap: wrap;
            gap: 8px;
        }
        & :is(.lc-table-wrap, .table-responsive) {
            max-width: 100%;
            min-width: 0;
            overflow-x: auto;
        }
        & :is(.hd, .ft, .page-head) > * { min-width: 0; max-width: 100%; }
    }
    html[data-design] :is(.lc-modal, .lc-card[role="dialog"]) :is(.hd, .bd, .ft) { padding-inline: 12px; }
    html[data-design] .lc-modal .ft .lc-btn { min-width: 0; flex: 1 1 9rem; }
}
@media screen and (max-width: 46rem) {
    html[data-design] :is(.lc-modal, [role="dialog"], [role="alertdialog"], dialog[open],
                          main[data-lc-detail], .lc-content:has(.lc-editorkopf)) {
        & :is(.row-2, .row-3, [style*="grid-template-columns" i]) {
            grid-template-columns: minmax(0, 1fr) !important;
        }
        & :is(.row-2, .row-3, [style*="grid-template-columns" i]) > * {
            min-width: 0; max-width: 100%; grid-column: auto !important;
        }
        & :is(div, section, fieldset, footer, header, label)[style*="flex" i]:not(.lc-reiter) {
            flex-wrap: wrap;
            min-width: 0 !important;
            max-width: 100%;
        }
        & :is(.hd, .ft) :is(div, section):has(> button) { flex-wrap: wrap; max-width: 100%; }
    }
    /* Kurze Querformate und die Bildschirmtastatur lassen wenig Höhe.
       Der gesamte Dialog scrollt, auch wenn Kopf und Fuß mehrzeilig werden. */
    html[data-design] .lc-modal :is(.hd, .ft) { position: static; }
}
@media screen and (max-height: 32rem) {
    html[data-design] .lc-modal { display: block; }
    html[data-design] .lc-modal > .lc-card { display: block; overflow: visible; max-height: none; }
    html[data-design] .lc-modal .bd { max-height: none; overflow-y: visible; }
}

@media screen {
    html[data-design] :is(.lc-modal, [role="dialog"], [role="alertdialog"], dialog[open],
                          main[data-lc-detail], .lc-content:has(.lc-editorkopf)) p {
        font-size: max(15px, 1rem);
        line-height: 1.45;
    }
    html[data-design] :is(.lc-modal, [role="dialog"]) :is(p,[style*="font-size" i]):not(h1,h2,h3,button,input,select,textarea) {
        font-size: max(14px, .95rem) !important;
    }
    html[data-design] .kvlog-dialog .muted > label { display: block; margin: 6px 0 0 !important; }
    html[data-design] .lc-modal .ap-toolbar { flex-wrap: wrap; }
    html[data-design] .lc-modal .ap-cat-wrap { min-width: 0; max-width: 100%; flex-wrap: wrap; }
    html[data-design] .lc-modal .ap-toolbar > * { min-width: 0; max-width: 100%; }
}
@media screen and (max-width: 46rem) {
    html[data-design] .lc-modal :is(div, section)[style*="flex" i] > .lc-field {
        flex: 1 1 min(100%, 15rem) !important;
    }
    html[data-design] .sf-raster.sf-raster-log { grid-template-columns: minmax(0,1fr); }
    html[data-design] .sf-logeintrag { min-width: 0; }
    html[data-design] .zn-zeile { flex-wrap: wrap; }
}
@media screen {
    html[data-design] .ap-modal .ap-vksperre-schalter { white-space: normal; min-width: 0; }
    html[data-design] .ap-modal .ap-vksperre-schalter input { flex-shrink: 0; }
    html[data-design] .sf-logaktionen { flex-wrap: wrap; min-width: 0; }
    html[data-design] .sf-logaktionen .lc-btn { min-width: 0; max-width: 100%; }
    html[data-design] .lc-filterbar :is(.lc-btn.sm, label.lc-field) {
        font-size: max(14px, .95rem);
    }
}

@media screen and (max-width: 30rem) {
    html[data-design] .lc-modal .lc-search {
        flex: 1 1 100% !important;
        flex-wrap: nowrap !important;
    }
    html[data-design] .lc-modal .lc-search input { min-width: 0; flex: 1 1 0; }
    html[data-design] .lc-modal .hd:has(> h3) > .spacer:empty { display: none; }
    html[data-design] .lc-modal .hd > h3 { flex: 1 1 9rem; }
    html[data-design] .lc-modal .hd button { min-width: 44px; }
}

@media screen {
    html[data-design] main[data-lc-detail] .lc-reiter button.gesperrt {
        flex-wrap: wrap;
        gap: 2px 5px;
    }
    html[data-design] main[data-lc-detail] .lc-reiter button.gesperrt :is(.reiter-beschriftung, .reiter-gesperrt) {
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    html[data-design] main[data-lc-detail] .reiter-gesperrt { font-size: 14px; }
}

@media screen and (max-width: 40rem) {
    .blatt-dialog .zolltarif-eingabe:has(.hs-auswahl) .bf-wahl { white-space: normal; }
    .blatt-dialog .ze-tabelle:has(.hs-auswahl) {
        & tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
        & :is(th:last-child, .ze-gruppe td, .ze-zelle) { grid-column: 1 / -1; width: auto; }
        & td.ze-name { width: auto; max-width: none; }
        & .ze-nummer { white-space: normal; overflow-wrap: anywhere; }
        & .ze-feldzeile { min-width: 0; }
        & :is(.hs-auswahl, .hs-kandidaten) { grid-template-columns: minmax(0, 1fr); }
        & .hs-kandidaten a { white-space: normal; overflow-wrap: anywhere; }
    }
}
