/* ============================================================
   components.css – Material-Listen, Ergebniszeilen,
                    Settings-Karten, Badge, Leer-Zustände
   ============================================================ */

/* ---- Material-Liste (3D Einstellungen) ---- */
.material-list   { display: flex; flex-direction: column; gap: 0.5rem; max-height: 220px; overflow-y: auto; }
.material-item   {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: var(--transition);
}
.material-item:hover { border-color: var(--border-bright); }
.mat-name   { flex: 1; font-size: 0.875rem; font-weight: 500; }
.mat-price  { font-size: 0.8rem; color: var(--accent); font-weight: 600; font-family: var(--font-display); }
.mat-delete {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0.2rem; border-radius: 4px; display: flex; transition: var(--transition);
}
.mat-delete:hover { color: var(--error); }
.mat-delete svg  { width: 14px; height: 14px; }

/* Laser-Gruppen */
.material-group        { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 0.4rem; }
.material-group-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; background: var(--bg-elevated);
  font-size: 0.8rem; font-weight: 700; font-family: var(--font-display);
  color: var(--accent); border-bottom: 1px solid var(--border);
}
.material-group-header svg { width: 13px; height: 13px; }
.mat-group-count { margin-left: auto; font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-body); font-weight: 400; }
.material-item--variant { border-radius: 0 !important; border: none !important; border-bottom: 1px solid var(--border) !important; padding-left: 1.25rem !important; }
.material-item--variant:last-child { border-bottom: none !important; }
.mat-variant-info { flex: 1; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }

/* ---- Ergebnis-Zeilen ---- */
.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.875rem; color: var(--text-secondary);
}
.result-row:last-child { border-bottom: none; }
.result-row.small { font-size: 0.8rem; color: var(--text-muted); }
.result-row.highlight {
  background: var(--accent-dim); border: 1px solid rgba(232,240,74,0.2);
  border-radius: var(--radius-sm); padding: 0.7rem 0.75rem; margin: 0.25rem 0; color: var(--text-primary);
}
.result-value { font-weight: 600; color: var(--text-primary); }
.result-total {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 800;
  color: var(--accent); letter-spacing: -0.02em;
}

/* ---- Leer-Zustand ---- */
.empty-list {
  text-align: center; color: var(--text-muted); font-size: 0.8rem;
  padding: 1rem; border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 4rem 2rem; color: var(--text-muted); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3  { font-family: var(--font-display); font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p   { font-size: 0.85rem; }

/* ---- Status Badge ---- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; font-family: var(--font-display);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.badge-accent { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(232,240,74,0.2); }
.badge-laser  { background: rgba(74,240,224,0.1); color: #4af0e0; border: 1px solid rgba(74,240,224,0.2); }
.badge-info   { background: rgba(74,180,240,0.1); color: var(--info); border: 1px solid rgba(74,180,240,0.2); }
.badge-success{ background: rgba(74,240,151,0.1); color: var(--success); border: 1px solid rgba(74,240,151,0.2); }

/* Light-Mode: Laser-Badge braucht mehr Kontrast für gute Lesbarkeit. */
body.light-theme .badge-laser {
  background: rgba(26, 176, 164, 0.12);
  color: #0f8f85;
  border-color: rgba(26, 176, 164, 0.26);
}

/* ---- Filterleiste ---- */
.toolbar {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem; flex-wrap: wrap;
  position: sticky;
  top: 0.75rem;
  z-index: 35;
  padding: 0.35rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-base) 86%, transparent);
  backdrop-filter: blur(16px);
}
.toolbar-search { position: relative; flex: 1; min-width: 200px; }
.toolbar-search svg {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-muted); pointer-events: none;
}
.toolbar-search input { padding-left: 2.4rem; }
.filter-btns { display: flex; gap: 0.4rem; }
.filter-btn {
  padding: 0.45rem 0.9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-secondary); font-family: var(--font-body);
  font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: var(--transition);
}
.filter-btn:hover  { border-color: var(--border-bright); color: var(--text-primary); }
.filter-btn.active { background: var(--accent-dim); border-color: rgba(232,240,74,0.3); color: var(--accent); }

/* ============================================================
   3D Material – Brand-Untergruppe (zweite Ebene unter Materialgruppe)
   ============================================================ */

/* Brand-Header: leicht eingerückt, andere Akzentfarbe */
.material-group--brand {
  margin-top: 0.35rem;
  margin-left: 1rem;
  border-left: 2px solid var(--border);
  padding-left: 0.6rem;
}
.mat-brand-header {
  font-size: 0.75rem !important;
  color: var(--info) !important;
  padding: 0.3rem 0 !important;
  border-bottom: none !important;
  gap: 0.4rem;
}
.mat-brand-header svg { color: var(--info); flex-shrink: 0; }

/* Farb-Dot vor dem Farbnamen */
.mat-color-dot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.mat-color-dot::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-hint, var(--accent));
  border: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* ============================================================
   MATERIAL-SEITEN – neues Layout
   ============================================================ */

/* Seiten-Wrapper: volle Breite, keine fixe settings-grid-Spalte */
.mat-page {
  /* Materialseiten dürfen breiter sein, damit Listen/Kacheln auf
     Desktop nicht unnötig gequetscht wirken. */
  max-width: 1180px;
}

/* Formular-Kachel oben: alle Felder in einer flexiblen Zeile */
.mat-add-card {
  margin-bottom: 1.5rem;
}
.mat-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mat-add-form .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.mat-add-form .form-group {
  flex: 1 1 160px;
  min-width: 130px;
}
.mat-add-btn {
  align-self: flex-start;
}

/* Container für die Gruppen-Kacheln */
.mat-groups-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Leerer Zustand */
.mat-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
  text-align: center;
}

/* Eine Kachel pro Materialgruppe */
.mat-group-card {
  /* übernimmt .card, aber kein max-height – scrollt mit der Seite */
}
.mat-group-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.mat-group-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.mat-group-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

/* Hersteller-Abschnitt innerhalb einer Gruppe */
.mat-brand-section {
  margin-bottom: 0.6rem;
}
.mat-brand-section:last-child { margin-bottom: 0; }

.mat-brand-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--info);
  padding: 0.25rem 0;
  margin-bottom: 0.25rem;
}
.mat-brand-label svg { flex-shrink: 0; }



/* ============================================================
   SONDEROPTIONEN – eigene Seite (Kacheln)
   ============================================================ */
.extras-page-item {
  padding: 1rem 1.25rem;
}
.extras-page-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.extras-page-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.extras-page-val {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.extras-page-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}
.extras-page-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
/* ============================================================
   VORLAGEN-PANEL ("Aus Vorlagen hinzufügen")
   ============================================================ */

/* <details>-Wrapper */
.mat-defaults-card {
  margin-bottom: 1.5rem;
}

/* summary: kein Browser-Dreieck, eigenes Layout */
.mat-defaults-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  gap: 1rem;
  padding: 0;
}
.mat-defaults-summary::-webkit-details-marker { display: none; }

.mat-defaults-summary-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.mat-defaults-summary-inner svg {
  color: var(--info, var(--accent));
  flex-shrink: 0;
}

.mat-defaults-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}

/* Chevron-Indikator */
.mat-defaults-summary::after {
  content: '›';
  font-size: 1.2rem;
  color: var(--text-muted);
  transform: rotate(90deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
details[open] > .mat-defaults-summary::after {
  transform: rotate(-90deg);
}

/* Inhalt */
.mat-defaults-container {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.machine-manual-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.machine-manual-modal-card {
  max-width: 640px;
}

.machine-manual-modal-body {
  gap: 1.25rem;
}

.machine-manual-modal-copy {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
}

.machine-manual-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.machine-manual-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Gemeinsames Bearbeiten-Popup für Maschinen, Materialien und Sonderoptionen. */
.entity-edit-modal-card {
  max-width: 760px;
}

.entity-edit-modal-body {
  gap: 1rem;
}

.entity-edit-modal-copy {
  margin-top: -0.1rem;
}

.entity-edit-modal-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.entity-edit-modal-actions {
  margin-top: 0.25rem;
}

.entity-edit-modal-grid .form-help {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

/* ============================================================
   EINSTELLUNGEN – E-MAIL-VORLAGEN
   ============================================================ */
.email-template-card {
  gap: 0.9rem;
}
.email-template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.email-template-edit-btn {
  width: auto;
  flex-shrink: 0;
  white-space: nowrap;
}
.email-template-preview {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 0.65rem 0.8rem;
}
.email-template-preview strong {
  color: var(--text-secondary);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.email-template-preview span {
  color: var(--text-primary);
  font-size: 0.86rem;
  line-height: 1.55;
  word-break: break-word;
}
.email-template-token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.email-template-token-btn {
  width: auto;
  padding: 0.38rem 0.72rem;
  font-size: 0.78rem;
}
.email-template-body-input {
  min-height: 300px;
  font-size: 0.9rem;
  line-height: 1.65;
}
.email-signature-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.email-signature-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.email-signature-item--default {
  border-color: rgba(232,240,74,0.45);
  box-shadow: inset 0 0 0 1px rgba(232,240,74,0.12);
}
.email-signature-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}
.email-signature-item-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.email-signature-item-title-wrap strong {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ============================================================
   EINSTELLUNGEN – RECHNUNGS-PDF-VORLAGE
   ============================================================ */
.invoice-template-grid {
  align-items: start;
  grid-template-columns: minmax(440px, 0.9fr) minmax(620px, 1.45fr);
}
.invoice-template-editor-card,
.invoice-template-preview-card {
  gap: 0.9rem;
}
.invoice-template-editor-card code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08rem 0.35rem;
  color: var(--text-primary);
}
.invoice-placeholder-groups {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.invoice-placeholder-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 0.6rem 0.65rem;
}
.invoice-placeholder-group-title {
  margin-bottom: 0.45rem;
  font-size: 0.73rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 700;
}
.invoice-template-editor-card textarea {
  min-height: 96px;
}
.invoice-template-preview-card {
  position: sticky;
  top: 1rem;
}
.invoice-template-preview-host {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.8rem;
  overflow: auto;
}
.invoice-preview-sheet {
  --invoice-accent: #E8F04A;
  width: min(100%, 1040px);
  margin: 0 auto;
  background: #ffffff;
  color: #1c2430;
  border: 1px solid #d7dbe1;
  border-radius: 10px;
  padding: 1.1rem 1rem 1rem;
  box-shadow: 0 12px 34px rgba(13, 18, 24, 0.08);
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.invoice-preview-accent {
  height: 4px;
  background: var(--invoice-accent);
  border-radius: 999px;
  margin-bottom: 0.9rem;
}
.invoice-preview-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.invoice-preview-sender {
  width: 58%;
  color: #334155;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.invoice-preview-logo-slot {
  width: 42%;
  min-height: 58px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: #64748b;
  background: #f8fafc;
}
.invoice-preview-address-row {
  margin-top: 0.95rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.invoice-preview-recipient {
  width: 58%;
}
.invoice-preview-section-title {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.32rem;
}
.invoice-preview-recipient-block {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #101828;
  white-space: pre-wrap;
}
.invoice-preview-meta {
  width: 42%;
  font-size: 0.74rem;
  line-height: 1.5;
  color: #334155;
  white-space: pre-wrap;
  text-align: right;
}
.invoice-preview-intro {
  margin-top: 0.85rem;
  font-size: 0.79rem;
  line-height: 1.55;
  color: #1f2937;
  white-space: pre-wrap;
}
.invoice-preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.85rem;
  font-size: 0.74rem;
}
.invoice-preview-table th,
.invoice-preview-table td {
  border: 1px solid #d7dbe1;
  padding: 0.42rem 0.46rem;
  text-align: left;
}
.invoice-preview-table thead th {
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
}
.invoice-preview-table .right {
  text-align: right;
}
.invoice-preview-table .invoice-row-position td {
  background: #fffdf0;
  color: #101828;
  font-weight: 800;
  border-top-color: #101828;
}
.invoice-preview-table .invoice-row-detail td {
  background: #ffffff;
  color: #475467;
  font-size: 0.71rem;
  border-color: transparent;
}
.invoice-preview-table .invoice-detail-indent {
  padding-left: 1.35rem;
}
.invoice-preview-details {
  margin-top: 0.65rem;
  border-top: 1px solid #e4e7ec;
  border-bottom: 1px solid #e4e7ec;
}
.invoice-preview-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.34rem 0.05rem;
  border-bottom: 1px solid #eef1f5;
  font-size: 0.72rem;
}
.invoice-preview-detail-row:last-child {
  border-bottom: none;
}
.invoice-preview-detail-row span {
  color: #667085;
}
.invoice-preview-detail-row strong {
  color: #111827;
  text-align: right;
  white-space: pre-wrap;
}
.invoice-preview-totals {
  margin-left: auto;
  margin-top: 0.7rem;
  width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}
.invoice-preview-totals > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.76rem;
}
.invoice-preview-totals span {
  color: #475467;
}
.invoice-preview-totals strong {
  color: #101828;
}
.invoice-preview-total-row strong,
.invoice-preview-total-row span {
  color: #101828;
  font-weight: 700;
}
.invoice-preview-total-row {
  border-top: 1px solid #d7dbe1;
  padding-top: 0.28rem;
  padding-left: 0.4rem;
  box-shadow: inset 3px 0 0 var(--invoice-accent);
}
.invoice-preview-payment-row {
  margin-top: 0.9rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
}
.invoice-preview-payment {
  font-size: 0.74rem;
  line-height: 1.5;
  color: #334155;
  white-space: pre-wrap;
}
.invoice-preview-qr-wrap {
  width: 132px;
  flex-shrink: 0;
  border: 1px solid #d7dbe1;
  border-radius: 8px;
  background: #f8fafc;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}
.invoice-preview-qr {
  width: 108px;
  height: 108px;
  border: 1px solid #d7dbe1;
  border-radius: 6px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.64rem;
  color: #64748b;
  text-align: center;
  padding: 0.3rem;
  overflow: hidden;
}
.invoice-preview-qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.invoice-preview-qr-caption {
  font-size: 0.62rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.invoice-preview-footer {
  margin-top: 1.05rem;
  border-top: 1px solid #d7dbe1;
  padding-top: 0.5rem;
  font-size: 0.68rem;
  line-height: 1.45;
  color: #64748b;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .invoice-template-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .machine-manual-cta,
  .machine-manual-modal-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .machine-manual-modal-grid {
    grid-template-columns: 1fr;
  }

  .entity-edit-modal-grid {
    grid-template-columns: 1fr;
  }

  .email-template-card-head {
    flex-direction: column;
    align-items: stretch;
  }
  .email-template-edit-btn {
    width: 100%;
  }
  .email-signature-item-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .invoice-template-preview-card {
    position: static;
  }

  .invoice-preview-header,
  .invoice-preview-address-row {
    flex-direction: column;
  }

  .invoice-preview-sender,
  .invoice-preview-logo-slot,
  .invoice-preview-recipient,
  .invoice-preview-meta {
    width: 100%;
    text-align: left;
  }

  .invoice-preview-payment-row {
    flex-direction: column;
  }

  .invoice-preview-qr-wrap {
    width: 100%;
    align-items: flex-start;
  }
}

/* "+" Button */
.mat-add-default-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--success);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.mat-add-default-btn:hover {
  background: rgba(74,240,151,0.1);
  border-color: var(--success);
}

/* "✓ Hinzugefügt" Badge */
.mat-default-added-badge {
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--success);
  background: rgba(74,240,151,0.08);
  border: 1px solid rgba(74,240,151,0.2);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Bereits hinzugefügte Items: gedämpft */
.mat-default-item--added {
  opacity: 0.5;
}
.mat-default-item--added .mat-name,
.mat-default-item--added .mat-price {
  color: var(--text-muted);
}

/* ============================================================
   BULK-ADD BUTTONS (Kategorie & Marke im Vorlagen-Panel)
   ============================================================ */

/* Rechte Seite des Gruppen-Headers: Badge + Bulk-Button */
.mat-group-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Bulk-Add Button – grün, kompakt */
.mat-bulk-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-display);
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: var(--transition);
}
.mat-bulk-add-btn:hover { opacity: 0.8; }

/* Kleinere Variante neben dem Markennamen */
.mat-bulk-add-btn--sm {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  margin-left: auto;
}

/* "✓ Alle" – alle bereits hinzugefügt */
.mat-bulk-all-done {
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--success);
  white-space: nowrap;
}
.mat-bulk-all-done--sm {
  font-size: 0.68rem;
  margin-left: auto;
}

/* ============================================================
   MATERIAL INLINE-EDIT
   ============================================================ */

.mat-edit-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.mat-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(var(--accent-rgb, 99,102,241), 0.08);
}

/* Inline-Edit-Formular innerhalb eines material-item */
.mat-inline-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 0;
  width: 100%;
}
.machine-inline-edit {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-md) - 2px);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)) , var(--bg-elevated);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.machine-inline-edit-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 0.75rem;
}
.machine-inline-edit-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.machine-inline-edit-subtitle {
  margin-top: 0.3rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.machine-inline-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  width: 100%;
}
.mat-inline-edit input,
.mat-inline-edit select {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 0.8rem 0.95rem;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.mat-inline-edit input:focus,
.mat-inline-edit select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(209, 225, 0, 0.12);
}
.mat-inline-edit-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
}
.mat-inline-save {
  background: var(--accent);
  color: #11131a;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(209, 225, 0, 0.18);
}
.mat-inline-cancel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.mat-inline-save:hover  { opacity: 0.92; transform: translateY(-1px); }
.mat-inline-cancel:hover { border-color: var(--text-muted); color: var(--text-primary); }
body.light-theme .machine-inline-edit {
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.98));
  box-shadow: 0 14px 32px rgba(25, 32, 61, 0.06);
}
body.light-theme .mat-inline-save {
  color: #ffffff;
  border-color: rgba(86, 100, 0, 0.18);
  box-shadow: 0 12px 24px rgba(209, 225, 0, 0.2);
}
body.light-theme .mat-inline-cancel {
  background: #ffffff;
}

/* ============================================================
   DANGER ZONE – Account löschen
   ============================================================ */
.danger-zone-card {
  border-color: rgba(240,74,74,0.25);
}
.danger-zone-title {
  color: var(--error) !important;
}
.danger-zone-confirm-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.danger-zone-confirm-hint strong {
  color: var(--error);
  font-family: var(--font-display);
}

/* ============================================================
   ACCOUNT RESET – Selektiver Reset-Dialog
   ============================================================ */
.account-reset-modal-card {
  max-width: 720px;
}

.account-reset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1rem 0 1.1rem;
}

.account-reset-option {
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  margin-top: 0;
}

.account-reset-option span {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.account-reset-option strong {
  color: var(--text-primary);
  font-size: 0.88rem;
}

.account-reset-option small {
  color: var(--text-muted);
  font-size: 0.77rem;
  line-height: 1.45;
}

.account-reset-confirm-hint {
  margin-top: 0.2rem;
}

.account-reset-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.account-reset-actions input {
  max-width: 180px;
}

@media (max-width: 720px) {
  .account-reset-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MACHINE CARDS
   ============================================================ */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.machine-card {
  padding: 0.9rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.machine-card--template {
  border-style: dashed;
  background: transparent;
  opacity: 0.85;
}
.machine-card--template:hover {
  opacity: 1;
  background: var(--surface);
}
.machine-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}
.machine-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.machine-name-wrap,
.machine-list-name-wrap {
  min-width: 0;
  flex: 1;
}
.machine-editing-shell {
  display: block !important;
}
.machine-note {
  margin-top: 0.25rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.machine-manual-note-field {
  grid-column: 1 / -1;
}
.machine-stats {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.machine-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 0.5rem;
}
.machine-stat-label {
  color: var(--text-muted);
}
.machine-stat-value {
  font-weight: 600;
  color: var(--text-primary);
}
.machine-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.8rem;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.machine-add-btn:hover { opacity: 0.85; }

/* ============================================================
   VORLAGEN-SUCHE
   ============================================================ */
.mat-search-input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.mat-search-input:focus {
  outline: none;
  border-color: var(--accent);
}
.mat-search-input::placeholder {
  color: var(--text-muted);
}

/* ============================================================
   MATERIAL-SUCHE (oberhalb Vorlagenbereich)
   ============================================================ */
.mat-inline-search-toolbar {
  margin-bottom: 0.35rem;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 0.75rem;
}
.mat-inline-search-toolbar .toolbar-search {
  flex: 1 1 340px;
  min-width: 0;
}
.mat-inline-template-btn {
  width: auto;
  white-space: nowrap;
  align-self: stretch;
  flex-shrink: 0;
}
.mat-inline-search-hint {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.mat-inline-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.2rem 0 0.65rem 0;
}
.mat-inline-section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-primary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.mat-quick-search-card {
  margin-bottom: 1rem;
}
.mat-quick-search-results {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.mat-inline-suggestion-card {
  margin-top: 0.4rem;
  border: 1px solid var(--border-bright);
  background: linear-gradient(180deg, rgba(74,180,240,0.05), rgba(74,180,240,0.02));
}
.material-template-modal-card {
  max-width: 920px;
}
.material-template-modal-card .modal-body {
  gap: 0.9rem;
}
.material-template-modal-card .mat-defaults-container {
  max-height: 58vh;
  overflow-y: auto;
}
.mat-quick-dropdown {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.mat-quick-result-group {
  border-top: 1px solid var(--border);
}
.mat-quick-result-group:first-child {
  border-top: none;
}
.mat-quick-result-group--own .mat-quick-result-head {
  background: rgba(74, 240, 151, 0.09);
  border-left: 3px solid var(--success);
  padding-left: 0.6rem;
}
.mat-quick-result-group--suggested .mat-quick-result-head {
  background: rgba(74, 180, 240, 0.09);
  border-left: 3px solid var(--info);
  padding-left: 0.6rem;
}
.mat-quick-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.mat-quick-scroller {
  max-height: 220px;
  overflow-y: auto;
}
.mat-quick-material-group {
  border-top: 1px solid var(--border);
}
.mat-quick-material-group:first-child {
  border-top: none;
}
.mat-quick-material-head {
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--bg-elevated);
}
.mat-quick-brand-group {
  border-top: 1px solid var(--border);
}
.mat-quick-brand-head {
  padding: 0.4rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--info);
  background: rgba(74, 180, 240, 0.08);
}
.mat-quick-result-head strong {
  color: var(--text-primary);
  font-size: 0.84rem;
}
.mat-quick-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}
.mat-quick-result-item:first-of-type {
  border-top: none;
}
.mat-quick-result-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.mat-quick-title {
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
}
.mat-quick-sub {
  color: var(--text-muted);
  font-size: 0.76rem;
}
.mat-quick-own-tag {
  flex-shrink: 0;
  border: 1px solid rgba(74, 240, 151, 0.35);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  color: var(--success);
  font-size: 0.72rem;
  background: rgba(74, 240, 151, 0.1);
}
.mat-quick-empty {
  padding: 0.75rem;
}
.mat-quick-manual-row {
  border-top: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  display: flex;
  justify-content: flex-end;
  background: var(--bg-elevated);
}
.mat-quick-manual-btn {
  width: auto;
  white-space: normal;
}

@media (max-width: 720px) {
  .mat-inline-search-toolbar {
    flex-wrap: wrap;
  }
  .mat-inline-template-btn {
    width: 100%;
  }
  .material-template-modal-card {
    max-width: 96vw;
  }
}

/* ============================================================
   MASCHINEN – MARKEN-GRUPPE
   ============================================================ */
.machine-brand-group {
  margin-bottom: 1.25rem;
}
.machine-brand-group:last-child {
  margin-bottom: 0;
}
.machine-brand-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.15rem 0 0.4rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6rem;
}

/* ---- Global Search Dropdown ---- */
.global-search-dropdown {
  position: fixed;
  z-index: 9000;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  overflow-y: auto;
  max-height: 420px;
}
.gs-group-label {
  padding: 0.45rem 0.85rem 0.2rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.gs-group-label:first-child { border-top: none; }
.gs-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  color: var(--text-primary);
}
.gs-item:hover, .gs-item--selected { background: var(--bg-elevated); }
.gs-item-icon { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; display: flex; align-items: center; }
.gs-item-icon svg { width: 100%; height: 100%; }
.gs-item-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.gs-item-label { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item-sub   { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-empty      { padding: 1rem 0.85rem; font-size: 0.82rem; color: var(--text-muted); text-align: center; }

/* ---- Machine View Toolbar ---- */
.machine-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.machine-view-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

/* ---- Machine List View ---- */
.machines-list-view {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overflow-y: hidden;
  margin-top: 0.5rem;
}
.machine-list-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.machine-list-header--detailed {
  grid-template-columns: minmax(220px, 1.8fr) repeat(7, minmax(120px, 0.95fr)) minmax(130px, auto);
}
.machine-list-header--laser {
  grid-template-columns: minmax(220px, 1.8fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(90px, 0.8fr) minmax(110px, 0.9fr) minmax(130px, auto);
}
.machine-list-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.machine-list-row--detailed {
  grid-template-columns: minmax(220px, 1.8fr) repeat(7, minmax(120px, 0.95fr)) minmax(130px, auto);
}
.machine-list-row--laser {
  grid-template-columns: minmax(220px, 1.8fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(90px, 0.8fr) minmax(110px, 0.9fr) minmax(130px, auto);
}
.machine-list-row:last-child { border-bottom: none; }
.machine-list-row:hover { background: var(--bg-elevated); }
.machine-list-row--default { background: var(--accent-dim); }
.machine-list-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.machine-list-stats {
  display: flex;
  gap: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.machine-list-stats .accent {
  font-weight: 700;
  color: var(--accent);
}
.machine-list-cell {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.machine-list-cell--accent {
  color: var(--accent);
  font-weight: 700;
}
.machine-list-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .machine-list-header,
  .machine-list-header--detailed,
  .machine-list-header--laser {
    grid-template-columns: 1fr auto;
  }
  .machine-list-header span:nth-child(n+2):not(:last-child) {
    display: none;
  }
  .machine-list-row,
  .machine-list-row--detailed,
  .machine-list-row--laser {
    grid-template-columns: 1fr auto;
  }
  .machine-list-stats,
  .machine-list-cell {
    display: none;
  }
}
