/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --primary:        #3b82f6;
  --primary-dark:   #2563eb;
  --primary-glow:   rgba(59,130,246,.18);
  --success:        #22c55e;
  --success-glow:   rgba(34,197,94,.15);
  --warning:        #f59e0b;
  --warning-glow:   rgba(245,158,11,.15);
  --danger:         #ef4444;
  --danger-glow:    rgba(239,68,68,.15);
  --purple:         #a78bfa;
  --purple-glow:    rgba(167,139,250,.15);

  /* Dark palette */
  --bg:             #08080b;
  --surface:        #101014;
  --surface-2:      #18181d;
  --surface-3:      #222228;
  --border:         #27272d;
  --border-2:       #36363e;
  --text:           #f0f0f4;
  --text-2:         #9090a0;
  --text-3:         #55555f;

  /* Legacy aliases (used in templates) */
  --gray-50:        #18181d;
  --gray-100:       #222228;
  --gray-200:       #2e2e36;
  --gray-300:       #42424c;
  --gray-400:       #606070;
  --gray-500:       #80809a;
  --gray-600:       #a0a0b4;
  --gray-700:       #c0c0d0;
  --gray-800:       #e0e0ea;
  --gray-900:       #f0f0f4;
  --primary-light:  rgba(59,130,246,.14);
  --success-light:  rgba(34,197,94,.12);
  --warning-light:  rgba(245,158,11,.12);
  --danger-light:   rgba(239,68,68,.12);
  --purple-light:   rgba(167,139,250,.14);
  --primary-dark:   #2563eb;

  --sidebar-bg:     #000000;
  --sidebar-w:      240px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.5);
  --shadow-md:      0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:      0 20px 48px rgba(0,0,0,.7);
}

/* ── Light Theme Override ───────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --surface-2:      #f1f5f9;
  --surface-3:      #e2e8f0;
  --border:         #e2e8f0;
  --border-2:       #cbd5e1;
  --text:           #0f172a;
  --text-2:         #475569;
  --text-3:         #94a3b8;
  --primary-glow:   rgba(59,130,246,.12);
  --success-glow:   rgba(34,197,94,.12);
  --warning-glow:   rgba(245,158,11,.12);
  --danger-glow:    rgba(239,68,68,.10);
  --purple-glow:    rgba(139,92,246,.12);
  --gray-50:        #f8fafc;
  --gray-100:       #f1f5f9;
  --gray-200:       #e2e8f0;
  --gray-300:       #cbd5e1;
  --gray-400:       #94a3b8;
  --gray-500:       #64748b;
  --gray-600:       #475569;
  --gray-700:       #334155;
  --gray-800:       #1e293b;
  --gray-900:       #0f172a;
  --primary-light:  rgba(59,130,246,.10);
  --success-light:  rgba(34,197,94,.10);
  --warning-light:  rgba(245,158,11,.10);
  --danger-light:   rgba(239,68,68,.08);
  --purple-light:   rgba(139,92,246,.10);
  --sidebar-bg:     #0f172a;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 20px 48px rgba(0,0,0,.15);
}
[data-theme="light"] .badge-lager          { background: #dbeafe; color: #1d4ed8; }
[data-theme="light"] .badge-in_verwendung  { background: #dcfce7; color: #15803d; }
[data-theme="light"] .badge-ausgemustert   { background: #f1f5f9; color: #64748b; }
[data-theme="light"] .badge-erfassung      { background: #f5f3ff; color: #6d28d9; }
[data-theme="light"] .badge-neuinstallation{ background: #dcfce7; color: #15803d; }
[data-theme="light"] .badge-austausch      { background: #fffbeb; color: #92400e; }
[data-theme="light"] .badge-abbau          { background: #fef2f2; color: #991b1b; }
[data-theme="light"] .badge-ausmustern     { background: #f1f5f9; color: #475569; }
[data-theme="light"] .badge-reaktivieren   { background: #eff6ff; color: #1d4ed8; }
[data-theme="light"] .toast { background: #1e293b; }
[data-theme="light"] .toast-success { background: #166534; }
[data-theme="light"] .toast-error   { background: #991b1b; }
[data-theme="light"] .customer-count { background: #dbeafe; color: #1d4ed8; }
[data-theme="light"] .alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
[data-theme="light"] .alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
[data-theme="light"] .alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
[data-theme="light"] .alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
[data-theme="light"] .scan-result   { background: #f0fdf4; color: #166534; border-color: #86efac; }
[data-theme="light"] .hw-tag { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
[data-theme="light"] .hw-tag-remove { color: #1d4ed8; }
[data-theme="light"] .login-screen { background: #f8fafc; }
[data-theme="light"] .search-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
}

/* ── Theme Toggle Button ─────────────────────────────────────────────────── */
.theme-toggle {
  margin-top: auto;
  background: none; border: none;
  color: var(--text-3); padding: 8px 18px;
  border-top: 1px solid rgba(255,255,255,.05);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: color .12s, background .12s;
  width: 100%; text-align: left;
}
.theme-toggle:hover { background: rgba(255,255,255,.05); color: var(--text-2); }
[data-theme="light"] .theme-toggle { border-top-color: rgba(0,0,0,.07); }
[data-theme="light"] .theme-toggle:hover { background: rgba(0,0,0,.05); }
.theme-toggle svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--primary-glow); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
  border-right: 1px solid rgba(255,255,255,.05);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-weight: 700; font-size: 15px; color: #fff;
  letter-spacing: -.01em;
}
.sidebar-brand svg { width: 26px; height: 26px; flex-shrink: 0; color: var(--primary); }

.nav-section { padding: 6px 0; }
.nav-section-label {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 7px; margin: 1px 6px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  transition: background .12s, color .12s;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.06); color: var(--text); }
.nav-link.active { background: var(--primary-glow); color: #93c5fd; }
.nav-link.active svg { color: var(--primary); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}

.main-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 54px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.main-header h1 { font-size: 16px; font-weight: 600; color: var(--text); }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

.menu-toggle {
  display: none; background: none; border: none;
  padding: 6px; border-radius: 6px; color: var(--text-2);
}
.menu-toggle:hover { background: var(--surface-2); }
.menu-toggle svg { width: 20px; height: 20px; }

.content { padding: 24px; flex: 1; }

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

/* ── Stat Cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 18px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s;
}
.stat-card:hover { border-color: var(--border-2); }
.stat-card .stat-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .07em;
}
.stat-card .stat-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); }
.stat-card .stat-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-icon.blue   { background: var(--primary-glow);  color: var(--primary); }
.stat-icon.green  { background: var(--success-glow);  color: var(--success); }
.stat-icon.amber  { background: var(--warning-glow);  color: var(--warning); }
.stat-icon.gray   { background: var(--surface-3);     color: var(--text-2); }
.stat-icon.purple { background: var(--purple-glow);   color: var(--purple); }

/* ── Grid Layouts ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* ── Charts ─────────────────────────────────────────────────────────────── */
.charts-row { display: grid; grid-template-columns: 320px 1fr; gap: 18px; margin-bottom: 22px; }
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { border-bottom: 1px solid var(--border); }
th {
  padding: 10px 14px; text-align: left; font-weight: 600; font-size: 11px;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .07em;
  white-space: nowrap; background: var(--surface);
  cursor: default; user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text-2); }
th.sort-asc::after  { content: ' ↑'; color: var(--primary); }
th.sort-desc::after { content: ' ↓'; color: var(--primary); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-lager          { background: rgba(59,130,246,.15);  color: #93c5fd; }
.badge-in_verwendung  { background: rgba(34,197,94,.14);   color: #86efac; }
.badge-ausgemustert   { background: var(--surface-3);       color: var(--text-2); }
.badge-erfassung      { background: var(--purple-glow);    color: var(--purple); }
.badge-neuinstallation{ background: rgba(34,197,94,.14);   color: #86efac; }
.badge-austausch      { background: rgba(245,158,11,.14);  color: #fcd34d; }
.badge-abbau          { background: rgba(239,68,68,.14);   color: #fca5a5; }
.badge-ausmustern     { background: var(--surface-3);       color: var(--text-2); }
.badge-reaktivieren   { background: var(--primary-glow);   color: #93c5fd; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all .12s; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover:not(:disabled) { background: #d97706; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-outline {
  background: transparent; color: var(--text-2);
  border-color: var(--border-2);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.form-label .required { color: var(--danger); }
.form-control {
  padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px; color: var(--text);
  background: var(--surface-2);
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control::placeholder { color: var(--text-3); }
select.form-control option { background: var(--surface-2); color: var(--text); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--text-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Filters bar ────────────────────────────────────────────────────────── */
.filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-group { display: flex; gap: 4px; }
.filter-btn {
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  transition: all .12s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.search-input {
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: var(--surface-2); color: var(--text);
  width: 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2355555f' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 15px;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-input::placeholder { color: var(--text-3); }
.filter-count { font-size: 11.5px; color: var(--text-3); margin-left: 4px; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
.modal-backdrop.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .18s ease;
}
@keyframes slideUp { from { transform: translateY(14px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-header {
  padding: 18px 18px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: none; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; line-height: 1;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 0 18px 18px; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-2);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .18s ease;
  min-width: 240px;
}
@keyframes toastIn { from { transform: translateX(30px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
.toast-success { background: #052e16; border-color: #166534; color: #86efac; }
.toast-error   { background: #2d0b0b; border-color: #991b1b; color: #fca5a5; }
.toast-icon svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state svg { width: 44px; height: 44px; color: var(--text-3); }
.empty-state h3 { font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty-state p { font-size: 13px; color: var(--text-3); }

/* ── Timeline ───────────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.timeline-icon svg { width: 13px; height: 13px; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-title { font-size: 13px; font-weight: 600; color: var(--text); }
.timeline-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.timeline-notes {
  font-size: 12px; color: var(--text-2); margin-top: 4px;
  background: var(--surface-2); padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Hardware Detail ─────────────────────────────────────────────────────── */
.hw-detail-grid { display: grid; grid-template-columns: 1fr 270px; gap: 18px; }
.hw-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hw-info-item {}
.hw-info-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); margin-bottom: 2px;
}
.hw-info-value { font-size: 13px; color: var(--text); font-weight: 500; }
.hw-info-value.empty { color: var(--text-3); font-style: italic; font-weight: 400; }

.action-card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); }
.action-card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); }
.action-buttons { padding: 14px; display: flex; flex-direction: column; gap: 7px; }
.action-form-area { padding: 0 14px 14px; display: none; }
.action-form-area.open { display: block; }

.qr-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 18px; text-align: center;
}
.qr-card img { max-width: 160px; border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--border); }
.qr-code-label { font-size: 13px; font-weight: 600; color: var(--text); }
.qr-url { font-size: 10.5px; color: var(--text-3); word-break: break-all; margin-top: 4px; }

/* ── QR Print Grid ───────────────────────────────────────────────────────── */
.qr-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.qr-label-card {
  display: flex; flex-direction: row; align-items: center;
  gap: 10px;
  background: #fff; color: #000;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px 12px 6px 6px;
  width: 315px; height: 101px;
  flex-shrink: 0;
  transition: box-shadow .15s;
}
.qr-label-card { cursor: pointer; position: relative; user-select: none; }
.qr-label-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.qr-label-card.selected { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.35); }
.qr-label-check {
  position: absolute; top: 5px; left: 5px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #ccc; background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s;
  flex-shrink: 0; z-index: 1;
}
.qr-label-check svg { width: 10px; height: 10px; opacity: 0; stroke: #fff; transition: opacity .12s; }
.qr-label-card.selected .qr-label-check { background: #2563eb; border-color: #2563eb; }
.qr-label-card.selected .qr-label-check svg { opacity: 1; }
.qr-label-card img { width: 86px; height: 86px; flex-shrink: 0; display: block; }
.qr-label-info { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.qr-label-code { font-size: 15px; font-weight: 700; color: #000; font-family: monospace; letter-spacing: .02em; }
.qr-label-type { font-size: 10.5px; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: .06em; }
.qr-label-model { font-size: 12px; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-label-serial { font-size: 10.5px; color: #777; }

/* ── Scanner ─────────────────────────────────────────────────────────────── */
#reader { border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-2); }
.scan-result {
  background: var(--success-glow); border: 1px solid rgba(34,197,94,.3);
  border-radius: var(--radius); padding: 11px 14px;
  font-size: 13px; color: var(--success); font-weight: 500;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; flex-direction: column; gap: 12px;
  color: var(--text-3); font-size: 13px;
}

/* ── Misc ────────────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 18px; display: flex; align-items: flex-start; justify-content: space-between; }
.page-header h2 { font-size: 19px; font-weight: 700; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
.gap-2 { gap: 8px; }
.flex { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }

/* ── Overlay nav backdrop (mobile) ──────────────────────────────────────── */
#nav-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 99;
}

/* ── Alert / Info box ────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius); padding: 11px 14px;
  font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
}
.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--primary-glow); color: #93c5fd; border: 1px solid rgba(59,130,246,.25); }
.alert-warning { background: var(--warning-glow); color: #fcd34d; border: 1px solid rgba(245,158,11,.25); }
.alert-success { background: var(--success-glow); color: #86efac; border: 1px solid rgba(34,197,94,.25); }
.alert-danger  { background: var(--danger-glow);  color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .hw-detail-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  #nav-backdrop.open { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .hw-info-grid { grid-template-columns: 1fr; }
  .main-header { padding: 0 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .search-input { width: 100%; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
}

/* ── Protocol Form ───────────────────────────────────────────────────────── */
.proto-section {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); margin-bottom: 12px;
}
.proto-section-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.proto-section-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.proto-section-body {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 13px;
}

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.toggle-btn {
  padding: 7px 16px; border: none;
  background: var(--surface-2); font-size: 12.5px; font-weight: 500;
  color: var(--text-2); cursor: pointer; transition: all .12s;
  border-right: 1px solid var(--border);
}
.toggle-btn:last-child { border-right: none; }
.toggle-btn:hover:not(.active) { background: var(--surface-3); }
.toggle-btn.active { background: var(--primary); color: #fff; }
.toggle-btn.active-yes { background: var(--success); color: #fff; }

.hw-tag-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; }
.hw-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-glow); color: #93c5fd;
  border: 1px solid rgba(59,130,246,.25); border-radius: 20px;
  padding: 4px 10px; font-size: 12px; font-weight: 600;
  font-family: 'SF Mono','Fira Code',monospace;
}
.hw-tag-remove {
  background: none; border: none; cursor: pointer;
  color: #93c5fd; font-size: 14px; line-height: 1;
  padding: 0; opacity: .6; transition: opacity .1s;
}
.hw-tag-remove:hover { opacity: 1; }

.zusatz-row { padding: 10px; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }

.photo-preview-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.photo-preview-item {
  position: relative; width: 90px; height: 90px;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
}
.photo-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; background: rgba(0,0,0,.7); color: #fff;
  border: none; border-radius: 50%; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Protocol Detail ─────────────────────────────────────────────────────── */
.proto-detail-block { margin-bottom: 18px; }
.proto-detail-block .card-header { background: var(--surface-2); }
.proto-field-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px;
}
.proto-field-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); margin-bottom: 3px;
}
.proto-field-value { font-size: 13px; color: var(--text); font-weight: 500; }
.proto-field-value.empty { color: var(--text-3); font-style: italic; font-weight: 400; }
.proto-yn-yes { color: var(--success); font-weight: 600; }
.proto-yn-no  { color: var(--text-3); }

.proto-photo-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.proto-photo-grid img {
  width: 200px; height: 150px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s;
}
.proto-photo-grid img:hover { border-color: var(--primary); }

/* ── Type Selector (QR Generator) ───────────────────────────────────────── */
.type-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.type-select-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  line-height: 1.3; text-align: center;
}
.type-select-btn .type-icon { font-size: 20px; }
.type-select-btn:hover { border-color: var(--primary); color: var(--text); }
.type-select-btn.active { border-color: var(--primary); background: var(--primary-glow); color: #93c5fd; font-weight: 600; }

/* ── Login Screen ────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
  width: 100%; max-width: 370px;
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-size: 17px; font-weight: 700;
  margin-bottom: 28px; letter-spacing: -.01em;
}
.login-brand svg { width: 26px; height: 26px; color: var(--primary); }
.login-title {
  font-size: 19px; font-weight: 700; color: var(--text);
  margin-bottom: 20px; letter-spacing: -.02em;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-error {
  background: var(--danger-glow); color: #fca5a5;
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px;
}

/* ── Sidebar User Info ───────────────────────────────────────────────────── */
.sidebar-user {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.05);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sidebar-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 12.5px; font-weight: 600; color: #d0d0e0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-role { font-size: 10.5px; color: var(--text-3); }
.sidebar-logout-btn {
  background: none; border: none; color: var(--text-3); padding: 6px;
  border-radius: var(--radius); display: flex; align-items: center;
  transition: color .12s, background .12s; flex-shrink: 0;
}
.sidebar-logout-btn svg { width: 15px; height: 15px; }
.sidebar-logout-btn:hover { color: var(--danger); background: var(--danger-glow); }

/* ── Customer/Location List ──────────────────────────────────────────────── */
.customer-list { display: flex; flex-direction: column; gap: 4px; }
.customer-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px;
}
.customer-row:hover { border-color: var(--border-2); }
.customer-name { font-weight: 500; color: var(--text); }
.customer-count {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  background: var(--primary-glow); color: #93c5fd;
  border-radius: 12px;
}

/* ── Print (general) ─────────────────────────────────────────────────────── */
@media print {
  .sidebar, .main-header, .filters, .btn, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .print-only { display: block !important; }
  body { background: #fff; color: #000; }
  .card, .proto-section { background: #fff; border-color: #ccc; box-shadow: none; }
  .proto-section-num { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .toggle-btn.active { background: #000 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .proto-detail-block { page-break-inside: avoid; break-inside: avoid; }
  .proto-photo-grid img { width: 150px; height: 112px; }
  .hw-tag { border: 1px solid #999; background: #ddf !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table, td, th { color: #000 !important; border-color: #ccc !important; }
}

/* ── Print: QR Labels 29mm × 90mm ────────────────────────────────────────── */
@media print {
  body.print-qr-labels *,
  body.print-qr-labels *::before,
  body.print-qr-labels *::after { box-sizing: border-box; }
  body.print-qr-labels .main,
  body.print-qr-labels .content { margin: 0 !important; padding: 0 !important; }
  body.print-qr-labels .qr-grid { display: block; margin: 0; padding: 0; }
  body.print-qr-labels .qr-label-card {
    width: 90mm !important; height: 29mm !important;
    min-width: 0; min-height: 0;
    border: none !important; border-radius: 0 !important;
    box-shadow: none !important; outline: none !important;
    padding: 2mm 3mm 2mm 2mm !important;
    gap: 2.5mm !important;
    margin: 0 !important;
    page-break-after: always; break-after: page;
    overflow: hidden;
  }
  body.print-qr-labels .qr-label-card:last-child { page-break-after: avoid; break-after: avoid; }
  body.print-qr-labels .qr-label-card img { width: 25mm !important; height: 25mm !important; flex-shrink: 0; }
  body.print-qr-labels .qr-label-check { display: none !important; }
  body.print-qr-labels .qr-label-code { font-size: 10.5pt !important; font-weight: 700; color: #000 !important; }
  body.print-qr-labels .qr-label-type { font-size: 7pt !important; color: #444 !important; }
  body.print-qr-labels .qr-label-model { font-size: 8pt !important; white-space: normal; color: #111 !important; }
  body.print-qr-labels .qr-label-serial { font-size: 7pt !important; color: #555 !important; }
}
