:root {
  --green: #3aad47;
  --green-dark: #2d8f38;
  --green-light: #e8f7ea;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e8e8e8;
  --text: #1a1a1a;
  --text-muted: #888;
  --sidebar-w: 220px;
  --topbar-h: 58px;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);

  /* Status colors */
  --s-anfrage: #a78bfa;
  --s-warte: #fb923c;
  --s-eingetroffen: #38bdf8;
  --s-bearbeitung: #3aad47;
  --s-ersatzteile: #f59e0b;
  --s-abgeschlossen: #10b981;
  --s-rechnung: #6366f1;
  --s-bezahlt: #059669;
  --s-zurueck: #6b7280;
  --s-entsorgt: #9ca3af;
  --s-storniert: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: #111;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid #222;
}
.logo-icon { font-size: 22px; }
.logo-title { font-weight: 700; font-size: 15px; color: var(--green); }
.logo-sub { font-size: 11px; color: #666; }

.nav-links { list-style: none; padding: 10px 0; flex: 1; }
.nav-links li { margin: 2px 8px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: #aaa;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-link:hover { background: #1e1e1e; color: #fff; }
.nav-link.active { background: var(--green); color: #fff; }
.nav-icon { font-size: 14px; width: 18px; text-align: center; }

/* ── Main ── */
#content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
}
#menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
#page-title { font-weight: 700; font-size: 16px; flex: 1; }
#topbar-actions { display: flex; gap: 8px; }

#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: #f0f0f0; color: var(--text); }
.btn-secondary:hover { background: #e4e4e4; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; }
.btn-icon:hover { background: var(--bg); }

/* ── Status badges ── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-Anfrage { background: #ede9fe; color: #7c3aed; }
.status-Warte { background: #fff7ed; color: #c2410c; }
.status-Eingetroffen { background: #e0f2fe; color: #0369a1; }
.status-Bearbeitung { background: var(--green-light); color: var(--green-dark); }
.status-Ersatzteile { background: #fffbeb; color: #b45309; }
.status-Abgeschlossen { background: #d1fae5; color: #065f46; }
.status-Rechnung { background: #e0e7ff; color: #4338ca; }
.status-Bezahlt { background: #d1fae5; color: #065f46; }
.status-Zurueck { background: #f3f4f6; color: #374151; }
.status-Entsorgt { background: #f3f4f6; color: #9ca3af; }
.status-Storniert { background: #fee2e2; color: #dc2626; }

/* ── Order cards ── */
.order-grid { display: grid; gap: 10px; }
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  transition: box-shadow 0.15s;
  cursor: pointer;
  position: relative;
  border-left: 3px solid transparent;
}
.order-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.1); }
.order-card.status-anfrage { border-left-color: #a78bfa; }
.order-card.status-warte { border-left-color: #fb923c; }
.order-card.status-eingetroffen { border-left-color: #38bdf8; }
.order-card.status-bearbeitung { border-left-color: #3aad47; }
.order-card.status-ersatzteile { border-left-color: #f59e0b; }
.order-card.status-abgeschlossen { border-left-color: #10b981; }
.order-card.status-rechnung { border-left-color: #6366f1; }
.order-card.status-bezahlt { border-left-color: #059669; }
.order-card.status-zurueck { border-left-color: #9ca3af; }
.order-card.status-entsorgt { border-left-color: #d1d5db; }
.order-card.status-storniert { border-left-color: #ef4444; }

.order-number { font-weight: 700; font-size: 13px; color: var(--green); font-family: 'DM Mono', monospace; }
.order-device { font-weight: 600; font-size: 14px; margin: 2px 0; }
.order-customer { font-size: 13px; color: var(--text-muted); }
.order-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; display: flex; gap: 12px; align-items: center; }
.order-actions { display: flex; gap: 6px; align-items: center; flex-direction: column; }

/* Status dropdown inline */
.status-select {
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  border: none;
  border-radius: 20px;
  padding: 3px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--surface);
  transition: border 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(58,173,71,0.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Dashboard stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-number { font-size: 26px; font-weight: 700; color: var(--green); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Modal ── */
#modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#modal-overlay.open { display: flex; }
#modal {
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
#modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  position: sticky;
  top: 0;
  background: var(--surface);
}
#modal-header button { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
#modal-body { padding: 20px; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1a1a1a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid #ef4444; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Order detail ── */
.order-detail { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.order-detail-main { display: flex; flex-direction: column; gap: 14px; }
.order-detail-side { display: flex; flex-direction: column; gap: 14px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 18px; }
.info-item-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.info-item-value { font-size: 14px; font-weight: 500; margin-top: 2px; }

/* Status history */
.timeline { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: flex; gap: 12px; align-items: flex-start; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-top: 5px; flex-shrink: 0; }
.timeline-text { font-size: 12.5px; }
.timeline-time { font-size: 11px; color: var(--text-muted); }

/* Messages */
.message-list { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
.message-item { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.message-out { background: var(--green-light); align-self: flex-end; max-width: 90%; }
.message-in { background: #f3f4f6; align-self: flex-start; max-width: 90%; }
.message-meta { font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; }

/* Items table in order */
.items-table { width: 100%; }
.items-table th, .items-table td { padding: 8px 10px; }

/* Tracking badge */
.tracking-info { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border-radius: 7px; font-size: 12.5px; }
.tracking-info a { color: var(--green); font-weight: 600; text-decoration: none; }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filter-bar input { max-width: 240px; }
.filter-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
  transition: all 0.15s;
}
.filter-pill:hover, .filter-pill.active { border-color: var(--green); color: var(--green); background: var(--green-light); }

/* Section title */
.section-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 10px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #menu-toggle { display: block; }
  .order-detail { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  #page-content { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
