/* Wiederverwendbare Komponenten */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch); padding: 0 var(--sp-5);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 700; cursor: pointer;
  background: var(--gray-100); color: var(--text); transition: filter .12s, background .12s;
  text-align: center; line-height: 1.1;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-subtle { background: var(--green-50); color: var(--primary-dark); }
.btn-lg { min-height: 60px; font-size: var(--fs-lg); padding: 0 var(--sp-6); }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0; width: var(--touch); }

/* Karten */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--sp-5);
}
.card.pad-sm { padding: var(--sp-4); }
.card-title { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-title h3 { margin: 0; }

.grid { display: grid; gap: var(--sp-4); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack > * + * { margin-top: var(--sp-3); }

/* Badges / Chips */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.4;
  background: var(--gray-100); color: var(--gray-700); white-space: nowrap;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-ok { background: var(--green-100); color: var(--green-900); }
.badge-info { background: var(--info-bg); color: var(--blue-700); }

.status { color: #fff; }
.status-unverplant { background: var(--st-unverplant); }
.status-geplant { background: var(--st-geplant); }
.status-in_arbeit { background: var(--st-in_arbeit); }
.status-warte_ersatzteile { background: var(--st-warte_ersatzteile); }
.status-teilabgeschlossen { background: var(--st-teilabgeschlossen); }
.status-zur_pruefung { background: var(--st-zur_pruefung); }
.status-abgeschlossen { background: var(--st-abgeschlossen); }
.status-storniert { background: var(--st-storniert); }

/* Listen */
.list { display: flex; flex-direction: column; gap: var(--sp-2); }
.list-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); min-height: var(--touch);
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.list-item:hover { border-color: var(--green-500); box-shadow: var(--sh-1); }
.list-item.selected { border-color: var(--primary); box-shadow: var(--sh-focus); }
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; }
.list-item .li-sub { color: var(--text-muted); font-size: var(--fs-sm); }
.li-num { font-family: var(--mono, ui-monospace, monospace); font-weight: 800; color: var(--primary-dark); background: var(--green-50); border: 1px solid var(--green-100); border-radius: 6px; padding: 0 6px; margin-right: 8px; font-size: var(--fs-sm); white-space: nowrap; }
.tb-cust .li-num { margin-right: 6px; padding: 0 4px; }
.list-item .li-meta { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.chev::after { content: "›"; color: var(--gray-400); font-size: 22px; margin-left: 4px; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field > label { font-weight: 600; font-size: var(--fs-sm); color: var(--gray-700); }
.input, .select, .textarea {
  width: 100%; min-height: var(--touch); padding: 10px 14px;
  border: 1px solid var(--gray-300); border-radius: var(--r-md);
  font-size: var(--fs-md); font-family: inherit; background: var(--surface); color: var(--text);
}
.textarea { min-height: 92px; padding: 12px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--sh-focus); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; padding: 12px 16px; font-weight: 700; color: var(--text-muted);
  cursor: pointer; border-bottom: 3px solid transparent; min-height: var(--touch);
}
.tabs button.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.segmented { display: inline-flex; background: var(--gray-100); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.segmented button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; color: var(--text-muted); cursor: pointer; min-height: 40px; }
.segmented button.active { background: var(--surface); color: var(--primary-dark); box-shadow: var(--sh-1); }

/* Modal + Bottom-Sheet */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,30,22,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: var(--sp-4);
  animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-2);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 1080px; }
.modal-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: var(--sp-5); overflow: auto; }
.modal-foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); display: flex; gap: var(--sp-3); justify-content: flex-end; flex-wrap: wrap; }
.modal .x { border: 0; background: var(--gray-100); width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 700px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 94vh; animation: slideup .2s ease; }
}

/* Toasts */
#toasts { position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: var(--gray-900); color: #fff; padding: 12px 16px; border-radius: var(--r-md);
  box-shadow: var(--sh-2); font-weight: 600; animation: slideup .18s ease; display: flex; gap: 10px; align-items: center;
}
.toast.ok { background: var(--green-700); }
.toast.warn { background: var(--warn); }
.toast.error { background: var(--danger); }
@media (max-width: 700px) { #toasts { left: 12px; right: 12px; bottom: 80px; top: auto; max-width: none; } }

/* Tiles (Startseite) */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); max-width: 760px; margin: var(--sp-6) auto; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-6); text-align: center; cursor: pointer; box-shadow: var(--sh-1);
  transition: transform .12s, box-shadow .12s; min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--sh-2); }
.tile .tile-ic { font-size: 56px; }
.tile h2 { margin: 0; color: var(--primary-dark); }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } }

.empty { text-align: center; color: var(--text-muted); padding: var(--sp-6); }
.empty .big { font-size: 42px; margin-bottom: var(--sp-2); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-muted); padding: var(--sp-5); justify-content: center; }
