:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --border: #2a2f3a;
  --text: #e6e8eb;
  --muted: #8a8f99;
  --accent: #4f8cff;
  --green: #2ea043;
  --orange: #f0883e;
  --red: #f85149;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
}
.container { max-width: 960px; margin: 0 auto; padding: 24px; }
header h1 { margin: 0 0 4px 0; font-size: 28px; }
.subtitle { margin: 0 0 24px 0; color: var(--muted); font-size: 14px; }

.lookup-form {
  display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.lookup-form .field { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.lookup-form label { font-size: 12px; color: var(--muted); }
.lookup-form input {
  padding: 10px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 15px;
}
.lookup-form input:focus { outline: none; border-color: var(--accent); }
.lookup-form button {
  padding: 10px 20px; background: var(--accent); color: white; border: none;
  border-radius: 6px; cursor: pointer; font-size: 15px; font-weight: 500;
}
.lookup-form button:hover { background: #5e9bff; }
.refresh-link { color: var(--muted); font-size: 13px; padding: 10px; text-decoration: none; }
.refresh-link:hover { color: var(--text); }

.alert { padding: 12px 16px; border-radius: 8px; margin: 16px 0; }
.alert.error { background: rgba(248,81,73,0.15); border: 1px solid var(--red); color: #ffb4af; }

.merchant-bar {
  margin: 20px 0; padding: 10px 14px; background: var(--panel);
  border-left: 3px solid var(--accent); border-radius: 6px;
}
.merchant-bar .muted { font-size: 12px; margin-left: 8px; }
.muted { color: var(--muted); }

.summary-box {
  margin: 16px 0; padding: 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px;
}
.summary-box h2 { margin: 0 0 12px 0; font-size: 14px; color: var(--muted); font-weight: 500; }

.quantity-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
}
.quantity-grid div { display: flex; flex-direction: column; align-items: center; padding: 10px; background: var(--bg); border-radius: 6px; }
.quantity-grid .num { font-size: 24px; font-weight: 600; }
.quantity-grid .num.strong { color: var(--green); }
.quantity-grid > div > span:last-child { font-size: 11px; color: var(--muted); margin-top: 2px; }
.quantity-grid.small .num { font-size: 20px; }

.hit-card {
  display: flex; gap: 16px; margin: 12px 0; padding: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
.hit-image { flex-shrink: 0; width: 80px; height: 80px; }
.hit-image img { width: 100%; height: 100%; object-fit: contain; background: white; border-radius: 6px; }
.no-image { width: 100%; height: 100%; background: var(--bg); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.hit-body { flex: 1; min-width: 0; }
.hit-body h3 { margin: 0 0 6px 0; font-size: 16px; line-height: 1.3; }
.hit-sku { margin-bottom: 12px; }
.hit-sku code { padding: 2px 6px; background: var(--bg); border-radius: 4px; font-size: 12px; }
.hit-meta { font-size: 12px; margin-top: 8px; }

.tags { margin: 10px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 10px; background: rgba(255,255,255,0.08); }
.tag-blue { background: rgba(79,140,255,0.2); color: #aac8ff; }
.tag-green { background: rgba(46,160,67,0.2); color: #a4e1b3; }
.tag-orange { background: rgba(240,136,62,0.2); color: #ffd1a4; }
.tag-red { background: rgba(248,81,73,0.2); color: #ffb4af; }
.tag-gray { background: rgba(138,143,153,0.2); color: var(--muted); }

.identifiers { margin: 10px 0; }
.identifiers summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.identifiers table { margin: 8px 0 0 0; border-collapse: collapse; font-size: 12px; }
.identifiers td { padding: 2px 12px 2px 0; }
.identifiers code { font-size: 12px; }

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---------- Dashboard ---------- */
.container.wide { max-width: 1200px; }
.dash-header { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 8px 14px; background: var(--panel); color: var(--muted);
  text-decoration: none; border-radius: 6px; font-size: 14px; border: 1px solid var(--border); }
.topnav a:hover { color: var(--text); }
.topnav a.current { background: var(--accent); color: white; border-color: var(--accent); }

.manual-form-box { margin: 16px 0 24px 0; padding: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.manual-form-box h2 { margin: 0 0 12px 0; font-size: 14px; color: var(--muted); font-weight: 500; }
.lookup-form.inline { padding: 0; background: none; border: none; }
.field.grow { flex: 2; }

.center { text-align: center; }
.kunde-card { margin: 16px 0; padding: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.kunde-header { display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.kunde-header h2 { margin: 0; font-size: 18px; }
.kn { display: inline-block; background: var(--bg); border-radius: 4px;
  padding: 2px 8px; font-size: 13px; color: var(--accent); margin-right: 6px;
  font-family: ui-monospace, monospace; }
.block { margin-top: 12px; }
.block h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 12px 0 6px 0; }

table.items { width: 100%; border-collapse: collapse; font-size: 13px; }
table.items th { text-align: left; padding: 6px 8px; color: var(--muted);
  font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); }
table.items td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.items tr:last-child td { border-bottom: none; }
table.items td.num, table.items th.num { text-align: right; }
.title-cell { max-width: 380px; }
.qty { display: inline-block; min-width: 32px; padding: 2px 8px; border-radius: 6px;
  font-weight: 600; text-align: center; }
.qty-have { background: rgba(46,160,67,0.2); color: #a4e1b3; }
.qty-zero { background: rgba(138,143,153,0.15); color: var(--muted); }
.row-actions button.ghost { background: transparent; border: 1px solid var(--border);
  color: var(--muted); padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; margin-right: 4px; }
.row-actions button.ghost:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Phase-4-Erweiterungen ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot-red { background: var(--red); }
.dot-yellow { background: var(--orange); }
.dot-green { background: var(--green); }

.section-title { margin: 24px 0 8px 0; font-size: 14px; color: var(--muted);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

.filter-bar { margin: 12px 0 16px 0; }
.filter-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-form input, .filter-form select {
  padding: 8px 12px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.filter-form button {
  padding: 8px 14px; background: var(--accent); color: white;
  border: none; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.seg { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg a { padding: 6px 12px; color: var(--muted); text-decoration: none; border-radius: 6px; font-size: 13px; }
.seg a:hover { color: var(--text); }
.seg a.active { background: var(--accent); color: white; }
.ghost-link { color: var(--muted); font-size: 12px; text-decoration: none; }
.ghost-link:hover { color: var(--text); }

table.tickets-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
table.tickets-table th { text-align: left; padding: 6px 8px; color: var(--muted);
  font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); }
table.tickets-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tickets-table tr:hover td { background: rgba(255,255,255,0.02); }
table.tickets-table a { color: var(--accent); text-decoration: none; }
table.tickets-table a:hover { text-decoration: underline; }
table.tickets-table tr.closed code { opacity: 0.6; }
.btn-sm { font-size: 12px; padding: 4px 10px; background: transparent;
  border: 1px solid var(--border); border-radius: 4px; color: var(--accent);
  text-decoration: none; }
.btn-sm:hover { border-color: var(--accent); }
.badge { display: inline-block; font-size: 10px; padding: 2px 6px;
  background: rgba(248,81,73,0.15); border: 1px solid var(--red);
  color: #ffb4af; border-radius: 4px; margin-left: 4px; vertical-align: middle; }

.detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 16px; margin-top: 16px; }
.detail-side .kunde-card { position: sticky; top: 16px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }

.ticket-form { display: flex; flex-direction: column; gap: 12px; }
.ticket-form .field { display: flex; flex-direction: column; gap: 4px; }
.ticket-form label { font-size: 12px; color: var(--muted); }
.ticket-form select, .ticket-form textarea, .ticket-form input {
  padding: 8px 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
  font-family: inherit;
}
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { padding: 10px 16px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: #5e9bff; }
.btn.ok { background: rgba(46,160,67,0.18); border-color: var(--green); color: #a4e1b3; }
.btn.ok:hover { background: rgba(46,160,67,0.3); }
.btn.block { display: block; width: 100%; margin-bottom: 8px; }
.btn.ghost { background: transparent; }
.small { font-size: 12px; }

/* ---------- Phase 5: Verlauf, Anhänge, Keepa, Pillen ---------- */
.product-card .product-flex { display: flex; gap: 14px; align-items: flex-start; }
.product-card .product-image { flex-shrink: 0; width: 120px; height: 120px;
  background: var(--bg); border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.product-card .product-image img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.product-card .product-meta h3 { margin: 0 0 8px 0; font-size: 15px; line-height: 1.3; }
.extracted { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  font-size: 12px; }
.pill-strong { background: rgba(46,160,67,0.18); border-color: var(--green); color: #a4e1b3; font-weight: 600; }
.pill code { background: transparent; padding: 0; font-size: 12px; }

.msg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 8px; background: var(--bg);
  border-left: 3px solid var(--border); }
.msg-customer { border-left-color: var(--accent); background: rgba(79,140,255,0.07); }
.msg-internal { border-left-color: var(--green); }
.msg-bot { opacity: 0.55; }
.msg-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 13px; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.45; }
.msg-attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.msg-attachments img { max-width: 220px; max-height: 200px; border-radius: 6px;
  border: 1px solid var(--border); display: block; cursor: zoom-in; }
.attach-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  text-decoration: none; color: var(--text); font-size: 13px; }
.attach-file:hover { border-color: var(--accent); }
.badge-soft { font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: rgba(46,160,67,0.2); color: #a4e1b3; }
.badge-soft.muted { background: rgba(138,143,153,0.15); color: var(--muted); }
.badge-soft.soft-blue { background: rgba(79,140,255,0.18); color: #aac8ff; }

.spinner { display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--muted); border-top-color: var(--accent);
  border-radius: 50%; vertical-align: middle;
  animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.zoomable { display: inline-block; cursor: zoom-in; }
.zoomable img { display: block; }

.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
  max-width: 92vw; max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7);
  cursor: default;
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

.alert.success { background: rgba(46,160,67,0.18); border: 1px solid var(--green); color: #a4e1b3; }

.channel-meter {
  display: flex; align-items: center; gap: 12px; margin-top: 8px;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.channel-meter strong { color: var(--text); }
.meter-bar { display: inline-block; width: 220px; height: 8px;
  background: var(--bg); border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border); }
.meter-fill { display: block; height: 100%; transition: width 0.3s; }
.bar-green { background: var(--green); }
.bar-yellow { background: var(--orange); }
.bar-red { background: var(--red); }
.meter-detail { font-size: 11px; }

/* Bulk-Action-Bar */
.bulk-actions {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 8px 0; margin-bottom: 4px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.bulk-actions .count { font-size: 13px; color: var(--muted); }
.bulk-actions .count strong { color: var(--text); }
.bulk-actions[data-empty="true"] { display: none; }
input[type="checkbox"].row-check, input[type="checkbox"].master-check {
  width: 16px; height: 16px; cursor: pointer; vertical-align: middle;
}

/* Verlauf — Avatar pro User */
.msg-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 12px; font-weight: 600; color: white;
  margin-right: 4px;
}

/* Discord-Link in Header und Aktionsspalten */
.discord-link {
  font-size: 12px; padding: 4px 10px; margin-left: 12px;
  background: rgba(88,101,242,0.18); color: #aab1ff;
  border: 1px solid #5865F2; border-radius: 6px;
  text-decoration: none; vertical-align: middle;
}
.discord-link:hover { background: rgba(88,101,242,0.32); }

.action-cell { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.btn-sm.ghost { padding: 4px 8px; }

.user-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; color: var(--muted); margin-left: 4px;
}
.topnav-logout {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); padding: 6px 10px; border-radius: 6px;
  cursor: pointer; font-size: 14px;
}
.topnav-logout:hover { color: var(--text); border-color: var(--accent); }

.check-inline { display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text); cursor: pointer; padding: 0 6px; }
.check-inline input { margin: 0; }

.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px;
}
.login-card h1 { margin: 0 0 4px 0; font-size: 20px; }
.login-card .subtitle { margin: 0 0 24px 0; }
.login-card .field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 12px; color: var(--muted); }
.login-card input {
  padding: 10px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card .btn.block { width: 100%; margin-top: 8px; }

.inline-actions { position: relative; display: inline-block; }
.inline-actions summary { list-style: none; cursor: pointer; }
.inline-actions summary::-webkit-details-marker { display: none; }
.actions-pop {
  position: absolute; right: 0; top: 100%;
  background: var(--panel); border: 1px solid var(--border);
  padding: 12px; border-radius: 8px; z-index: 10; min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.tag-purple { background: rgba(168,85,247,0.2); color: #d4b3ff; }

/* ---------- Pickliste ---------- */
.picklist-card { margin: 16px 0; padding: 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; }
.picklist-header { display: flex; justify-content: space-between;
  align-items: baseline; border-bottom: 1px solid var(--border);
  padding-bottom: 8px; margin-bottom: 10px; }
.picklist-header h2 { margin: 0; font-size: 17px; }

table.picklist-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.picklist-table th { text-align: left; padding: 6px 8px; color: var(--muted);
  font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); }
table.picklist-table td { padding: 8px; border-bottom: 1px solid var(--border);
  vertical-align: top; }
table.picklist-table .img-col { width: 60px; }
table.picklist-table .img-col img,
table.picklist-table .no-image.small {
  width: 60px; height: 60px; object-fit: contain; background: white;
  border-radius: 4px; display: block;
}
table.picklist-table .no-image.small {
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 16px;
}
table.picklist-table .qty-cell { width: 60px; }
table.picklist-table .title-cell { max-width: 300px; }
table.picklist-table .ticket-link { font-size: 11px; margin-top: 4px; }
table.picklist-table .ticket-link a { color: var(--accent); text-decoration: none; }
table.picklist-table .note-cell { max-width: 200px; word-wrap: break-word; }

.btn-sm.ok { background: rgba(46,160,67,0.2); border-color: var(--green); color: #a4e1b3; cursor: pointer; }
.btn-sm.ok:hover { background: rgba(46,160,67,0.35); }

@media print {
  .picklist-card { break-inside: avoid; border: 1px solid #ccc; background: white !important; }
  .picklist-table th, .picklist-table td { color: black !important; border-color: #ddd !important; }
  .picklist-header h2 { color: black; }
  .picklist-table .qty-cell .pill-strong {
    background: white; border: 2px solid black; color: black; font-weight: 700;
  }
  .picklist-table img { box-shadow: 0 0 0 1px #ccc; }
}

@media print {
  body { background: white; color: black; }
  .container.wide { max-width: none; padding: 12px; }
  .no-print { display: none !important; }
  .kunde-card { break-inside: avoid; border: 1px solid #ccc; background: white; }
  .panel, .manual-form-box { background: white; }
  table.items th, table.items td { color: black; border-color: #ccc; }
  .qty-have { background: #d4edda; color: #155724; }
  .qty-zero { background: #f0f0f0; color: #555; }
  .tag { background: #eee; color: #333; }
  code { background: #f5f5f5; color: black; }
}
