/* Tagwerk 1.7 – Modul „Händleraufträge“ (Kennung auftraege, Vorsilbe ha-). Schlichtes Grund-CSS: Raster, Abstände, 390 px ohne Querscrollen,
   hell/dunkel über die Variablen aus app.css. Die Feingestaltung folgt in gestaltung.css.
   Wiederverwendet aus app.css/module.css: .kopf, .knopf, .block, .eingabe, .chip, .leer, .d-ab, .schalterreihe, .kennzahlen/.kz, .dat-*, .kt-zurueck, .kt-link, .avatar, .sd-dok-zahl.
   Bewusst NICHT verwendet: die Klasse „leer“ für Spalten (globale Leeranzeige mit großem Innenabstand). */

/* ---------- Gemeinsames ---------- */
.ha-still { color: var(--leise); margin: 6px 2px 18px; }
.ha-werkzeug { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin-bottom: 16px; }
.ha-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.ha-chips .chip { min-height: 40px; padding: 5px 13px; gap: 8px; }
.ha-chip-zahl { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--zart); }
.chip.gesetzt .ha-chip-zahl { color: inherit; opacity: .75; }
.ha-kennzahlen { margin-top: 0; }
.ha-kz { cursor: default; }
#ha-inhalt { min-width: 0; }

/* Marken (Art, Stand, Versandart, Bestand offen, Fällig) */
.ha-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap; background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--leise); }
.ha-art-reservierung { background: color-mix(in srgb, #2F9E8F 16%, transparent); color: #2F9E8F; }
.ha-art-bestellung { background: color-mix(in srgb, var(--p3) 16%, transparent); color: var(--p3); }
.ha-st-0 { --ton: var(--p4); } .ha-st-1 { --ton: #6B7A8F; } .ha-st-2 { --ton: #9B6BD3; } .ha-st-3 { --ton: #3F7FD6; } .ha-st-4 { --ton: var(--gut); } .ha-st-5 { --ton: var(--warn); }
.ha-chip[class*="ha-st-"] { background: color-mix(in srgb, var(--ton) 16%, transparent); color: var(--ton); }
.ha-versand-liegeware { background: color-mix(in srgb, #C9A227 18%, transparent); color: #A8861B; }
.ha-versand-haengeware { background: color-mix(in srgb, #9B6BD3 16%, transparent); color: #9B6BD3; }
.ha-bestand-offen, .ha-chip-faellig { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.ha-bekannt { background: color-mix(in srgb, var(--gut) 16%, transparent); color: var(--gut); }
.ha-frei { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--leise); }

.ha-termin { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--leise); }
.ha-termin.rot { color: var(--warn); font-weight: 600; }
.ha-zusatz, .ha-groesse { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--leise); white-space: nowrap; }
.ha-groesse { background: var(--akzent-weich); color: var(--akzent-kraeftig); }

.ha-balken { display: block; height: 6px; border-radius: 3px; background: var(--linie); overflow: hidden; min-width: 0; }
.ha-balken i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--akzent), var(--gut)); transition: width .4s; }

/* Bild-Kachel (Bild-Adresse des Modells, darunter Farbfläche mit Kürzel) */
.ha-kachel { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; overflow: hidden; color: #fff; font-size: 14px; }
.ha-kachel b { font-weight: 650; }
.ha-bild { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Brett ---------- */
.ha-brett { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: start; margin-bottom: 8px; }
.ha-spalte { min-width: 0; background: color-mix(in srgb, var(--text) 4%, transparent); border-radius: 14px; padding: 10px 8px 8px; transition: background .18s, box-shadow .18s; }
.ha-spalte.ziel { background: var(--akzent-weich); box-shadow: inset 0 0 0 2px var(--akzent); }
.ha-sp-kopf { display: flex; align-items: center; gap: 8px; padding: 2px 6px 10px; }
.ha-sp-kopf h2 { margin: 0; font-size: 13.5px; font-weight: 650; flex: 1; min-width: 0; }
.ha-sp-zahl { color: var(--zart); font-size: 13px; font-variant-numeric: tabular-nums; }
.ha-sp-punkt { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--ton, var(--p4)); }
.ha-sp-0 { --ton: var(--p4); } .ha-sp-1 { --ton: #6B7A8F; } .ha-sp-2 { --ton: #9B6BD3; } .ha-sp-3 { --ton: #3F7FD6; } .ha-sp-4 { --ton: var(--gut); }
.ha-sp-frei { padding: 14px 8px; text-align: center; font-size: 12.5px; color: var(--zart); border: 1.5px dashed var(--linie-stark); border-radius: 11px; }
.ha-sp-alle { width: 100%; }

.ha-karte { position: relative; margin-bottom: 8px; cursor: grab; transition: opacity .18s, transform .18s; }
.ha-karte.zieht { opacity: .4; transform: scale(.97); }
.ha-karte-in {
  position: relative; display: flex; flex-direction: column; gap: 7px; width: 100%; min-width: 0; padding: 11px 44px 11px 11px; text-align: left; min-height: 56px;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; box-shadow: 0 1px 2px rgba(40, 28, 16, .05);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.ha-karte-in:hover { box-shadow: var(--schatten); transform: translateY(-2px); border-color: var(--linie-stark); }
.ha-karte.ha-faellig .ha-karte-in { border-color: color-mix(in srgb, var(--warn) 45%, var(--linie)); }
.ha-karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; flex-wrap: wrap; }
.ha-nr { font-size: 12.5px; color: var(--leise); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ha-haendler { font: 600 17px/1.2 var(--zier); overflow-wrap: anywhere; }
.ha-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.ha-stueck { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ha-fort { display: flex; align-items: center; gap: 8px; }
.ha-fort .ha-balken { flex: 1; }
.ha-fort-zahl { font-size: 12px; color: var(--leise); font-variant-numeric: tabular-nums; }
.ha-zustaendig { position: absolute; right: 10px; bottom: 10px; display: inline-flex; }
.ha-zustaendig .avatar { width: 24px; height: 24px; font-size: 10px; }
.ha-weiter { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--leise); }
.ha-weiter:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }

/* ---------- Liste ---------- */
.ha-liste { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ha-zeile {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr) auto auto minmax(0, 1.2fr); gap: 6px 14px; align-items: center; width: 100%; min-width: 0; padding: 11px 14px; text-align: left; min-height: 56px;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; transition: box-shadow .18s, border-color .18s;
}
.ha-zeile:hover { box-shadow: var(--schatten); border-color: var(--linie-stark); }
.ha-zeile.ha-faellig { border-color: color-mix(in srgb, var(--warn) 45%, var(--linie)); }
.ha-z-haendler { display: flex; flex-direction: column; min-width: 0; }
.ha-z-haendler b { overflow-wrap: anywhere; }
.ha-z-haendler small { color: var(--leise); overflow-wrap: anywhere; }
.ha-z-marken { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.ha-z-stueck, .ha-z-wert { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ha-z-wert { font-weight: 600; text-align: right; }
.ha-z-termin { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.ha-abg { margin: 22px 0 4px; border-top: 1px solid var(--linie); }
.ha-abg-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 4px 2px; cursor: pointer; list-style: none; color: var(--leise); font-weight: 550; }
.ha-abg-kopf::-webkit-details-marker { display: none; }
.ha-abg-kopf:hover { color: var(--text); }
.ha-abg[open] > .ha-abg-kopf .kt-pfeil { transform: rotate(-135deg); margin-top: 4px; }
.ha-abg .ha-liste { padding-top: 6px; }
.ha-abg .ha-zeile { opacity: .85; }

/* ---------- Reserviert je Artikel ---------- */
.ha-reserviert { margin-top: 24px; }
.ha-res-liste { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.ha-res { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; align-items: center; padding: 11px 12px; min-width: 0; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; }
.ha-res-text { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.ha-res-titel { overflow-wrap: anywhere; }
.ha-groessen { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.ha-gr { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 9px; border-radius: 8px; background: color-mix(in srgb, var(--text) 6%, transparent); font-variant-numeric: tabular-nums; }
.ha-gr b { font-weight: 650; }
.ha-gr-menge { font-weight: 600; }
.ha-gr-shop { color: var(--leise); font-size: 11.5px; }
.ha-gr.ha-eng { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.ha-gr.ha-eng .ha-gr-shop { color: inherit; }
.ha-shop { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--leise); white-space: nowrap; }
.ha-shop.ha-eng { color: var(--warn); font-weight: 600; }

/* ---------- Detail ---------- */
.ha-leiste-rahmen { margin: 4px 0 18px; }
.ha-leiste { height: 6px; border-radius: 3px; background: var(--linie); overflow: hidden; margin: 0 2px 10px; }
.ha-leiste i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--akzent), var(--gut)); transition: width .4s; }
.ha-schritte { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ha-stand {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; min-width: 0; padding: 9px 4px; min-height: 64px; text-align: center;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; color: var(--leise); transition: background .15s, border-color .15s, color .15s;
}
.ha-stand:hover { border-color: var(--zart); }
.ha-stand-punkt { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 650; background: var(--linie); color: var(--leise); }
.ha-stand-text { font-size: 12px; font-weight: 550; line-height: 1.2; overflow-wrap: anywhere; }
.ha-stand.erreicht { color: var(--text); }
.ha-stand.erreicht .ha-stand-punkt { background: var(--gut); color: #fff; }
.ha-stand.aktuell { background: var(--akzent-weich); border-color: var(--akzent); color: var(--akzent-kraeftig); }
.ha-stand.aktuell .ha-stand-punkt { background: var(--akzent); color: var(--akzent-text); }
.ha-storniert .ha-schritte { opacity: .55; }
.ha-storno-hinweis { margin: 10px 2px 0; color: var(--warn); font-weight: 600; }
.ha-notiz { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--akzent); background: var(--akzent-weich); border-radius: 0 10px 10px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.ha-schnell { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.ha-knopfreihe { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.ha-positionen { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ha-pos {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "kachel text zahlen bearbeiten" "kachel text shop haken"; gap: 4px 12px; align-items: center;
  padding: 12px 14px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; transition: border-color .2s, background .2s;
}
.ha-pos > .ha-kachel { grid-area: kachel; }
.ha-pos > .ha-pos-text { grid-area: text; }
.ha-pos > .ha-pos-zahlen { grid-area: zahlen; justify-self: end; }
.ha-pos > .ha-shop { grid-area: shop; justify-self: end; }
.ha-pos > .rund { grid-area: bearbeiten; width: 40px; height: 40px; }
.ha-pos > .ha-haken { grid-area: haken; }
.ha-pos.reduziert { border-color: color-mix(in srgb, var(--gut) 40%, var(--linie)); }
.ha-pos-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ha-pos-titel { overflow-wrap: anywhere; }
.ha-pos-marken { display: flex; flex-wrap: wrap; gap: 4px; }
.ha-pos-zahlen { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; color: var(--leise); }
.ha-pos-summe { color: var(--text); font-weight: 650; white-space: nowrap; }
.ha-summe { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 12px 14px; margin-bottom: 4px; background: color-mix(in srgb, var(--akzent-weich) 55%, var(--flaeche)); border: 1px solid var(--linie); border-radius: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ha-summe-red { color: var(--leise); font-weight: 500; font-size: 13px; }

/* Haken (Bestand reduziert, Schritte) */
.ha-haken {
  display: inline-flex; align-items: center; gap: 6px; min-width: 30px; min-height: 30px; padding: 0 8px 0 5px; border-radius: 999px; border: 2px solid var(--p4); color: transparent; font-size: 12px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.ha-haken:hover { color: var(--zart); }
.ha-haken[aria-checked="true"] { background: var(--gut); border-color: var(--gut); color: #fff; }
.ha-haken-text { color: var(--leise); }
.ha-haken[aria-checked="true"] .ha-haken-text { color: #fff; }
.ha-check .ha-haken { padding: 0; width: 30px; height: 30px; border-radius: 50%; justify-content: center; flex: none; }

.ha-schritte-balken { margin: -2px 0 10px; }
.ha-checkliste { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ha-check { display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 12px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; min-width: 0; }
.ha-check-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ha-check-titel { overflow-wrap: anywhere; }
.ha-check-text small { color: var(--leise); font-size: 12px; }
.ha-check.erledigt .ha-check-titel { color: var(--zart); text-decoration: line-through; }
.ha-check > .rund { width: 40px; height: 40px; }
.ha-neu-zeile { display: flex; gap: 8px; margin-bottom: 16px; }
.ha-neu-zeile .eingabe { flex: 1; min-width: 0; }

/* Eckdaten */
.ha-felder { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.ha-feld { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; color: var(--leise); }
.ha-feld > span:first-child { font-weight: 600; }
.ha-feld .eingabe { width: 100%; min-width: 0; }
.ha-bis { display: flex; gap: 8px; align-items: center; }
.ha-bis .eingabe { flex: 1; }
.ha-versandart { align-self: flex-start; max-width: 100%; }
.ha-schalter { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--linie-stark); align-self: flex-start; color: var(--text); }
.ha-schalter i { width: 32px; height: 20px; border-radius: 999px; background: var(--linie-stark); position: relative; transition: background .15s; }
.ha-schalter i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.ha-schalter.an i { background: var(--gut); }
.ha-schalter.an i::after { transform: translateX(12px); }

/* Notizen und Verlauf */
.ha-eingabe { margin-bottom: 6px; }
.ha-bausteine { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ha-verlauf { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ha-ereignis { padding: 10px 12px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; min-width: 0; }
.ha-ereignis-kopf { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; color: var(--leise); }
.ha-wer { display: inline-flex; align-items: center; gap: 6px; }
.ha-wer .avatar { width: 22px; height: 22px; font-size: 9px; }
.ha-weg { margin-left: auto; width: 32px; height: 32px; }
.ha-ereignis-text { margin-top: 4px; overflow-wrap: anywhere; white-space: pre-wrap; }
.ha-art-system { background: transparent; border-style: dashed; }
.ha-art-system .ha-ereignis-text { color: var(--leise); font-size: 13.5px; }
.ha-ereignis.ha-art-notiz { border-left: 3px solid var(--akzent); }

.ha-upload { display: flex; gap: 8px; margin-bottom: 10px; }
.ha-typ { flex: 1; min-width: 0; min-height: 42px; }
.ha-upload .knopf { min-height: 42px; }

/* Positionen einfügen: Vorschau */
.ha-vorschau-liste { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; }
.ha-vorschau-pos { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ha-vorschau-pos .ha-kachel { width: 36px; height: 36px; font-size: 12px; }
.ha-vorschau-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.ha-vorschau-text b { overflow-wrap: anywhere; }
.ha-unklar { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 10%, transparent); }
.ha-unklar ul { margin: 6px 0 0; padding-left: 18px; }
.ha-unklar li { overflow-wrap: anywhere; }

/* ---------- Schmale Ansicht ---------- */
@media (max-width: 860px) {
  .ha-zeile { grid-template-columns: minmax(0, 1fr) auto; }
  .ha-z-marken { grid-column: 1 / -1; grid-row: 2; }
  .ha-z-stueck { grid-column: 1; grid-row: 3; }
  .ha-z-wert { grid-column: 2; grid-row: 1; }
  .ha-z-termin { grid-column: 1 / -1; grid-row: 4; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
  .ha-z-termin:empty { display: none; }
}
@media (max-width: 520px) {
  .ha-schritte { gap: 4px; }
  .ha-stand { padding: 8px 1px; }
  .ha-stand-text { font-size: 11px; letter-spacing: -.01em; overflow-wrap: normal; }
  .ha-pos { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "kachel text bearbeiten" "zahlen zahlen zahlen" "haken haken shop"; }
  .ha-pos > .ha-pos-zahlen { justify-self: start; flex-direction: row; gap: 10px; align-items: baseline; }
  .ha-pos > .ha-haken { justify-self: start; }
  .ha-res-liste { grid-template-columns: minmax(0, 1fr); }
  .ha-felder { grid-template-columns: minmax(0, 1fr); }
  .ha-upload { flex-direction: column; }
  .ha-upload .knopf { width: 100%; }
  .ha-knopfreihe { justify-content: flex-start; }
  .ha-summe { flex-direction: column; align-items: flex-start; }
  .ha-summe .knopf { width: 100%; }
  .ha-werkzeug { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .ha-karte, .ha-balken i, .ha-leiste i { transition: none; }
}
