/*
  EmFlex-Portal – modernes Layout, angelehnt an das emFlex-Terminal.
  Jede Maske behält ihre Farbe aus dem Terminal (WinForms BackColor je Formular), damit man jederzeit erkennt,
  wo man sich befindet: als Hintergrund der Maske und als farbiger Kopf von Dialogen.
  Breite Bildschirme (PC, Tablet): Inhalt links, Menü rechts wie im Terminal.
  Handy (bis 760 px): Kopfleiste oben, Aktionen in einer Leiste unten, Listen als Karten, Dialoge als Vollbild.
  Der Hintergrund hinter Dialogen wird immer abgedunkelt (früher Terminal-Einstellung „Opacity“).
*/
:root {
    /* Maskenfarben aus dem Terminal */
    --maske-hofliste: #A9A9A9;        /* DarkGray  frmHofliste */
    --maske-beleg: #A9A9A9;           /* DarkGray  frmBeleg */
    --maske-position: #00FF00;        /* Lime      frmBelegPosition */
    --maske-abrufauftrag: #A9A9A9;    /* DarkGray  frmAbrufauftrag */
    --maske-kundensuche: #FFFFC0;     /* frmKundensuche */
    --maske-artikelsuche: #696969;    /* DimGray   frmArtikelSuche */
    --maske-adresse: #1E90FF;         /* DodgerBlue frmAdresse */
    --maske-auswahl: #C0C0C0;         /* Silver    frmChoice */
    --maske-eingabe: #C0FFFF;         /* frmInputBox / frmBelegInfo */
    --maske-meldung: #AFEEEE;         /* PaleTurquoise frmMessageBox */
    --maske-fehler: #FFB6C1;          /* LightPink frmMessageBox (Fehler) */
    --maske-kasse: #A9A9A9;           /* DarkGray  frmKasse/frmKassenabrechnung */
    --maske-rueckgeld: #FFE0C0;       /* frmRueckgeld */
    --maske-login: #404040;           /* frmKeyboard */
    --titel: #E30613;                 /* rotes Titel-Label (lblHofliste), etwas satter */

    /* Modernes Grundgerüst */
    --flaeche: #ffffff;
    --flaeche-2: #f4f5f7;
    --linie: rgba(0, 0, 0, .12);
    --text: #1d1f23;
    --text-2: #5b6170;
    --primaer: #1f6feb;
    --ok: #1a9c4b;
    --ok-hell: #d6f5e1;
    --gefahr: #d93025;
    --radius: 12px;
    --radius-klein: 8px;
    --schatten: 0 1px 2px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.10);
    --schatten-gross: 0 12px 40px rgba(0,0,0,.35);
    --kopf-hoehe: 56px;
    --leiste-hoehe: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 16px; color: var(--text); background: var(--maske-hofliste);
    -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; }
/* Kein Doppeltipp-Zoom (iPhone/Android), z. B. beim schnellen Tippen im Rechner; Zwei-Finger-Zoom bleibt möglich */
html, body, button, .knopf, a, input, select, textarea, label, [role=button] { touch-action: manipulation; }
.laden { padding: 2rem; font-size: 1.3rem; display: flex; align-items: center; gap: 14px; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--maske-fehler); padding: .6rem 1rem; z-index: 1000; }

/* Update-Hinweis (js/update.js): unten mittig, über allem, Abstand zur iPhone-Home-Leiste */
.update-hinweis {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: max(1rem, env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 1rem;
    max-width: calc(100vw - 2rem); padding: .7rem .8rem .7rem 1.1rem;
    background: #fff; color: #000; border: 3px solid #4169E1; border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.35); z-index: 3000; font-size: 1.1rem; font-weight: 600;
}
.update-hinweis .knopf { min-height: 0; padding: .5rem 1rem; white-space: nowrap; }
/* Belegmaske ohne Bedienung: Countdown vor dem automatischen Verlassen, oben über allen Dialogen */
.inaktiv-hinweis {
    position: fixed; left: 50%; transform: translateX(-50%);
    top: max(1rem, env(safe-area-inset-top));
    max-width: calc(100vw - 2rem); padding: .8rem 1.2rem; text-align: center;
    background: #FFE4E1; color: #000; border: 3px solid #E00000; border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.35); z-index: 3000; font-size: 1.1rem; font-weight: 600;
    pointer-events: none;
}

/* ---------------------------------------------------------------- Masken */
.maske { min-height: 100vh; display: flex; gap: 6px; padding: 6px; }
/* Tablet/Desktop: Maske genau so hoch wie der sichtbare Bereich, Listen scrollen innen.
   100dvh statt 100vh: In der iOS-Vollbild-WebApp ist 100vh höher als der sichtbare Bereich (oben/unten abgeschnitten).
   Safe-Area: viewport-fit=cover legt die Seite unter Statusleiste und Home-Leiste, daher Abstand per env(). */
@media (min-width: 761px) {
    .maske {
        height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
        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));
    }
    .maske-inhalt { min-height: 0; overflow-y: auto; }
    .maske-inhalt > .grid { min-height: 160px; }
    .maske-menue { min-height: 0; overflow-y: auto; overflow-x: hidden; }   /* nie horizontaler Scrollbalken in der Knopfleiste */
    .maske-menue .titel { overflow-wrap: anywhere; }
}
.maske-hofliste { background: var(--maske-hofliste); }
.maske-beleg { background: var(--maske-beleg); }
.maske-kasse { background: var(--maske-kasse); }
.maske-inhalt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.maske-menue {
    width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px;
    background: rgba(255,255,255,.22); border-radius: var(--radius); padding: 6px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.titel {
    background: var(--titel); color: #fff; font-weight: 700; font-size: 1.45rem; text-align: center;
    padding: 10px 8px; border-radius: var(--radius-klein); user-select: none; letter-spacing: .02em; cursor: default;
}
/* Masken-Titel oben im Seitenbalken: Kopfzeile statt Knopf (bündig, zentriert, ohne Schatten) */
.maske-menue > .titel:first-child {
    margin: -6px -6px 4px; border-radius: var(--radius) var(--radius) 0 0; text-align: center;
    padding: 10px 4px; font-size: 1.25rem; line-height: 1.15; box-shadow: none !important;
    border-bottom: 3px solid rgba(0,0,0,.18);
}
.titel-klein { font-size: .95rem; padding: 6px; box-shadow: none; }/* Titel-Label je Maske in der Menüfarbe des alten Terminals (frmModernForm.MenuColor), damit man sofort sieht, wo man ist */
.titel-beleg { background: #80FF80; color: #10361a; }      /* frmBeleg „Belegerfassung“ */
.titel-kasse { background: #C0C0FF; color: #1d1d5a; }      /* frmKassenabrechnung */
.knopf.knopf-kasse { background: #C0C0FF; color: #1d1d5a; } /* Hofliste: Knopf in der Farbe der Maske Kassenbuch */
.titel-kassenautomat { background: #FFFF80; color: #3d3d00; }                                       /* frmKasse */
.titel-abrufauftrag { background: #FFC080; color: #4a2600; }                                        /* frmAbrufauftrag */
.knopf.knopf-abrufauftrag { background: #FFC080; color: #4a2600; }   /* Hofliste: Knopf in der Farbe der Maske Abrufauftrag */
/* Rückweg zur Hofliste in der Farbe der Hofliste */
.knopf.knopf-hofliste { background: var(--titel); color: #fff; border-color: transparent; }
/* Abrufauftrag-Knopf, wenn der Kunde offene Abrufaufträge hat: Farbe der Abrufauftrag-Maske, Anzahl, dezentes Pulsieren */
.knopf.knopf-abruf-offen {
    background: #FFC080; color: #4a2600; border: 2px solid #E07B00; position: relative;
    animation: abruf-puls 2s ease-in-out infinite;
}
.knopf-abruf-offen .zaehler {
    display: inline-block; min-width: 1.6em; margin-left: 8px; padding: 1px 6px; border-radius: 999px;
    background: #E30613; color: #fff; font-size: .85em; line-height: 1.4;
}
@keyframes abruf-puls { 0%, 100% { box-shadow: 0 0 0 0 rgba(224,123,0,.55); } 50% { box-shadow: 0 0 0 6px rgba(224,123,0,0); } }
/* Zwei gleich breite Knöpfe nebeneinander (Tag zurück / Tag vor) */
.knopf-paar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.knopf-paar .knopf { width: 100%; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: nowrap; font-size: .85rem; }
.titel-zusatz { display: block; font-size: .75rem; font-weight: 500; opacity: .9; letter-spacing: 0; }
.spacer { flex: 1; }
.nur-mobil { display: none !important; }

/* ---------------------------------------------------------------- Knöpfe: groß und touch-tauglich */
.knopf {
    background: var(--flaeche); color: var(--text); border: 1px solid var(--linie); border-radius: var(--radius-klein);
    min-height: 50px; padding: 8px 14px; font-size: 1.02rem; font-weight: 600; cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.08); transition: transform .05s, box-shadow .15s, filter .15s;
}
.knopf:hover:not(:disabled) { box-shadow: 0 3px 10px rgba(0,0,0,.14); }
.knopf:active:not(:disabled) { transform: translateY(1px); filter: brightness(.95); }
.knopf:disabled { opacity: .45; cursor: default; }
.knopf-klein { min-height: 40px; font-size: .92rem; padding: 6px 10px; }
.knopf-ok { background: var(--ok); color: #fff; border-color: transparent; }
.knopf-primaer { background: var(--primaer); color: #fff; border-color: transparent; }
.knopf-abbrechen { background: var(--maske-fehler); }
.knopf-flach { background: transparent; box-shadow: none; border-color: rgba(255,255,255,.35); color: inherit; }
.knopf-reihe { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Abbrechen und Bestätigen unten im Dialog, gleich breit nebeneinander */
.dialog .knopf-reihe.dialog-fuss { flex-wrap: nowrap; }
.dialog .knopf-reihe.dialog-fuss .knopf { flex: 1 1 0; }

/* ---------------------------------------------------------------- Listen (Tabellen) */
.grid { background: var(--flaeche); overflow: auto; flex: 1; border-radius: var(--radius); box-shadow: var(--schatten); }
.grid table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 1.08rem; }
.grid th {
    position: sticky; top: 0; z-index: 1; background: var(--flaeche-2); color: var(--text-2); text-align: left;
    padding: 10px 12px; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--linie);
}
.grid td { padding: 11px 12px; border-bottom: 1px solid var(--linie); white-space: nowrap; }
.grid td.fill { width: 100%; white-space: normal; }
.grid td.zahl, .grid th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr { cursor: pointer; background: var(--flaeche); }
.grid tbody tr:hover td { filter: brightness(.97); }
.grid tr.ausgewaehlt td { outline: 2px solid var(--primaer); outline-offset: -2px; }
/* Per Pfeiltaste markierte Zeile deutlich zeigen; geöffneter Abrufauftrag dezent */
.grid tr.ausgewaehlt td { box-shadow: inset 0 0 0 999px rgba(31,111,235,.12); }
.grid tr.geoeffnet td { font-weight: 600; }
.grid-karten tr.ausgewaehlt { outline: 3px solid var(--primaer); outline-offset: 1px; }
.grid tr.leer td { text-align: center; color: var(--text-2); padding: 28px; cursor: default; }

/* Hofliste-Status (frmHofliste.mFormatGrid) */
.st-neu, .st-neu td { background: #FFF59D !important; }
.st-bearbeitung, .st-bearbeitung td { background: #E6E6E6 !important; }
.st-bestaetigung, .st-bestaetigung td { background: #FFB74D !important; }
.st-bestaetigung-ueberfaellig, .st-bestaetigung-ueberfaellig td { background: #D2691E !important; color: #fff; }
.st-fertig, .st-fertig td { background: #B9F0C8 !important; }
.st-gedruckt, .st-gedruckt td { background: #1E7B34 !important; color: #fff; }
.st-geloescht, .st-geloescht td { background: #E53935 !important; color: #fff; }
.st-uebernommen, .st-uebernommen td { background: #BBDEFB !important; }
.aktuell td { color: #D00000; font-weight: 700; }
td.zelle-kontrollwiegung { background: #1565C0 !important; color: #fff !important; }
td.zelle-bar { background: #E30613 !important; color: #fff !important; }
td.zelle-angebot { background: #00A3E0 !important; color: #fff !important; }
.k-status span { font-weight: 600; }
.gesperrt-symbol::before { content: "🔒 "; }

.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; align-items: center; background: rgba(255,255,255,.35); border-radius: var(--radius-klein); padding: 6px 10px; }
.legende span.farbe { display: inline-block; width: 16px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.3); vertical-align: middle; margin-right: 4px; }

/* Belegart (frmBeleg.txtBelegart) */
.belegart { padding: 6px 12px; font-weight: 700; border-radius: var(--radius-klein); background: var(--flaeche); border: 1px solid var(--linie); }
.belegart-bar { background: #E30613; color: #fff; border-color: transparent; }
.belegart-info { background: #00A3E0; color: #fff; border-color: transparent; }
.belegart-quittung { background: #FFEB3B; }

/* ---------------------------------------------------------------- Formularfelder */
.felder {
    display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 6px 10px; align-items: center;
    background: rgba(255,255,255,.55); padding: 8px; border-radius: var(--radius); box-shadow: var(--schatten);
}
.felder label { font-weight: 600; color: #2b2f36; font-size: .92rem; }
.felder .feld-breit { grid-column: span 3; }   /* über Feld, Label und Feld der 4-Spalten-Ansicht */
.felder-buchung { grid-template-columns: max-content 1fr max-content 160px max-content; }
.feld {
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius-klein);
    padding: 8px 10px; min-height: 40px; font-size: 1.05rem;
}
input.feld, select.feld, textarea.feld { width: 100%; }
/* Hofliste breit: Suchfeld mit kleinem, bei Bedarf zweizeiligem Hinweis statt Label „Belegsuche“ */
.such-rahmen { position: relative; }
.such-rahmen .feld { font-size: .9rem; }
.such-hinweis {
    position: absolute; inset: 0; padding: 3px 10px; display: flex; flex-direction: column; justify-content: center;
    font-size: .75rem; line-height: 1.2; color: var(--text-2); pointer-events: none; white-space: nowrap; overflow: hidden;
}
.such-hinweis b { font-size: .8rem; color: var(--text); }
input.feld:focus, select.feld:focus, textarea.feld:focus { outline: none; border-color: var(--primaer); box-shadow: 0 0 0 3px rgba(31,111,235,.2); }
.such-feld { font-size: 1.25rem; }
.summen { display: grid; grid-template-columns: repeat(3, max-content 150px); gap: 6px 10px; align-items: center; justify-content: end;
          background: rgba(255,255,255,.55); padding: 6px 8px; border-radius: var(--radius); }
.summen .summe-end { font-size: 1.4rem; }
.summen .feld { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Fahrzeug-Tara (Einfahrt) rechts im KFZ-Feld des Kopfs, reine Anzeige */
.feld-kfz { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.feld-kfz .kfz-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feld-kfz .kfz-tara { flex: 0 0 auto; color: var(--text-2); font-size: .85em; white-space: nowrap; }
.feld-kfz .kfz-tara b { color: var(--text); font-variant-numeric: tabular-nums; }
.zeile-minus, .zeile-minus td { background: #FFE0E6 !important; }
.zeile-mindestwert, .zeile-mindestwert td { background: #ECECEC !important; }
.suche-mobil { display: none; }

/* ---------------------------------------------------------------- Hinweise */
.banner { padding: 10px 14px; font-weight: 600; border-radius: var(--radius-klein); box-shadow: var(--schatten); }
.banner-sperre { background: var(--maske-fehler); }
.banner-wiegung { background: #CFE8FF; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner-info { background: #FFFBE0; }
.waage { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; }
.waage .led { width: 11px; height: 11px; border-radius: 50%; background: #E53935; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.waage .led.an { background: #2ECC71; }
.stoerung { background: #FFE0E0; color: #8B0000; font-weight: 700; font-size: .85rem; padding: 6px 8px; border-radius: var(--radius-klein); }

/* ---------------------------------------------------------------- Dialoge: Hintergrund immer abgedunkelt */
.dialog-hg {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(10, 12, 16, .62); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    animation: einblenden .12s ease-out;
}
.dialog {
    min-width: 520px; max-width: 96vw; max-height: 94vh; overflow: auto; padding: 16px;
    border-radius: var(--radius); box-shadow: var(--schatten-gross); display: flex; flex-direction: column; gap: 12px;
    border-top: 8px solid rgba(0,0,0,.18); animation: hochfahren .16s ease-out;
}
.dialog-breit { width: 900px; }
.dialog-gross { width: 1000px; height: 80vh; }
.dialog h2 { margin: 0; font-size: 1.35rem; }
.d-position { background: var(--maske-position); transition: background-color .2s; }
/* Negative Menge/Betrag: LightPink wie frmBeleg-Positionszeile (dMenge < 0) */
.d-position.d-minus { background: var(--maske-fehler); }
/* Dialog mit farbiger Titelzeile: kein zusätzlicher Rand oben */
.d-mit-kopf { border-top: none; }
.d-abrufauftrag { background: var(--maske-abrufauftrag); border-top: none; }
/* Farbige Titelzeile über die ganze Dialogbreite (MenuColor der alten Maske) */
.dialog h2.dialog-kopf { margin: -16px -16px 0; padding: 12px 16px; border-radius: var(--radius) var(--radius) 0 0;
                          border-bottom: 3px solid rgba(0,0,0,.18); }
/* Filter wie frmAbrufauftrag: Silber, gewählter Filter RoyalBlue */
.filter-reihe .knopf { background: #C0C0C0; }
.filter-reihe .knopf.knopf-ok { background: #4169E1; color: #fff; }
.d-kundensuche { background: var(--maske-kundensuche); }
.d-artikelsuche { background: var(--maske-artikelsuche); color: #fff; }
.d-artikelsuche .grid { color: var(--text); }
.d-adresse { background: var(--maske-adresse); color: #fff; }
.d-adresse .feld { color: var(--text); }
.d-auswahl { background: var(--maske-auswahl); }
.d-eingabe { background: var(--maske-eingabe); }
.d-meldung { background: var(--maske-meldung); }
.d-fehler { background: var(--maske-fehler); }
.d-rueckgeld { background: var(--maske-rueckgeld); }
/* Zahlen und Beträge immer rechtsbündig */
.zahl, .feld.zahl, input.zahl { text-align: right; font-variant-numeric: tabular-nums; }

/* Positionsmaske wie frmBelegPosition: 2 Spalten, Beschriftungen links, Werte rechtsbündig */
.pos-raster { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px 22px;
              background: rgba(255,255,255,.35); border-radius: var(--radius); padding: 14px; }
.pos-block { display: flex; flex-direction: column; gap: 8px; }
.pos-zeile { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 8px; }
.pos-zeile > label { font-weight: 600; font-size: 1.05rem; }
.pos-gewicht .pos-zeile > label { font-size: 1.2rem; text-align: right; }
.pos-wert { min-width: 0; flex-wrap: nowrap; }
.pos-artikel { min-width: 90px; background: #f0f0f0; }
.pos-bestand { width: 100px; background: #f0f0f0; }
.pos-hinweis { font-size: .85rem; color: #24502f; white-space: nowrap; }
.pos-rechts { text-align: right; }
.pos-umrechnung { font-size: 1.05rem; font-weight: 600; }
.feld.pos-zahl, input.feld.pos-zahl { width: 130px; flex: 0 0 auto; font-size: 1.15rem; }
.pos-gewicht .feld.pos-zahl { width: 150px; font-size: 1.35rem; font-weight: 700; }
.pos-netto { background: #e9e9e9; }
.pos-gesamt { font-weight: 700; background: #e9e9e9; }
.pos-einheit { white-space: nowrap; font-size: .95rem; }
/* Preisliste: dezenter Auswahl-Knopf direkt hinter dem Gesamtpreis (wie ein unterstrichener Hinweis) */
.pos-preisliste {
    background: none; border: none; border-bottom: 1px dashed rgba(0,0,0,.4); border-radius: 0; padding: 2px 1px; margin-left: 4px;
    font: inherit; font-size: .9rem; color: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.pos-preisliste:hover:not(:disabled) { border-bottom-style: solid; }
.pos-preisliste:disabled { border-bottom-color: transparent; cursor: default; color: inherit; }
/* Gewichtszeilen: Feld, Einheit (darf umbrechen), +Wiegen bleibt immer im Dialog */
.pos-wert-gewicht { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.pos-wert-gewicht .pos-einheit { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
/* Umrechnung (z. B. „= 63,5 m²“) als kleine Zeile unter dem Feld */
.pos-umr { margin-top: -6px; font-size: .82rem; color: #24502f; padding-left: 4px; }
.pos-gewicht .pos-umr { text-align: right; padding-right: calc(100% - 150px); }
.pos-wert-gewicht .pos-wiegen { flex: 0 0 auto; margin-left: auto; }
/* Schmale Gewichtsspalte (Dialog nur wenig breiter als das Handy-Layout, z. B. Tablet hochkant oder kleines Fenster):
   Beschriftung, Feld und +Wiegen kompakter, damit nichts rechts aus dem Dialog ragt; notfalls bricht +Wiegen um */
.pos-gewicht { container-type: inline-size; }
@media (min-width: 761px) {
    @container (max-width: 360px) {
        .pos-gewicht .pos-zeile { grid-template-columns: 74px minmax(0, 1fr); gap: 6px; }
        .pos-gewicht .pos-zeile > label { font-size: 1.05rem; }
        .pos-gewicht .feld.pos-zahl { width: 96px; font-size: 1.15rem; }
        .pos-gewicht .pos-umr { padding-right: calc(100% - 96px); }
        .pos-wert-gewicht { gap: 6px; flex-wrap: wrap; }
        .pos-wert-gewicht .pos-einheit { flex: 0 0 auto; }
        .pos-wert-gewicht .pos-wiegen { padding-left: 10px; padding-right: 10px; }
    }
}
/* Anklickbare Anzeigefelder (Bestand, Rabatt) */
button.feld.pos-klickbar { font: inherit; color: inherit; cursor: pointer; text-align: right; }
button.feld.pos-klickbar:hover:not(:disabled) { border-color: var(--primaer); }
button.feld.pos-klickbar:disabled { cursor: default; }
/* Bestandsübersicht */
.d-bestand { min-width: 420px; }
.bestand-text { color: var(--text-2); margin-top: -6px; }
.bestand-tabelle { border-collapse: collapse; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.bestand-tabelle td { padding: 6px 8px; }
.bestand-tabelle td:nth-child(2) { width: 1.2em; text-align: center; color: var(--text-2); }
.bestand-tabelle .bestand-summe td { border-top: 2px solid rgba(0,0,0,.3); font-weight: 700; }
.pos-warnung { color: #c00000; font-weight: 700; }
.pos-zuordnung { justify-content: flex-start; }
.pos-zuordnung .knopf { width: 100%; }
.pos-zuordnung .knopf.gewaehlt { background: #FF0000; color: #fff; border-color: transparent; }

/* Positionsmaske: Gewichtszeilen in allen Layouts [frei][+Wiegen][Beschriftung][Feld][Einheit].
   +Wiegen steht direkt links vor der Beschriftung; feste Spalten, damit die Knöpfe von Brutto und Tara exakt übereinander
   stehen und alle Felder rechtsbündig untereinander. Umrechnung klein unter dem Feld. Breiten je Layout über Variablen. */
.d-position { --pos-label-b: 92px; --pos-feld-b: 150px; --pos-einh-b: 30px; }
.d-position .pos-gewicht .pos-zeile {
    grid-template-columns: minmax(0, 1fr) auto var(--pos-label-b) var(--pos-feld-b) var(--pos-einh-b); column-gap: 6px; row-gap: 0;
}
.d-position .pos-gewicht .pos-wert-gewicht { display: contents; }
.d-position .pos-gewicht .pos-wiegen { grid-column: 2; grid-row: 1; margin: 0; }
.d-position .pos-gewicht .pos-zeile > label { grid-column: 3; grid-row: 1; text-align: left !important; white-space: nowrap; }
.d-position .pos-gewicht .feld.pos-zahl { grid-column: 4; grid-row: 1; width: 100%; }
.d-position .pos-gewicht .pos-einheit { grid-column: 5; grid-row: 1; min-width: 0; }
.d-position .pos-gewicht .pos-zeile > span:empty { display: none; }
.d-position .pos-gewicht .pos-umr { grid-column: 4 / 6; grid-row: 2; text-align: right; padding-right: calc(var(--pos-einh-b) + 6px); margin-top: -2px; }
/* Preise rechtsbündig, Preisliste direkt links vor dem Einzelpreisfeld, Preis je Einheit klein darunter */
.d-position .pos-block:not(:first-child):not(.pos-gewicht) .pos-wert.knopf-reihe { justify-content: flex-end; }
.d-position .pos-block:not(:first-child):not(.pos-gewicht) .pos-einheit { min-width: 22px; }
.d-position .pos-block:not(:first-child):not(.pos-gewicht) .pos-umr { text-align: right; padding-right: 30px; }
.d-position .pos-preisliste { order: -1; margin: 0 4px 0 0; text-align: right; }
/* Breit (Browser, Handy quer): unten links die Zuordnung (Einzel-Wiegung, Fahrzeug, Schubkarre) untereinander, gleich breit;
   unten rechts die Preise unter den Gewichten, Felder rechtsbündig mit Brutto/Tara/Menge (gleiche Einheitenspalte) */
@media (min-width: 761px) {
    .d-position .pos-raster > .pos-block:nth-child(1) { order: 1; }
    .d-position .pos-raster > .pos-gewicht { order: 2; }
    .d-position .pos-raster > .pos-zuordnung { order: 3; }
    .d-position .pos-raster > .pos-block:nth-child(3) { order: 4; }
    .d-position .pos-zuordnung { flex-direction: column; align-items: flex-start; gap: 6px; }
    .d-position .pos-zuordnung .knopf { width: 160px; flex: 0 0 auto; white-space: nowrap; }
    .d-position .pos-block:nth-child(3) .pos-wert.knopf-reihe { gap: 6px; }
    .d-position .pos-block:nth-child(3) .pos-einheit { flex: 0 0 var(--pos-einh-b); min-width: var(--pos-einh-b); }
    .d-position .pos-block:nth-child(3) .pos-umr { padding-right: calc(var(--pos-einh-b) + 6px); }
    .d-position .pos-block:nth-child(3) .pos-zahl { width: var(--pos-feld-b); }
}
/* Kurze Einblendung im Positionsdialog (z. B. Ergebnis der Wiegung), überlagert, verschwindet nach 2,5 s */
.d-position { position: relative; }
.pos-meldung { position: absolute; left: 12px; right: 12px; top: 8px; z-index: 5; cursor: pointer; box-shadow: var(--schatten-gross); }
.pos-einblendung {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; max-width: 90%;
    background: rgba(16, 54, 26, .92); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 1.1rem;
    text-align: center; box-shadow: var(--schatten-gross); pointer-events: none; animation: einblenden .15s ease-out;
}

/* Taschenrechner (frmRechner, Flieder) */
.d-rechner { background: #C0C0FF; flex-direction: row; gap: 16px; min-width: 0; width: 640px; outline: none; }
.rechner { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.rechner-anzeige { background: #f0f0f0; border-radius: var(--radius-klein); padding: 10px 14px; text-align: right;
                   font-size: 2rem; font-variant-numeric: tabular-nums; min-height: 58px; overflow: hidden; }
.rechner-historie { text-align: right; font-size: .9rem; color: #33335a; margin-top: -4px; min-height: 1.3em; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rechner-tasten { display: grid; grid-template-columns: 64px repeat(5, 1fr); grid-auto-rows: 58px; gap: 8px; }
.rechner-tasten .knopf { min-height: 0; font-size: 1.25rem; }
.rechner-tasten .rt-ac { font-size: .85rem; }
.rechner-tasten .rt-tax { font-size: .9rem; }
.rechner-tasten .rt-plus { grid-row: span 2; }
.rechner-seite { width: 140px; display: flex; flex-direction: column; gap: 8px; }
.knopf-rechner { font-size: 1.5rem; min-width: 70px; }

.dialog .meldungstext { font-size: 1.25rem; white-space: pre-line; text-align: center; padding: 12px; }
.gross-zahl { font-size: 2rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
@keyframes einblenden { from { opacity: 0; } to { opacity: 1; } }
@keyframes hochfahren { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- Anmeldung (Gerätefreigabe) */
.anmeldung {
    min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(circle at 20% 10%, #5a5a5a 0, var(--maske-login) 45%, #262626 100%); color: #fff;
}
.anmelde-karte {
    width: 100%; max-width: 440px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.15);
    border-radius: 18px; padding: 28px; box-shadow: var(--schatten-gross); display: flex; flex-direction: column; gap: 12px;
}
.anmelde-karte h1 { margin: 6px 0 0; font-size: 1.5rem; }
.anmelde-karte p { margin: 0; line-height: 1.45; }
.anmelde-karte .hinweis { color: rgba(255,255,255,.78); }
.anmelde-karte .klein { font-size: .85rem; }
.marke { display: flex; flex-direction: column; gap: 14px; }
.marke-bild { display: block; width: 100%; height: auto; }
.marke-titel { font-weight: 700; font-size: 1.35rem; }
.name-eingabe { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.name-eingabe label { font-size: .85rem; opacity: .8; }
.name-eingabe .feld { font-size: 1.2rem; min-height: 50px; color: var(--text); }
.fehlertext { color: #ffb4b4; font-weight: 600; }
.warte-symbol { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; animation: drehen 1s linear infinite; }
.laden .warte-symbol { border-color: rgba(0,0,0,.15); border-top-color: var(--titel); }
@keyframes drehen { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Tablet: etwas kompakter */
@media (max-width: 1100px) {
    .maske-menue { width: 170px; }
    .felder { grid-template-columns: max-content 1fr; }
    .felder .feld-breit { grid-column: auto; }   /* bei 2 Spalten sonst implizite 3. Spalte, die den Kopf verschiebt */
    .maske-menue > .titel:first-child { font-size: 1.1rem; }
    .summen { grid-template-columns: max-content 1fr; justify-content: stretch; }
    .dialog { min-width: 0; width: 96vw; }
}

/* ---------------------------------------------------------------- Belegerfassung: Kopf und Summen kompakt, Platz für die Positionen */
@media (min-width: 761px) {
    .maske-beleg .felder { gap: 4px 8px; padding: 6px 8px; }
    .maske-beleg .felder label { font-size: .85rem; }
    .maske-beleg .felder .feld { min-height: 30px; padding: 3px 8px; font-size: .98rem; }
    .maske-beleg .felder .belegart { padding: 3px 10px; }
    .maske-beleg .felder .knopf-klein { min-height: 30px; padding-top: 2px; padding-bottom: 2px; }
    .maske-beleg .felder .knopf-reihe { gap: 6px; }
    .maske-beleg .summen { gap: 4px 8px; padding: 4px 8px; }
    .maske-beleg .summen .feld { min-height: 30px; padding: 3px 8px; }
    .maske-beleg .summen .summe-end { font-size: 1.2rem; }
}
/* Ab 900 px Kopf in 4 Spalten und Summen in einer Zeile (statt untereinander) */
@media (min-width: 900px) {
    .maske-beleg .felder { grid-template-columns: max-content 1fr max-content 1fr; }
    .maske-beleg .felder .feld-breit { grid-column: span 3; }
    .maske-beleg .summen { grid-template-columns: repeat(3, max-content minmax(90px, 130px)); justify-content: end; }
}
/* Handy quer (breites Layout, geringe Höhe): Summen in einer kompakten Zeile, die nie breiter als der Bildschirm wird.
   Die Felder wachsen nur bis 120 px. */
@media (min-width: 761px) and (orientation: landscape) and (max-height: 500px) {
    .maske-beleg .summen { grid-template-columns: repeat(3, max-content minmax(64px, 120px)); justify-content: end; gap: 4px 6px; padding: 4px 6px; }
    .maske-beleg .summen label { font-size: .8rem; }
    .maske-beleg .summen .feld { min-width: 0; min-height: 28px; padding: 2px 6px; font-size: .95rem; overflow: hidden; }
    .maske-beleg .summen .summe-end { font-size: 1.05rem; }
}

/* ---------------------------------------------------------------- Handy: eigenes, funktionales Layout */
@media (max-width: 760px) {
    body { font-size: 15px; }
    /* Unten Platz für die Aktionsleiste (bis zu zwei Reihen) */
    .maske { flex-direction: column; padding: calc(var(--kopf-hoehe) + env(safe-area-inset-top) + 10px) 10px calc(2 * var(--leiste-hoehe) + 14px); gap: 10px; }

    /* Kopfleiste in Maskenfarbe mit rotem Titel */
    .maske-menue .titel {
        position: fixed; top: 0; left: 0; right: 0; height: var(--kopf-hoehe); z-index: 50; border-radius: 0;
        display: flex; align-items: center; justify-content: center; flex-direction: column; font-size: 1.2rem; padding: 4px 12px;
    }
    .maske-menue > .titel:first-child { margin: 0; border-radius: 0; text-align: center; padding: 4px 12px; font-size: 1.2rem; border-bottom: none; }
    /* Kopfleiste unter der Statusleiste (iPhone-Vollbild mit viewport-fit=cover) */
    .maske-menue .titel { height: calc(var(--kopf-hoehe) + env(safe-area-inset-top)); padding-top: calc(4px + env(safe-area-inset-top)); }
    .maske-menue .titel-klein, .nur-breit { display: none !important; }
    .maske-menue .stoerung { flex: 0 0 auto; white-space: nowrap; }

    /* Menü wird zur Aktionsleiste unten: 4 gleich breite Felder, kein seitliches Verschieben.
       Längere Beschriftungen brechen in zwei Zeilen um statt abgeschnitten zu werden.
       Seltene Aktionen (.mehr) liegen hinter „Mehr“ und klappen als breite 2er-Reihen über der Leiste auf. */
    .maske-menue {
        position: fixed; left: 0; right: 0; bottom: 0; width: auto; z-index: 50;
        display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row dense; align-items: stretch;
        gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        border-radius: 0; background: rgba(255,255,255,.97); box-shadow: 0 -4px 18px rgba(0,0,0,.18);
    }
    .maske-menue .spacer { display: none; }
    .maske-menue .knopf {
        width: 100%; min-width: 0; min-height: 56px; padding: 4px 6px; white-space: normal; line-height: 1.12;
        font-size: .86rem; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
        overflow-wrap: normal; word-break: normal; hyphens: auto; -webkit-hyphens: auto;
    }
    .maske-menue .knopf-paar { grid-column: span 2; }    .maske-menue .knopf-paar .knopf { font-size: .82rem; }
    .maske-menue input[type=date] { min-height: 56px; }
    .maske-menue .stoerung { grid-column: 1 / -1; order: -10; text-align: center; }
    /* Offene Abrufaufträge: eigene breite Zeile über den Hauptaktionen */
    .maske-menue .knopf.knopf-abruf-offen { grid-column: 1 / -1; order: -6; flex-direction: row; min-height: 46px; font-size: .95rem; }
    .mobil-breit-2 { grid-column: span 2; }
    .mobil-breit-3 { grid-column: span 3; }
    .nur-mobil { display: flex !important; }

    /* „Mehr“-Fach */
    .maske-menue .mehr { display: none; }
    .maske-menue.offen { box-shadow: 0 0 0 100vmax rgba(10,12,16,.45), 0 -4px 18px rgba(0,0,0,.18); border-radius: 16px 16px 0 0; padding-top: 12px; }
    .maske-menue.offen .mehr { display: flex; grid-column: span 2; order: -5; min-height: 52px; font-size: .95rem; }
    .knopf-mehr { background: var(--flaeche-2); }
    .maske-menue.offen .knopf-mehr { background: #3a3f4a; color: #fff; }
    .mehr-symbol { font-size: 1.25rem; line-height: 1; margin-bottom: 2px; }

    /* Suchfeld bleibt beim Scrollen unter der Titelleiste stehen (Rand in Maskenfarbe deckt den Spalt ab) */
    .suche-mobil {
        display: block; font-size: 1.1rem; min-height: 48px;
        position: sticky; top: calc(var(--kopf-hoehe) + env(safe-area-inset-top) + 6px); z-index: 20;
        box-shadow: 0 0 0 6px var(--maske-hofliste), 0 4px 10px 6px rgba(0,0,0,.12);
    }
    /* Legende kompakt: eine Zeile mit Farbpunkten unten am Rand, Tippen zeigt die Texte */
    .legende {
        font-size: .78rem; gap: 6px 10px; cursor: pointer; user-select: none;
        position: sticky; bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 20;
        background: rgba(255,255,255,.92); box-shadow: 0 2px 10px rgba(0,0,0,.18); padding: 6px 10px;
    }
    .legende:not(.offen) { flex-wrap: nowrap; }
    .legende:not(.offen) .leg-text { display: none; }
    .legende:not(.offen) span.farbe { margin-right: 0; }
    .legende.offen > span:not(.spacer):not(.leg-hinweis) { flex: 1 1 45%; }
    .leg-hinweis { color: #555; white-space: nowrap; }

    /* Listen als Karten */
    .grid-karten { background: transparent; box-shadow: none; overflow: visible; }
    .grid-karten table, .grid-karten tbody { display: block; }
    .grid-karten thead { display: none; }
    .grid-karten tr {
        display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; margin-bottom: 10px;
        border-radius: var(--radius); box-shadow: var(--schatten); background: var(--flaeche);
    }
    .grid-karten td { display: block; border: none; padding: 0; white-space: normal; text-align: left !important; }
    .grid-karten td.fill { width: auto; }
    .grid-karten td.k-titel { grid-column: 1 / -1; order: -2; font-size: 1.12rem; font-weight: 700; }
    .grid-karten td.k-status { order: -1; grid-column: 1 / -1; justify-self: start; padding: 3px 10px; border-radius: 999px; font-size: .88rem; background: rgba(0,0,0,.06); }
    .grid-karten td.k-kfz { font-weight: 700; letter-spacing: .04em; }
    .grid-karten td.k-betrag { font-weight: 700; font-size: 1.1rem; }
    .grid-karten td.k-nebeninfo { color: var(--text-2); font-size: .88rem; }
    .grid-karten td[data-label]:not(.k-titel):not(.k-status)::before { content: attr(data-label) ": "; color: var(--text-2); font-size: .8rem; }
    .grid-karten td[data-label=""]::before { content: none; }
    /* Belegpositionen: Pos und Artikel links, Menge, E.P. und G.P. rechtsbündig */
    .maske-beleg .grid-karten tr { grid-template-columns: auto 1fr; grid-auto-flow: row dense; }
    .maske-beleg .grid-karten td.k-titel { grid-row: 1; }
    .maske-beleg .grid-karten td[data-label="Pos"] { grid-column: 1; grid-row: 2; }
    .maske-beleg .grid-karten td[data-label="Artikel"] { grid-column: 1; grid-row: 3; }
    .maske-beleg .grid-karten td[data-label="Menge"] { grid-column: 2; grid-row: 2; }
    .maske-beleg .grid-karten td[data-label="E.P."] { grid-column: 2; grid-row: 3; }
    .maske-beleg .grid-karten td[data-label="G.P."] { grid-column: 2; grid-row: 4; }
    .maske-beleg .grid-karten td[data-label="Menge"], .maske-beleg .grid-karten td[data-label="E.P."],
    .maske-beleg .grid-karten td[data-label="G.P."] { text-align: right !important; }
    .maske-beleg .grid-karten td[data-label="Menge"] { font-weight: 700; font-size: 1.1rem; }
    .grid-karten tr.leer { display: block; text-align: center; }
    .st-gedruckt td.k-nebeninfo, .st-geloescht td.k-nebeninfo, .st-gedruckt td::before, .st-geloescht td::before { color: rgba(255,255,255,.85) !important; }


    /* Felder kompakt: Beschriftung links, Wert rechts */
    .felder, .felder-buchung { grid-template-columns: max-content 1fr; gap: 4px 10px; padding: 8px 10px; }
    .felder label { font-size: .78rem; color: var(--text-2); }
    .felder .feld { min-height: 32px; padding: 4px 8px; font-size: .95rem; }
    .felder .knopf-klein { min-height: 32px; }
    .felder-buchung { grid-template-columns: 1fr; }
    .summen { grid-template-columns: 1fr auto; padding: 10px; }
    .summen .feld { min-width: 120px; }

    /* Dialoge als Vollbild-Ansicht */
    .dialog-hg { padding: 0; align-items: stretch; }
    .dialog, .dialog-breit, .dialog-gross { width: 100vw; max-width: 100vw; min-width: 0; height: 100%; max-height: 100%; border-radius: 0; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); }
    .dialog[style] { min-width: 0 !important; width: 100vw !important; }
    .dialog h2.dialog-kopf { margin: -14px -12px 0; padding: 12px; border-radius: 0; }
    .dialog .knopf-reihe .knopf { flex: 1 1 auto; }
    .dialog .grid { max-height: none !important; }
    /* Position auf dem Handy: Beschriftung links, alle Zahlen rechtsbündig untereinander (Feld + Einheit), Menge groß */
    .pos-raster { grid-template-columns: 1fr; padding: 10px; gap: 12px; }
    .pos-block { gap: 6px; }
    .pos-zeile { grid-template-columns: 92px minmax(0, 1fr); gap: 6px; }
    .pos-zeile > label, .pos-gewicht .pos-zeile > label { text-align: left; font-size: .95rem; }
    .pos-gewicht .feld.pos-zahl, .feld.pos-zahl, input.feld.pos-zahl { width: 120px; font-size: 1.05rem; }
    .pos-wert { flex-wrap: nowrap; }
    .pos-wert-gewicht, .pos-block .pos-wert.knopf-reihe { justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
    /* Einheit mindestens 28 px (Felder bündig), längere Texte wie „€ (93,51 €/m³)“ brechen um statt rechts hinauszuragen */
    .pos-wert .pos-einheit, .pos-wert-gewicht .pos-einheit { flex: 0 1 auto; min-width: 28px; width: auto; white-space: normal; }
    .pos-wert-gewicht .pos-wiegen { order: -1; margin-left: 0; margin-right: auto; padding-left: 6px; padding-right: 6px; font-size: .85rem; }
    .pos-preisliste { flex: 1 0 100%; text-align: right; }
    .pos-zeile:has(.pos-preisliste) > label { align-self: start; padding-top: 10px; }
    .pos-umr, .pos-gewicht .pos-umr { text-align: right; padding-right: 34px; }
    /* Artikel und Bestand in einer Zeile */
    .pos-block:first-child .pos-wert.knopf-reihe { justify-content: flex-start; flex-wrap: nowrap; }
    .pos-artikel { min-width: 0; flex: 1 1 auto; }
    .pos-bestand { width: 80px; flex: 0 0 auto; }
    /* Menge: das Wichtigste, groß und fett */
    .pos-menge > label { font-size: 1.15rem !important; font-weight: 700; }
    .pos-menge .feld.pos-zahl, .pos-menge input.feld.pos-zahl { width: 140px; font-size: 1.5rem; font-weight: 700; min-height: 50px; }
    .pos-zuordnung { display: grid; grid-template-columns: 1fr 1fr; }
    .d-rechner { flex-direction: column; }
    .rechner-tasten { grid-template-columns: 52px repeat(5, 1fr); grid-auto-rows: 54px; gap: 6px; }
    .rechner-seite { width: auto; flex-direction: row; flex-wrap: wrap; }
    .rechner-seite .knopf { flex: 1 1 40%; }
    .rechner-seite .spacer { display: none; }
    .gross-zahl { font-size: 1.6rem; }
}
/* Handy/Tablet quer (geringe Höhe): Legende ebenfalls kompakt als eine Zeile mit Farbpunkten, Tippen zeigt die Texte */
@media (orientation: landscape) and (max-height: 500px) {
    .legende { font-size: .78rem; gap: 4px 10px; padding: 3px 8px; cursor: pointer; user-select: none; }
    .legende:not(.offen) { flex-wrap: nowrap; }
    .legende:not(.offen) .leg-text { display: none; }
    .legende:not(.offen) span.farbe { margin-right: 0; }
    .legende.offen > span:not(.spacer):not(.leg-hinweis) { flex: 1 1 30%; }
    .legende .leg-hinweis.nur-mobil { display: inline !important; color: #555; white-space: nowrap; }
}
/* Breit (Browser/Terminal quer): Legende kompakt als Chips mit runden Farbpunkten in einer Zeile */
@media (min-width: 761px) and (min-height: 501px) {
    .legende { gap: 6px; font-size: .78rem; padding: 4px 6px; flex-wrap: nowrap; overflow: hidden; }
    .legende > span:not(.spacer):not(.leg-hinweis):not(.leg-anzahl) {
        display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--text-2); padding: 2px 6px 2px 2px;
    }
    .legende span.farbe { width: 12px; height: 12px; border-radius: 50%; margin-right: 0; border-color: rgba(0,0,0,.25); }
    .legende .leg-anzahl { color: var(--text-2); white-space: nowrap; padding-right: 4px; }
}
/* Hofliste breit: Mein Beleg und Rechner untereinander, wenn die Höhe reicht (Klasse setzt emflex.kachelPlatz nach den Kameras),
   sonst nebeneinander wie cmdMeinBeleg | btnRechner */
@media (min-width: 761px) {
    .maske-menue > .paar-mein-beleg.untereinander { grid-template-columns: minmax(0, 1fr); }
    .maske-menue > .paar-mein-beleg.untereinander .knopf { font-size: 1.02rem; }   /* wie .knopf */
}

/* ---------------------------------------------------------------- Kameras (go2rtc, frmKameraSplit/frmKameraSingle) */
.maske-kameras { background: var(--maske-hofliste); }
.titel-kameras { background: #404040; color: #fff; }
/* Alle Kameras scrollbar, Spalten nach verfügbarer Breite, Bilder immer 16:9 */
.kamera-raster {
    flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 6px; align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); grid-auto-rows: max-content;
}
.kamera-bild {
    position: relative; background: #000; border-radius: var(--radius-klein); overflow: hidden; cursor: pointer;
    min-height: 0; aspect-ratio: 16 / 9;
}
.kamera-video, .kamera-video emflex-kamera { position: absolute; inset: 0; display: block; }
.kamera-titel {
    position: absolute; left: 0; top: 0; padding: 3px 8px; color: #fff; font-weight: 600; font-size: .9rem;
    background: rgba(0,0,0,.45); border-bottom-right-radius: var(--radius-klein); pointer-events: none;
}
.kamera-status {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; color: #ddd; font-size: .85rem;
    text-align: center; pointer-events: none;
}
.kamera-status:empty { display: none; }
.kamera-vollbild { flex: 1; aspect-ratio: auto; }
.kamera-kacheln { display: flex; flex-direction: column; gap: 6px; }
.kamera-kacheln.kamera-kacheln-leer { display: none; }   /* kein Platz für Kacheln im Menü (emflex.kachelPlatz) */
.kamera-kachel .kamera-titel { font-size: .75rem; padding: 2px 6px; }
@media (max-width: 760px) {
    .kamera-raster { grid-template-columns: 1fr; }   /* Handy hochkant: eine Spalte */
    .kamera-vollbild { aspect-ratio: 16 / 9; flex: none; }
    .maske-menue .kamera-kacheln { display: none; }   /* Handy: Aktionsleiste unten, Kameras über die eigene Seite */
}
/* Handy quer (geringe Höhe): zwei Spalten */
@media (orientation: landscape) and (max-height: 500px) {
    .kamera-raster { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- Titelzeile oben statt Knopfspalte (Kameraseite) */
/* Zurück zur Hofliste: kleiner Knopf links in der Titelzeile, immer rot wie das Hofliste-Label */
.titel-zurueck {
    position: absolute; left: 6px; top: 50%; transform: translateY(-50%); height: 34px; padding: 0 14px;
    border: none; border-radius: 8px; background: var(--titel); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35);
    font-size: .9rem; font-weight: 700; letter-spacing: 0; display: flex; align-items: center; cursor: pointer; white-space: nowrap;
}
.titel-zurueck.titel-rechts { left: auto; right: 6px; background: rgba(255,255,255,.18); box-shadow: none; }
/* Belegerfassung: Kurztitel und Knopf-Symbole nur auf dem Handy; Hinweis zu Fertig/Bezahlen */
.titel-kurz, .knopf-symbol { display: none; }
.menue-hinweis { font-size: .85rem; line-height: 1.25; padding: 6px 8px; border-radius: var(--radius-klein); background: #fff4d6; color: #5a4300; }
.menue-hinweis.menue-hinweis-fehler { background: #ffe1e1; color: #8a1010; }
@media (min-width: 761px) {
    .maske.maske-kopf { flex-direction: column; }
    .maske-kopf .maske-menue { order: -1; width: auto; flex-shrink: 0; padding: 0; background: none; box-shadow: none; overflow: visible; }
    .maske-kopf .maske-menue > .titel:first-child { margin: 0; position: relative; border-radius: var(--radius); border-bottom: none; padding: 10px 120px; }
}

/* ---------------------------------------------------------------- Handy: Menü oben im Titel (Hofliste) */
.menue-hintergrund { display: none; }
@media (max-width: 760px) {
    /* Keine Aktionsleiste unten: die Liste reicht bis zum unteren Rand */
    .maske.maske-menue-oben { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    /* Geschlossen: nur Titelleiste (und ggf. Störungshinweis), die Knöpfe liegen hinter dem Menüknopf */
    .maske-menue.menue-oben {
        top: calc(var(--kopf-hoehe) + env(safe-area-inset-top)); bottom: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; background: transparent; box-shadow: none;
    }
    .maske-menue.menue-oben:not(.offen) > :not(.titel):not(.stoerung) { display: none !important; }
    .maske-menue.menue-oben:not(.offen) > .stoerung { margin: 6px 10px 0; }
    /* Offen: Klappmenü unter der Titelleiste */
    .maske-menue.menue-oben.offen {
        padding: 10px 10px 12px; background: rgba(255,255,255,.98);
        border-radius: 0 0 16px 16px; box-shadow: 0 8px 20px rgba(0,0,0,.25);
    }
    .maske-menue.menue-oben.offen .knopf { min-height: 52px; font-size: .95rem; }
    /* Knöpfe untereinander in derselben Reihenfolge wie im Querformat (Dokumentreihenfolge, kein Auffüllen von Lücken);
       Knopfpaare (Mein Beleg | Rechner, Tag zurück | Tag vor) bleiben wie dort nebeneinander */
    .maske-menue.menue-oben.offen { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; }
    .maske-menue.menue-oben.offen > * { grid-column: 1 / -1; }
    /* Mein Beleg und Rechner hier untereinander (das Paar löst sich ins einspaltige Raster auf) */
    .maske-menue.menue-oben.offen > .paar-mein-beleg { display: contents; }
    .maske-menue.menue-oben.offen > .paar-mein-beleg > .knopf { grid-column: 1 / -1; }
    .menue-hintergrund { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(10,12,16,.45); }

    /* Titelleiste: Menüknopf links, Mini-Kacheln rechts */
    .maske-menue > .titel.titel-ecken { padding-left: 58px; padding-right: 58px; }
    .maske-menue > .titel.titel-ecken:has(.kamera-kacheln-mini) { padding-right: 150px; }
    .titel-menueknopf {
        position: absolute; left: 6px; bottom: 6px; width: 44px; height: 44px; padding: 0;
        border: none; border-radius: 10px; background: rgba(255,255,255,.18); color: inherit;
        font-size: 1.5rem; line-height: 1; align-items: center; justify-content: center; cursor: pointer;
    }
    .titel-menueknopf:active, .titel-kameraknopf:active, .titel-zurueck:active { background: rgba(255,255,255,.32); }
    /* Zurück-Knöpfe in der Titelzeile (Kameraseite): Handy unten bündig wie der Menüknopf */
    .titel-zurueck { top: auto; bottom: 6px; transform: none; height: 44px; border-radius: 10px; }
    .titel-zurueck:not(.titel-rechts):active { background: #b8050f; }
    .maske-menue > .titel.titel-ecken:has(.titel-zurueck) { padding-left: 110px; padding-right: 110px; }
    .titel-kameraknopf {
        position: absolute; right: 6px; bottom: 6px; width: 44px; height: 44px; padding: 0;
        border: none; border-radius: 10px; background: rgba(255,255,255,.18); color: inherit;
        font-size: 1.3rem; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer;
    }
    .maske-menue .kamera-kacheln.kamera-kacheln-mini {
        display: flex; flex-direction: row; gap: 4px; position: absolute; right: 6px; bottom: 6px; height: 44px;
    }
    .kamera-kacheln-mini .kamera-kachel { height: 44px; width: auto; aspect-ratio: 16 / 9; border-radius: 6px; }
    .kamera-kacheln-mini .kamera-titel { display: none; }

    /* Belegerfassung: Hofliste oben links im Titel, unten nur noch die Belegaktionen */
    .mobil-breit-4 { grid-column: 1 / -1; }
    /* Titel: „‹ Hofliste“ links, kurzer Titel, rechts zwei Mini-Kacheln */
    .titel-kurz { display: inline; }
    .maske-menue > .titel.titel-ecken:has(.titel-zurueck):has(.kamera-kacheln-mini) { padding-right: 150px; }
    /* Aktionsleiste: abgerundete Fläche, große Knöpfe mit Symbol über dem Text */
    .maske-menue.menue-beleg:not(.menue-leer) {
        gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
        border-radius: 18px 18px 0 0; background: rgba(248,249,251,.98); box-shadow: 0 -6px 20px rgba(0,0,0,.16);
    }
    .menue-beleg .knopf {
        min-height: 60px; border-radius: 14px; font-size: .9rem; font-weight: 700; line-height: 1.1;
        box-shadow: 0 1px 3px rgba(0,0,0,.14);
    }
    .menue-beleg .knopf:disabled { opacity: .4; box-shadow: none; }
    .menue-beleg .knopf-primaer { font-size: 1rem; }
    .menue-beleg .knopf-symbol { display: block; font-size: 1.35rem; line-height: 1; margin-bottom: 4px; font-weight: 400; }
    .menue-beleg .knopf-mehr { background: #e9ecf1; border-color: transparent; }
    .menue-beleg.offen .knopf-mehr { background: #3a3f4a; color: #fff; }
    .menue-beleg.offen .mehr { min-height: 50px; }
    /* Hinweis, warum Fertig/Bezahlen nicht geht: eigene Zeile über den Knöpfen */
    .menue-beleg .menue-hinweis { grid-column: 1 / -1; order: -8; font-size: .82rem; padding: 6px 10px; border-radius: 10px; }
    /* Untere Reihe gleich breit: Pos. neu links, Mehr in der Mitte, Fertig (bzw. Drucken bei „Mein Beleg“) rechts.
       6-Spalten-Raster: je 2 Spalten; die Knöpfe hinter „Mehr“ je 3 Spalten (zwei pro Zeile) */
    .maske-menue.menue-beleg { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-flow: row; }
    .menue-beleg .knopf-primaer.mobil-breit-2 { grid-column: 1 / span 2; order: 10; }
    .menue-beleg .knopf-mehr { grid-column: 3 / span 2; order: 11; }
    .menue-beleg .knopf-fertig { grid-column: 5 / span 2; order: 12; }
    .menue-beleg.offen .mehr { grid-column: span 3; }
    /* Ohne Aktionen (Nur Ansicht, noch nicht gedruckt): keine leere Leiste unten */
    .maske-menue.menue-leer { background: transparent; box-shadow: none; padding: 0; pointer-events: none; }
    .maske-menue.menue-leer > * { pointer-events: auto; }
    .maske-menue.menue-leer > :not(.titel):not(.stoerung) { display: none !important; }
    .maske:has(.menue-leer) { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------- Positionsmaske Handy hochkant: ohne Scrollen
   Titel klein, Zuordnung in einer Zeile, Preisliste neben dem Gesamtpreis, Felder etwas niedriger */
@media (max-width: 760px) {
    .d-position { gap: 8px; }
    .d-position h2 { font-size: 1.05rem; }
    .d-position h2.dialog-kopf { padding: 8px 12px; }
    .d-position .pos-raster { padding: 8px; gap: 8px; }
    .d-position .pos-block { gap: 5px; }
    .d-position .feld { min-height: 36px; padding-top: 3px; padding-bottom: 3px; }
    .d-position .pos-menge .feld.pos-zahl, .d-position .pos-menge input.feld.pos-zahl { min-height: 44px; }
    .d-position .pos-umr { margin-top: -4px; font-size: .74rem; line-height: 1.1; }
    .d-position { --pos-label-b: 84px; --pos-feld-b: 120px; --pos-einh-b: 28px; }
    .d-position .pos-preisliste { flex: 0 1 auto; font-size: .8rem; }
    .d-position .pos-zeile:has(.pos-preisliste) > label { align-self: center; padding-top: 0; }
    /* Zuordnung in einer Zeile, links bündig mit „Abbrechen“, rechts mit „OK“ (Innenabstand des Rasters ausgleichen) */
    .d-position .pos-zuordnung { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0 -8px; }
    .d-position .pos-zuordnung .knopf { min-height: 40px; padding: 4px; font-size: .85rem; line-height: 1.1; }
    .d-position > .knopf-reihe .knopf { min-height: 46px; }
    /* Artikelnummer nicht abschneiden: Hinweis „Bestand“ weglassen (der Bestand-Knopf daneben bleibt), Suchen schmaler */
    .d-position .pos-block:first-child .pos-hinweis { display: none; }
    .d-position .pos-artikel { min-width: 56px; }
    .d-position .pos-block:first-child .knopf-klein { padding-left: 8px; padding-right: 8px; }
    .d-position .pos-bestand { width: 72px; }
}
/* Kleine Handys oder Browser mit Adressleiste (geringe Höhe): noch eine Stufe kompakter */
@media (max-width: 760px) and (max-height: 720px) {
    .d-position { gap: 6px; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
    .d-position h2 { font-size: .95rem; }
    .d-position h2.dialog-kopf { margin-top: -8px; padding: 6px 12px; }
    .d-position .pos-raster { padding: 6px 8px; gap: 6px; }
    .d-position .pos-block { gap: 4px; }
    .d-position .feld { min-height: 32px; }
    .d-position .pos-menge .feld.pos-zahl, .d-position .pos-menge input.feld.pos-zahl { min-height: 38px; font-size: 1.3rem; }
    .d-position .pos-zuordnung .knopf { min-height: 34px; }
    .d-position > .knopf-reihe .knopf { min-height: 40px; }
}

/* ---------------------------------------------------------------- Positionsmaske Handy quer: ohne Scrollen auf ~360 px Höhe
   Felder und Knöpfe niedriger, Titel klein, Zuordnung (Fahrzeug/Schubkarre) nebeneinander in einer Zeile */
@media (min-width: 761px) and (orientation: landscape) and (max-height: 500px) {
    .dialog-hg:has(.d-position) { padding: 4px; }
    .d-position { padding: 6px 12px 8px; gap: 6px; max-height: calc(100vh - 8px); border-top-width: 4px; }
    .d-position h2 { font-size: .95rem; }
    .d-position h2.dialog-kopf { margin: -6px -12px 0; padding: 4px 12px; }
    .d-position .pos-raster { gap: 6px 16px; padding: 6px 8px; }
    .d-position .pos-block { gap: 4px; }
    .d-position .pos-zeile { grid-template-columns: 78px minmax(0, 1fr); gap: 6px; }
    .d-position .pos-zeile > label { font-size: .88rem; }
    .d-position .pos-gewicht .pos-zeile > label { font-size: .95rem; }
    .d-position .feld { min-height: 30px; padding: 2px 8px; font-size: .95rem; }
    .d-position .feld.pos-zahl, .d-position input.feld.pos-zahl { font-size: 1rem; }
    .d-position .pos-gewicht .feld.pos-zahl { width: 120px; font-size: 1.1rem; }
    .d-position .pos-gewicht .pos-umr { padding-right: calc(100% - 120px); }
    .d-position .pos-umr { margin-top: -3px; font-size: .72rem; line-height: 1.1; }
    .d-position .pos-umrechnung { font-size: .88rem; }
    .d-position .knopf { min-height: 32px; padding-top: 3px; padding-bottom: 3px; }
    /* Spaltenbreiten der Gewichtszeilen (Aufbau siehe „Positionsmaske: Gewichtszeilen“) */
    .d-position { --pos-label-b: 70px; --pos-feld-b: 120px; --pos-einh-b: 26px; }
    .d-position .pos-preisliste { font-size: .8rem; }
    /* Zuordnung untereinander, niedriger, damit die Maske ohne Scrollen passt */
    .d-position .pos-zuordnung { gap: 4px; }
    .d-position .pos-zuordnung .knopf { height: 30px; min-height: 30px; width: 130px; font-size: .85rem; }
    /* Große Such-Dialoge (Artikel, Kunde, Abrufauftrag): volle Höhe, kleiner Titel und Knöpfe, damit mehrere Treffer sichtbar sind */
    .dialog-hg:has(.dialog-gross) { padding: 4px; }
    .dialog-gross { height: calc(100vh - 8px); max-height: calc(100vh - 8px); padding: 6px 12px 8px; gap: 6px; border-top-width: 4px; }
    .dialog-gross h2 { font-size: .95rem; }
    .dialog-gross h2.dialog-kopf { margin: -6px -12px 0; padding: 4px 12px; }
    .dialog-gross .feld { min-height: 34px; padding-top: 3px; padding-bottom: 3px; }
    .dialog-gross .knopf { min-height: 34px; padding-top: 3px; padding-bottom: 3px; }
    .dialog-gross .grid td { padding-top: 5px; padding-bottom: 5px; }
}