/* ============================================================= */
/* Kennzahl-Kacheln auf «Aufträge» (#3259)                       */
/* Auf jedem Gerät, Wahl je Gerätetyp (Handy, Tablet, PC).       */
/* Variante per Klasse am Raster: kpi-handy-a (Raster),          */
/* -b (Zeilen, Standard), Wahl im Zahnrad.                       */
/* ============================================================= */

/* MudGrid Spacing=3 (negativer Rand, 12 px Innenabstand) und die 1-Spalten-Regel unter 380 px aufheben. */
.orders-kpi-tiles.kpi-handy {
    margin: 0 0 10px 0 !important;
    width: 100% !important;
    gap: 5px;
    overflow: visible !important; /* ohne negativen Rand nötig für Schatten und Fokusrahmen (app.css .kpi-tiles) */
}
.orders-kpi-tiles.kpi-handy > .mud-grid-item {
    padding: 0 !important;
    max-width: none !important;
    flex-basis: auto !important;
    min-width: 0;
}
/* Meine Jobs und Offline stehen als eigene Felder im Raster. */
.orders-kpi-tiles.kpi-handy > .kpi-meine-offline { display: contents !important; }
.orders-kpi-tiles.kpi-handy .meine-jobs-root,
.orders-kpi-tiles.kpi-handy .offline-kachel-root { display: block; width: 100%; height: 100%; min-width: 0; }

/* Gemeinsame kompakte Kachel */
.orders-kpi-tiles.kpi-handy .mud-paper {
    position: relative;
    height: 100%;
    min-height: 56px;
    padding: 5px 8px 5px 6px !important;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}
.orders-kpi-tiles.kpi-handy .mud-paper > .d-flex { width: 100%; min-width: 0; flex-wrap: nowrap !important; gap: 0 !important; }
.orders-kpi-tiles.kpi-handy .mud-typography-h5,
.orders-kpi-tiles.kpi-handy .mud-typography-h6 {
    font-size: 20px !important;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.orders-kpi-tiles.kpi-handy .mud-typography-subtitle2 { font-size: 12.5px !important; line-height: 1.15; min-width: 0; }
/* Status-Symbole weglassen, das Wort sagt es. Offline behält sein Zustandssymbol. */
.orders-kpi-tiles.kpi-handy .kpi-status .mud-icon-root,
.orders-kpi-tiles.kpi-handy .offline-kachel-neu { display: none; }
.orders-kpi-tiles.kpi-handy .offline-kachel-symbol { font-size: 1rem !important; }
.orders-kpi-tiles.kpi-handy .offline-kachel-zahl { font-size: 17px !important; }

/* Gewählt: Tönung und Rahmen kommen aus CardStyle, dazu ein Haken. */
.orders-kpi-tiles.kpi-handy .mud-paper[aria-pressed="true"]::after,
.orders-kpi-tiles.kpi-handy .orders-myjobs-tile[aria-pressed="true"]::after {
    content: "✓";
    position: absolute;
    top: 2px;
    right: 5px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: var(--mud-palette-primary);
}
/* Meine Jobs wie die anderen Kacheln: gewählt getönt mit Rahmen statt voll eingefärbt. */
.orders-kpi-tiles.kpi-handy .orders-myjobs-tile {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 56px;
    padding: 0 4px;
    font-size: 20px;
}
.orders-kpi-tiles.kpi-handy .orders-myjobs-tile .mud-icon-root { font-size: 1.1rem; }
.orders-kpi-tiles.kpi-handy .orders-myjobs-tile[aria-pressed="true"] {
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}
.orders-kpi-tiles.kpi-handy .orders-myjobs-tile[aria-pressed="true"]:focus-visible { outline-width: 3px; outline-offset: 2px; }

/* Alle Varianten: «Meine Jobs» zuvorderst, Wort nie unten abgeschnitten (g, p in «Begonnen», «Überfällig»). */
.orders-kpi-tiles.kpi-handy .meine-jobs-root { order: -1; }
.orders-kpi-tiles.kpi-handy .mud-typography-subtitle2 { line-height: 1.3 !important; padding-bottom: 1px; }

/* Raster (a) und Zeilen (b): Wort höchstens zwei Zeilen. */
.orders-kpi-tiles.kpi-handy-a .mud-typography-subtitle2,
.orders-kpi-tiles.kpi-handy-b .mud-typography-subtitle2 {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal !important;
    text-overflow: clip !important;
    hyphens: auto;
    overflow-wrap: anywhere;
}

/* Raster (a): vier gleiche Spalten, alle Zeilen so hoch wie die höchste Kachel, Zahl oben, Wort darunter. */
.orders-kpi-tiles.kpi-handy-a { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 4px; }
.orders-kpi-tiles.kpi-handy-a .mud-paper,
.orders-kpi-tiles.kpi-handy-a .orders-myjobs-tile { min-height: 48px !important; padding: 3px 6px 4px 6px !important; }
.orders-kpi-tiles.kpi-handy-a .mud-paper > .d-flex {
    flex-direction: column-reverse !important;
    align-items: flex-start !important;
    justify-content: center !important;
}
.orders-kpi-tiles.kpi-handy-a .mud-typography-h5,
.orders-kpi-tiles.kpi-handy-a .mud-typography-h6 { font-size: 18px !important; }
.orders-kpi-tiles.kpi-handy-a .mud-typography-subtitle2 { font-size: 12px !important; }
.orders-kpi-tiles.kpi-handy-a .orders-myjobs-tile { flex-direction: column; gap: 0; }
/* Offline im Raster: Zahl über die ganze Breite, Symbol vor dem Wort. Die Zahl wird in schmalen Spalten kleiner,
   statt herauszuragen (--zeichen setzt die Kachel, 0.65 em je Zeichen in Inter fett). */
.orders-kpi-tiles.kpi-handy-a .offline-kachel { container-type: inline-size; }
.orders-kpi-tiles.kpi-handy-a .offline-kachel > .d-flex {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "zahl zahl" "symbol wort";
    align-items: center;
    column-gap: 3px !important;
}
.orders-kpi-tiles.kpi-handy-a .offline-kachel > .d-flex > .d-flex { display: contents !important; }
.orders-kpi-tiles.kpi-handy-a .offline-kachel .mud-typography-subtitle2 { grid-area: wort; }
.orders-kpi-tiles.kpi-handy-a .offline-kachel-zahl {
    grid-area: zahl;
    font-size: 13px !important; /* Rückfall für Browser ohne Container-Einheiten (iPadOS 15) */
    font-size: min(18px, calc(100cqi / (var(--zeichen, 7) * 0.65))) !important;
}
.orders-kpi-tiles.kpi-handy-a .offline-kachel-symbol,
.orders-kpi-tiles.kpi-handy-a .offline-kachel .mud-progress-circular { grid-area: symbol; }
/* Ladekreis so gross wie das Symbol, sonst springt die Kachel beim Abgleich. */
.orders-kpi-tiles.kpi-handy .offline-kachel .mud-progress-circular { width: 0.85rem !important; height: 0.85rem !important; }

/* Zeilen (b): oben Meine Jobs und alle Status, darunter Checklisten und Offline (der leere ::before bricht um).
   Zahl links, Wort rechts daneben; jede Kachel gleich hoch (Platz für ein Wort in zwei Zeilen). */
.orders-kpi-tiles.kpi-handy-b { display: flex !important; flex-wrap: wrap; gap: 4px; }
.orders-kpi-tiles.kpi-handy-b::before { content: ""; order: 2; flex: 0 0 100%; height: 0; margin-top: -4px; }
.orders-kpi-tiles.kpi-handy-b > *,
.orders-kpi-tiles.kpi-handy-b .offline-kachel-root { order: 3; }
.orders-kpi-tiles.kpi-handy-b .meine-jobs-root { order: 0; flex: 0 0 44px; width: 44px; }
/* Jede Kachel so breit wie Zahl und Wort, der Rest der Zeile wird verteilt; reicht die Zeile nicht, bricht sie um.
   So wird kein Wort abgeschnitten. Checklisten-Namen brechen nur an Leerzeichen um, höchstens zwei Zeilen. */
.orders-kpi-tiles.kpi-handy-b > .kpi-status { order: 1; flex: 1 0 auto !important; }
.orders-kpi-tiles.kpi-handy-b > .kpi-checkliste { flex: 1 0 auto !important; }
.orders-kpi-tiles.kpi-handy-b > .kpi-status .mud-typography-subtitle2 { display: block !important; white-space: nowrap !important; overflow: visible; }
.orders-kpi-tiles.kpi-handy-b > .kpi-checkliste .mud-typography-subtitle2 { max-width: 96px; overflow-wrap: anywhere; }
/* Offline so breit wie Zahl und Symbol (nie fest, sonst ragt «124/124» heraus, 15.11.2026). */
.orders-kpi-tiles.kpi-handy-b .offline-kachel-root { flex: 1 0 auto; width: auto; }
.orders-kpi-tiles.kpi-handy-b .mud-paper,
.orders-kpi-tiles.kpi-handy-b .orders-myjobs-tile { height: 36px; min-height: 0 !important; padding: 2px 5px 2px 4px !important; }
.orders-kpi-tiles.kpi-handy-b .mud-paper > .d-flex {
    flex-direction: row-reverse !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 4px !important;
}
.orders-kpi-tiles.kpi-handy-b .mud-typography-h5,
.orders-kpi-tiles.kpi-handy-b .mud-typography-h6 { font-size: 15px !important; }
.orders-kpi-tiles.kpi-handy-b .mud-typography-subtitle2 { font-size: 11.5px !important; line-height: 1.22 !important; hyphens: manual; overflow-wrap: normal; }
.orders-kpi-tiles.kpi-handy-b .orders-myjobs-tile { flex-direction: column; gap: 0; font-size: 15px; padding: 0 2px !important; }
.orders-kpi-tiles.kpi-handy-b .orders-myjobs-tile .mud-icon-root { font-size: 0.95rem; }
.orders-kpi-tiles.kpi-handy-b .offline-kachel .mud-typography-subtitle2 { display: none !important; }
.orders-kpi-tiles.kpi-handy-b .offline-kachel > .d-flex { justify-content: center !important; }
.orders-kpi-tiles.kpi-handy-b .offline-kachel > .d-flex > .d-flex { gap: 3px !important; }
.orders-kpi-tiles.kpi-handy-b .offline-kachel-zahl { font-size: 13px !important; }
.orders-kpi-tiles.kpi-handy-b .offline-kachel-symbol { font-size: 0.85rem !important; }

/* Tablet und PC: gleiche Anordnung, etwas grössere Schrift. */
@media (min-width: 600px) {
    .orders-kpi-tiles.kpi-handy .mud-typography-subtitle2 { font-size: 13px !important; }
    .orders-kpi-tiles.kpi-handy .mud-typography-h5,
    .orders-kpi-tiles.kpi-handy .mud-typography-h6 { font-size: 19px !important; }
    .orders-kpi-tiles.kpi-handy-b .mud-paper,
    .orders-kpi-tiles.kpi-handy-b .orders-myjobs-tile { height: 36px; }
    .orders-kpi-tiles.kpi-handy-b > .kpi-checkliste .mud-typography-subtitle2 { max-width: none; }
    .orders-kpi-tiles.kpi-handy-a .offline-kachel-zahl { font-size: 15px !important; font-size: min(19px, calc(100cqi / (var(--zeichen, 7) * 0.65))) !important; }
}

/* Am Handy (unter 600 px) */
@media (max-width: 599.98px) {
    /* Auftragskarten: Checklisten zum Abhaken erst im aufgeklappten Teil, nicht im Kopf. */
    .order-panel .order-header-checklists,
    .orders-lab.mode-tiles .lab-summary .order-header-checklists { display: none; }
    .order-checklisten-aufgeklappt { margin-bottom: 8px; }
}

/* Ab 600 px stehen die Checklisten wie bisher nur im Kopf. */
@media (min-width: 600px) {
    .order-checklisten-aufgeklappt { display: none; }
}
