/* Wärmepur Betriebsmodule – Werkbank-Register-Oberfläche (nahtlose Ergänzung zu styles.css). */

/* Zusätzliche semantische Zustandsquadrate (Quadrat-Regel aus DESIGN.md: 7px-Quadrat, nie Pille) */
.state.s-anfrage,
.state.s-neu,
.state.s-geplant,
.state.s-eingeplant,
.state.s-vorbereitet,
.state.s-normal { color: var(--ink-2); }
.state.s-anfrage::before,
.state.s-neu::before,
.state.s-geplant::before,
.state.s-eingeplant::before,
.state.s-vorbereitet::before,
.state.s-normal::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.state.s-in_ausfuehrung,
.state.s-in_arbeit,
.state.s-rueckruf,
.state.s-rueckruf_offen,
.state.s-wartet,
.state.s-mittel,
.state.s-aktualisieren,
.state.s-faellig { color: var(--amber); }

.state.s-aktiv,
.state.s-erledigt,
.state.s-abgeschlossen,
.state.s-abgerechnet,
.state.s-durchgefuehrt,
.state.s-ok,
.state.s-bestaetigt { color: var(--green); }

.state.s-hoch,
.state.s-dringend,
.state.s-notfall,
.state.s-kritisch,
.state.s-unterbestand,
.state.s-konflikt,
.state.s-fehler { color: var(--crimson); }

.state.s-pausiert,
.state.s-beendet,
.state.s-gekuendigt,
.state.s-abgesagt,
.state.s-niedrig,
.state.s-archiviert,
.state.s-uebersprungen { color: var(--ink-3); }
.state.s-pausiert::before,
.state.s-niedrig::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

/* Salden-/Registerzeile mit sauberen 1px-Haarlinien bei jedem Umbruch (1280/1110/900/420 px) */
.b-ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.b-ledger > div {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 10px;
  padding: 12px 18px;
  background: var(--sheet);
  min-width: 0;
}
.b-ledger dt {
  font-size: 13px;
  color: var(--ink-2);
}
.b-ledger dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.b-ledger dd.alert { color: var(--crimson); }
.b-ledger dd.warn { color: var(--amber); }
.b-ledger dd.ok { color: var(--green); }
.b-ledger.has-subrow {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.b-ledger-subrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 9px 18px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
}
.b-ledger-subrow-label {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--ink-2);
}
.b-ledger-subrow-val {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}
@media (max-width: 1120px) and (min-width: 981px), (max-width: 840px) and (min-width: 721px) {
  .b-ledger {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Segment-Filter mit sauberen 1px-Trennlinien für 2, 3, 4 oder 5 Optionen (ohne starre 3er-Raster-Lücken) */
.b-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 100%;
}
.b-seg button {
  flex: 1 0 auto;
  border: 0;
  background: var(--sheet);
  padding: 0 12px;
  min-height: 32px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink-2);
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.b-seg button:hover { background: var(--panel); color: var(--ink); }
.b-seg button[aria-pressed="true"] { background: var(--side); color: #fff; }
.b-seg .count {
  font-size: 11.5px;
  opacity: .75;
  font-variant-numeric: tabular-nums;
}

/* Filter- und Suchleisten */
.b-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.b-filters .field {
  min-width: 148px;
  flex: 0 1 auto;
}
.b-filters .field.b-grow {
  flex: 1 1 220px;
  max-width: 340px;
}
.b-filters .field input,
.b-filters .field select {
  height: 32px;
  font-size: 13px;
}
.b-filters .b-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Tabellen-Container mit Container-Abfragen gegen horizontalen Überlauf bei 1280/1110/900/420 px */
.b-list {
  container-type: inline-size;
  min-width: 0;
}
.b-list .table-wrap {
  max-width: 100%;
}
.b-list table.list td {
  overflow-wrap: break-word;
}
.b-list table.list td.num,
.b-list table.list th.num {
  overflow-wrap: normal;
}
.b-date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.b-code-num {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.b-list.b-list-wide table.list,
.b-master .b-list table.list {
  font-size: 13px;
}
.b-list.b-list-wide table.list th,
.b-master .b-list table.list th {
  padding: 8px 9px;
  font-size: 12px;
  white-space: normal;
}
.b-list.b-list-wide table.list td,
.b-master .b-list table.list td {
  padding: 8px 9px;
}
.b-list.b-list-wide .btn.small,
.b-master .b-list .btn.small {
  padding: 0 8px;
  font-size: 12px;
  height: 26px;
}
.b-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  align-items: center;
}
/* Zeilenfarben auf <tr> statt <td>, damit im Stapel-Grid keine weißen Streifen im grid-gap entstehen */
.b-list table.list tbody tr.row-link:hover { background: #f7f9fa; }
.b-list table.list tbody tr.selected { background: #eef1f3; }
.b-list table.list tbody tr.b-row-warn { background: var(--amber-wash); }
.b-list table.list tbody tr.b-row-warn:hover { background: #f6e7c6; }
.b-list table.list tbody tr.b-row-alert { background: var(--crimson-wash); }
.b-list table.list tbody tr.b-row-alert:hover { background: #f6dbdc; }
.b-list table.list tbody tr.row-link:hover td,
.b-list table.list tbody tr.selected td,
.b-list table.list tbody tr.b-row-warn td,
.b-list table.list tbody tr.b-row-warn:hover td,
.b-list table.list tbody tr.b-row-alert td,
.b-list table.list tbody tr.b-row-alert:hover td {
  background: transparent;
}
.b-list tr.b-row-done td { color: var(--ink-3); }
/* Sprungziel aus dem Telefonassistenten: 2px-Graphitkante, bleibt auch auf Notfall- und erledigten Zeilen sichtbar */
.b-list table.list tbody tr.b-row-target { outline: 2px solid var(--side); outline-offset: -2px; }
.b-subline {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.35;
}
.b-filepath {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

/* Stapel-Ansicht: 1280px zeigt echte Desktop-Tabellen mit <thead>; schmale Container (900/420px bzw. 1110px breit) stapeln sauber */
@container (max-width: 560px) {
  .b-list:not(.b-hub-list) table.list.stack thead { display: none; }
  .b-list:not(.b-hub-list) table.list.stack,
  .b-list:not(.b-hub-list) table.list.stack tbody,
  .b-list:not(.b-hub-list) table.list.stack tr,
  .b-list:not(.b-hub-list) table.list.stack td { display: block; width: 100%; }
  .b-list:not(.b-hub-list) table.list.stack tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-3);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 14px;
  }
  .b-list:not(.b-hub-list) table.list.stack tr:last-child { border-bottom: 0; }
  .b-list:not(.b-hub-list) table.list.stack td,
  .b-list:not(.b-hub-list) table.list.stack td.num {
    border: 0;
    padding: 1px 0;
    text-align: left;
    min-width: 0;
    background: transparent;
  }
  .b-list:not(.b-hub-list) table.list.stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--ink-3);
    font-weight: 400;
  }
  .b-list:not(.b-hub-list) table.list.stack td:first-child,
  .b-list:not(.b-hub-list) table.list.stack td.b-primary-cell,
  .b-list:not(.b-hub-list) table.list.stack td.b-wide-cell,
  .b-list:not(.b-hub-list) table.list.stack td.b-actions-cell {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .b-list:not(.b-hub-list) table.list.stack td.b-actions-cell .b-row-actions {
    justify-content: flex-start;
    margin-top: 4px;
  }
}

@container (max-width: 440px) {
  .b-list.b-hub-list table.list.stack thead { display: none; }
  .b-list.b-hub-list table.list.stack,
  .b-list.b-hub-list table.list.stack tbody,
  .b-list.b-hub-list table.list.stack tr,
  .b-list.b-hub-list table.list.stack td { display: block; width: 100%; }
  .b-list.b-hub-list table.list.stack tr {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-3);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 12px;
  }
  .b-list.b-hub-list table.list.stack tr:last-child { border-bottom: 0; }
  .b-list.b-hub-list table.list.stack td,
  .b-list.b-hub-list table.list.stack td.num {
    border: 0;
    padding: 1px 0;
    text-align: left;
    min-width: 0;
    background: transparent;
  }
  .b-list.b-hub-list table.list.stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--ink-3);
    font-weight: 400;
  }
  .b-list.b-hub-list table.list.stack td:first-child,
  .b-list.b-hub-list table.list.stack td.b-primary-cell,
  .b-list.b-hub-list table.list.stack td.b-actions-cell {
    grid-column: 1 / -1;
    min-width: 0;
  }
}

/* Breite Tabellen (Verkaufspreise, Lager, Belege, Service, Verträge, Wartungen, Projekte, Telefon):
   1280px (Container 976px) bleibt echte Tabelle mit <thead>; 900px (868px), 1110px (806px) und 420px (388px) stapeln sauber */
@container (max-width: 880px) {
  .b-list.b-list-wide table.list.stack thead { display: none; }
  .b-list.b-list-wide table.list.stack,
  .b-list.b-list-wide table.list.stack tbody,
  .b-list.b-list-wide table.list.stack tr,
  .b-list.b-list-wide table.list.stack td { display: block; width: 100%; }
  .b-list.b-list-wide table.list.stack tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-3);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 14px;
  }
  .b-list.b-list-wide table.list.stack tr:last-child { border-bottom: 0; }
  .b-list.b-list-wide table.list.stack td,
  .b-list.b-list-wide table.list.stack td.num {
    border: 0;
    padding: 1px 0;
    text-align: left;
    min-width: 0;
    background: transparent;
  }
  .b-list.b-list-wide table.list.stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--ink-3);
    font-weight: 400;
  }
  .b-list.b-list-wide table.list.stack td:first-child,
  .b-list.b-list-wide table.list.stack td.b-primary-cell,
  .b-list.b-list-wide table.list.stack td.b-wide-cell,
  .b-list.b-list-wide table.list.stack td.b-actions-cell {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .b-list.b-list-wide table.list.stack td.b-actions-cell .b-row-actions {
    justify-content: flex-start;
    margin-top: 4px;
  }
}

/* Detail-Seitenleiste (Lieferanten / Partner Master-Detail) */
.b-master {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.b-master > * { min-width: 0; }
.b-detail-panel {
  position: sticky;
  top: 76px;
}
.b-detail-panel h2 {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 4px;
}
.b-kv-list {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
  gap: 6px 14px;
  font-size: 13px;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-3);
}
.b-kv-list dt { color: var(--ink-3); }
.b-kv-list dd { margin: 0; overflow-wrap: anywhere; }

/* Projektakte (Baustellen-Akte) */
.b-hub-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 20px;
  margin: 0;
  padding: 14px 18px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.b-hub-meta > div { min-width: 0; }
.b-hub-meta dt { font-size: 11.5px; color: var(--ink-3); margin-bottom: 2px; }
.b-hub-meta dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.b-hub-band {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.b-hub-band-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 12px;
  letter-spacing: .01em;
}
.b-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.b-hub-grid > section { min-width: 0; }
.b-hub-full { grid-column: 1 / -1; }
.b-hub-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.b-hub-head .section-title { margin-bottom: 0; }

/* Planung: Tages- / Wochen-Einsatztafel (Werkbank-Register) */
.b-schedule-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.b-day-group {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.b-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
}
.b-day-head .muted { font-weight: 400; font-size: 12px; }
.b-slot {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: start;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-3);
}
.b-slot:last-child { border-bottom: 0; }
.b-slot.b-slot-conflict {
  border-left: 3px solid var(--crimson);
  background: var(--crimson-wash);
  padding-left: 11px;
}
.b-slot-time {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
}
.b-slot-body { min-width: 0; }
.b-slot-title {
  font-weight: 600;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.b-slot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.b-slot-conflict-note {
  margin-top: 5px;
  font-size: 12px;
  color: var(--crimson);
  font-weight: 600;
}
.b-slot-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* DATANORM & Datei-Auswahl (schlichte 1px-Haarlinie, Design-System-Knopf) */
.b-file-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 12px;
  background: var(--sheet);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}
.b-file-box input[type="file"] {
  font-size: 13px;
  color: var(--ink-2);
  max-width: 100%;
}
.b-file-box input[type="file"]::file-selector-button {
  height: 30px;
  padding: 0 12px;
  margin-right: 10px;
  border: 1px solid var(--side);
  border-radius: 3px;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--chrome);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.b-file-box input[type="file"]::file-selector-button:hover {
  background: var(--side);
  color: #fff;
}
.b-mono-area {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}
.b-diff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.35;
}
.b-diff-list li {
  overflow-wrap: anywhere;
}
.b-diff-list .b-diff-old {
  color: var(--ink-3);
  text-decoration: line-through;
}
.b-diff-list .b-diff-new {
  color: var(--ink);
  font-weight: 600;
}
.b-diff-list .b-diff-vat {
  color: var(--amber);
  font-weight: 600;
}
.b-calc-preview {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 13px;
}
.b-calc-preview b {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Aufgaben: direkte Checkbox-Zeile */
.b-task-check {
  width: 17px;
  height: 17px;
  accent-color: var(--side);
  cursor: pointer;
  margin: 2px 0 0;
  flex: none;
}
.b-task-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.b-task-done {
  text-decoration: line-through;
  color: var(--ink-3);
}

/* Telefonassistent: kompakte Übernahmeleiste */
.b-handoff-bar {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}
.b-handoff-bar .btn.small {
  padding: 0 8px;
  white-space: nowrap;
}

/* Wartungs-Checkliste im Dialog */
.b-checklist-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.b-chk-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1.3fr) minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
}
.b-chk-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--side);
  margin: 0;
}
.b-chk-row input[type="text"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid #c9d0d5;
  border-radius: 3px;
  font-size: 13px;
  min-width: 0;
  width: 100%;
}

/* Sektionsabstand */
.b-section { margin-top: 20px; }
.b-section-tight { margin-top: 14px; }

/* Dialog-Vorschautabelle */
.b-dlg-preview {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.b-dlg-preview table.list { font-size: 12.5px; }
.b-dlg-preview table.list th,
.b-dlg-preview table.list td { padding: 6px 10px; }

/* Großhandel-Detaildialog: 4-5 Preisspalten und Marktanalyse-Bereich mit 1px-Haarlinien */
.gh-price-row {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px 14px;
}
.gh-price-row > div { min-width: 0; }
.gh-market-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--sheet);
}
.gh-market-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px 14px;
  flex-wrap: wrap;
}
.gh-market-head h3 {
  font-size: 14px;
  font-weight: 650;
  margin: 0 0 2px;
}
#b-gh-market-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Breakpoints */
@media (max-width: 1180px) {
  .b-master { grid-template-columns: minmax(0, 1fr); }
  .b-detail-panel { position: static; }
  .b-hub-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .b-list table.list.stack td,
  .b-list.b-list-wide table.list.stack td {
    background: transparent;
    overflow-wrap: anywhere;
  }
  .b-ledger {
    grid-template-columns: minmax(0, 1fr);
  }
  .b-ledger > div {
    justify-content: space-between;
    padding: 11px 14px;
  }
  .b-ledger-subrow {
    padding: 10px 14px;
  }
  .b-handoff-bar {
    flex-wrap: wrap;
  }
  .b-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .b-filters .field,
  .b-filters .field.b-grow {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .b-seg {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }
  .b-seg button {
    flex: 1 1 45%;
    white-space: normal;
    line-height: 1.25;
    min-height: 34px;
    padding: 6px 8px;
    text-align: center;
  }
  .b-slot {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .b-slot-actions { margin-top: 4px; }
  .b-chk-row {
    grid-template-columns: 20px minmax(0, 1fr) 28px;
  }
  .b-chk-row .b-chk-note {
    grid-column: 2 / 4;
  }
  .b-hub-meta {
    grid-template-columns: minmax(0, 1fr);
  }
  .gh-price-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
  }
  .b-list table.list.stack tr,
  .b-list.b-list-wide table.list.stack tr {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}
@media (max-width: 440px) {
  .gh-price-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .gh-market-head .btn {
    width: 100%;
    justify-content: center;
  }
}
