/* Materialcenter V3 – Materialstamm. Nur fuer die Materiallager-Ansicht. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-modal-card {
  width: min(1240px, calc(100vw - 48px)) !important;
  max-width: none !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-body {
  min-width: 0;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-overview {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--cch-border, rgba(116, 174, 207, .22));
  border-radius: 16px;
  background: rgba(5, 19, 29, .46);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media > img,
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media > .material-image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  max-height: 310px;
  object-fit: contain;
  border-radius: 12px;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media-copy {
  display: grid;
  gap: 3px;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media-copy b {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .72;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-facts {
  min-width: 0;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-facts .material-info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media {
  align-self: start;
  background: #f2f5f7;
  color: #304653;
  overflow: visible;
}
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-media > img:not([hidden]) {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-height: min(52vh, 440px) !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: center !important;
  overflow: visible !important;
  filter: none !important;
  transform: none !important;
}
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-section {
  min-width: 0;
  padding: 15px;
  border: 1px solid rgba(112, 165, 199, .2);
  border-radius: 14px;
  background: rgba(5, 19, 29, .4);
}
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-section h3 {
  margin: 0 0 12px;
  font-size: 14px;
}
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-section .material-info-grid > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-modal-card {
    width: calc(100vw - 20px) !important;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-overview {
    grid-template-columns: 1fr;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-sections {
    grid-template-columns: 1fr;
  }
}

/* v3.3.0 – Materialinformationen und Datenblatt als gemeinsame, ruhige Tab-Arbeitsfläche. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] :is(.material-info-tabs, .material-editor-tabs, .material-sheet-tabs) {
  display: flex;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  border: 1px solid rgba(112, 165, 199, .2);
  border-radius: 14px;
  background: rgba(4, 16, 25, .72);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-tabs {
  margin: 0 20px 4px;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] :is(.material-info-tabs, .material-editor-tabs, .material-sheet-tabs) button {
  flex: 0 0 auto;
  width: auto !important;
  max-width: none !important;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--cch-text-soft, #a7b5c2);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] :is(.material-info-tabs, .material-editor-tabs, .material-sheet-tabs) button:hover {
  color: #fff;
  background: rgba(37, 189, 243, .09);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] :is(.material-info-tabs, .material-editor-tabs, .material-sheet-tabs) button.is-active {
  border-color: rgba(67, 207, 250, .46);
  color: #03141e;
  background: #2bc5f4;
  box-shadow: 0 7px 20px rgba(18, 143, 190, .18);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  margin-bottom: 18px;
  backdrop-filter: blur(14px);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-tab-panel[hidden],
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] [data-material-editor-panel][hidden],
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] [data-material-sheet-panel][hidden] {
  display: none !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-section {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid rgba(112, 165, 199, .2);
  border-radius: 16px;
  background: rgba(5, 19, 29, .48);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-section h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 22px;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-grid b {
  color: #9db0bd;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-grid span {
  color: #f4f8fb;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-empty {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 220px;
  padding: 28px;
  text-align: center;
  border: 1px dashed rgba(112, 165, 199, .32);
  border-radius: 16px;
  color: #98aab7;
  background: rgba(5, 19, 29, .32);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-empty strong { color: #f5f8fa; font-size: 17px; }
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-document-actions,
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-footer { justify-content: flex-end; margin-top: 18px; }

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-datasheet-panel {
  padding: 16px 20px 22px;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-sheet-hint {
  margin-bottom: 12px;
  padding: 12px 15px;
  border: 1px solid rgba(43, 197, 244, .24);
  border-radius: 12px;
  color: #bbd1de;
  background: rgba(22, 87, 113, .18);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialSheetForm.is-embedded .material-sheet-tabs {
  display: none;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialSheetForm.is-embedded #skipMaterialSheetBtn {
  display: none;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialSheetForm.is-embedded .material-sheet-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  justify-content: flex-end;
  padding: 12px;
  border-top: 1px solid rgba(112, 165, 199, .18);
  background: rgba(7, 21, 31, .94);
  backdrop-filter: blur(12px);
}

/* Produktbilder in der Stammliste groß genug, mit ruhigem, hellem Produkt-Hintergrund. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-library-material-cell {
  grid-template-columns: 78px minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 14px !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-library-material-cell .thumb {
  width: 76px !important;
  height: 76px !important;
  padding: 6px !important;
  border: 1px solid rgba(112, 165, 199, .24) !important;
  border-radius: 13px !important;
  background: #f4f7f9 !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-library-material-cell .thumb img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
  filter: none !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-library-material-cell .material-image-placeholder {
  color: #617784;
}

@media (max-width: 900px) {
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-tabs {
    margin-inline: 10px;
    scroll-snap-type: x proximity;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] :is(.material-info-tabs, .material-editor-tabs, .material-sheet-tabs) button {
    flex-basis: auto !important;
    scroll-snap-align: start;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-datasheet-panel { padding-inline: 10px; }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-info-data-grid { grid-template-columns: 1fr; }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-library-material-cell { grid-template-columns: 64px minmax(0, 1fr) !important; }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-library-material-cell .thumb { width: 62px !important; height: 62px !important; }
}

/* v3.2.2 – Materialeditor: breitere Arbeitsflaeche, klare Freigaben, saubere Bildvorschau. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-modal-card {
  width: min(1440px, calc(100vw - 36px)) !important;
  max-width: none !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-modal-body {
  padding: 20px !important;
  gap: 16px !important;
}

/* Bild nicht mehr als kleines, unscharfes Nebenfeld: klare Medienkarte links, Bedienung rechts. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-editor {
  display: grid !important;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) !important;
  gap: 18px !important;
  align-items: stretch !important;
  padding: 16px !important;
  border: 1px solid rgba(112, 165, 199, .18);
  border-radius: 16px;
  background: rgba(5, 19, 29, .42);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-editor > div:first-child {
  grid-column: 2;
  align-self: center;
  min-width: 0;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-preview {
  grid-column: 1;
  grid-row: 1;
  min-height: 190px !important;
  height: 100%;
  padding: 12px;
  display: grid !important;
  place-items: center !important;
  overflow: hidden;
  border: 1px solid rgba(112, 165, 199, .20);
  border-radius: 14px;
  background: #f4f7f9;
  color: #536571;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-preview img {
  width: 100% !important;
  height: 100% !important;
  max-height: 210px;
  object-fit: contain !important;
  object-position: center;
  filter: none !important;
  transform: none !important;
  opacity: 1 !important;
  border-radius: 10px;
}

/* Freigaben als eigener breiter V3-Bereich statt enger Schalter-Reihe. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-panel {
  grid-template-columns: 1fr !important;
  gap: 18px !important;
  padding: 20px !important;
  margin: 16px 0 !important;
  border-radius: 18px !important;
  background: linear-gradient(135deg, rgba(12, 47, 66, .78), rgba(6, 25, 37, .88)) !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 20px;
  align-items: center;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-copy > :not(.material-release-actions) {
  grid-column: 1;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-copy .material-release-actions {
  grid-column: 2;
  grid-row: 1 / span 3;
  margin-top: 0;
  justify-content: flex-end;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-controls {
  display: grid !important;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) !important;
  gap: 16px !important;
  align-items: stretch !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-field {
  padding: 14px;
  border: 1px solid rgba(112, 165, 199, .18);
  border-radius: 14px;
  background: rgba(5, 19, 29, .58);
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-usage-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 10px !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-usage-grid .material-release-switch:last-child:nth-child(odd) {
  grid-column: auto !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch {
  min-height: 78px !important;
  display: grid !important;
  grid-template-columns: 26px minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 11px !important;
  padding: 12px 13px !important;
  border: 1px solid rgba(112, 165, 199, .20) !important;
  border-radius: 14px !important;
  background: rgba(5, 19, 29, .64) !important;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch:hover {
  border-color: rgba(39, 194, 243, .42) !important;
  background: rgba(10, 39, 55, .78) !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch:has(input:checked) {
  border-color: rgba(39, 194, 243, .46) !important;
  background: rgba(16, 69, 91, .40) !important;
}

/* Die bisherigen runden Schalterpunkte werden zu klaren Auswahlfeldern. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch-ui {
  width: 24px !important;
  height: 24px !important;
  display: grid;
  place-items: center;
  position: relative;
  border: 1px solid rgba(142, 178, 199, .48) !important;
  border-radius: 7px !important;
  background: rgba(5, 19, 29, .88) !important;
  box-shadow: none !important;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch-ui::after {
  content: "✓" !important;
  position: static !important;
  width: auto !important;
  height: auto !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #04141e;
  font-size: 16px;
  font-weight: 1000;
  line-height: 1;
  opacity: 0;
  transform: none !important;
  transition: opacity .14s ease !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch input:checked + .material-release-switch-ui {
  background: #2bc5f4 !important;
  border-color: #65dafb !important;
  box-shadow: 0 0 0 3px rgba(43, 197, 244, .10) !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch input:checked + .material-release-switch-ui::after {
  opacity: 1;
  transform: none !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch strong {
  font-size: 13px;
  line-height: 1.25;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-switch small {
  margin-top: 4px !important;
  font-size: 11px !important;
  line-height: 1.35;
}

@media (max-width: 1120px) {
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-usage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 820px) {
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-editor-modal-card {
    width: calc(100vw - 16px) !important;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-editor,
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-controls,
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-copy {
    grid-template-columns: 1fr !important;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-editor > div:first-child,
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-preview,
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-copy .material-release-actions {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-image-preview {
    min-height: 180px !important;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-release-copy .material-release-actions {
    justify-content: flex-start;
    margin-top: 10px;
  }
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] .material-usage-grid {
    grid-template-columns: 1fr !important;
  }
}


/* v3.2.3 – Materialeditor: echtes viewport-zentriertes Modal ohne Horizontal-Scroll. */
body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialModal.modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: var(--cch-v3-modal-z, 300000) !important;
  align-items: center !important;
  justify-content: center !important;
  padding: clamp(10px, 1.5vw, 24px) !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialModal .material-editor-modal-card {
  width: min(1280px, calc(100vw - 32px)) !important;
  max-width: 1280px !important;
  max-height: min(90dvh, 960px) !important;
  margin: 0 auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
}

body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialModal :is(
  .material-editor-modal-body,
  form,
  .grid2,
  .grid3,
  .grid4,
  .material-image-editor,
  .material-release-panel,
  .material-release-controls,
  .material-usage-grid,
  .price-mode-box,
  .price-logic-box,
  .unit-mode-note,
  .variant-card
) {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

@media (max-width: 820px) {
  body.cch-page-cch-materialcenter[data-materialcenter-view="materials"] #materialModal .material-editor-modal-card {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
  }
}
