:root {
  --rot: #b7393e; --rot-dunkel: #8f2a2e; --rot-hell: #f6d5d6;
  --bg: #f4f4f5; --karte: #ffffff; --text: #18181b; --text-2: #5b5b63; --linie: #e2e2e6;
  --gruppe: #ececef; --calc: #f8f8fa; --hover: #fbf1f1; --gruen: #2f7d4f; --gruen-hell: #dcefe3;
  --grau-hell: #ededf0; --schatten: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
body.dunkel {
  --bg: #111113; --karte: #1b1b1e; --text: #ececf0; --text-2: #a1a1aa; --linie: #2e2e33;
  --gruppe: #232327; --calc: #19191c; --hover: #2a1e1f; --rot-hell: #4a2224; --gruen-hell: #1d3326;
  --grau-hell: #26262b; --schatten: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Kopfzeile */
header.top { background: #000; color: #fff; display: flex; align-items: center; gap: 16px; padding: 8px 16px; flex-wrap: wrap; }
header.top img.logo { height: 42px; width: 42px; display: block; }
header.top h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; }
header.top h1 span { color: var(--rot); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #1f1f22; border: 1px solid #333; border-radius: 999px; padding: 3px 10px; font-size: 12px; color: #ddd; white-space: nowrap; cursor: default; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #777; }
.dot.ok { background: #3fb86b; } .dot.fehler { background: var(--rot); } .dot.laeuft { background: #fff; animation: puls 1s infinite; }
@keyframes puls { 50% { opacity: .3; } }
.top .rechts { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn { border: 1px solid var(--linie); background: var(--karte); border-radius: 8px; padding: 6px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--rot); }
.btn.primaer { background: var(--rot); border-color: var(--rot); color: #fff; }
.btn.primaer:hover { background: var(--rot-dunkel); }
.btn.dunkel { background: #1f1f22; border-color: #3a3a3f; color: #fff; }
.btn.dunkel:hover { border-color: var(--rot); }
.btn.klein { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 3px 5px; border-radius: 6px; color: var(--text-2); font-size: 14px; }
.icon-btn:hover { background: var(--grau-hell); color: var(--rot); }

/* Filterleiste */
.filter { display: flex; gap: 10px; align-items: center; padding: 10px 16px; flex-wrap: wrap; background: var(--karte); border-bottom: 1px solid var(--linie); }
.filter input[type=search] { width: 260px; padding: 6px 10px; border: 1px solid var(--linie); border-radius: 8px; background: var(--bg); }
.filter select { padding: 6px 8px; border: 1px solid var(--linie); border-radius: 8px; background: var(--bg); }
.filter label.tg { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; user-select: none; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--linie); }
.filter label.tg:has(input:checked) { border-color: var(--rot); background: var(--rot-hell); }
.filter .zaehler { margin-left: auto; color: var(--text-2); }
.filter .warnzahl { color: var(--rot); font-weight: 600; }

/* Tabelle */
.tabelle-wrap { flex: 1; overflow: auto; }
table.liste { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; background: var(--karte); }
table.liste th, table.liste td { border-bottom: 1px solid var(--linie); padding: 4px 8px; white-space: nowrap; text-align: right; }
table.liste th { position: sticky; top: 0; z-index: 3; background: var(--rot); color: #fff; font-weight: 600; font-size: 12px; text-align: center; white-space: normal; line-height: 1.2; padding: 6px 8px; min-width: 70px; }
table.liste th.links, table.liste td.links { text-align: left; }
table.liste td.produkt, table.liste th.produkt { position: sticky; left: 0; z-index: 2; background: inherit; text-align: left; min-width: 230px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--linie); }
table.liste th.produkt { z-index: 4; background: var(--rot); }
table.liste tbody tr { background: var(--karte); }
table.liste tbody tr:hover { background: var(--hover); }
table.liste tr.gruppe td { background: var(--gruppe); font-weight: 700; text-align: left; font-size: 13px; position: sticky; left: 0; }
table.liste tr.gruppe td .anz { font-weight: 400; color: var(--text-2); margin-left: 6px; }
td.calc { background: var(--calc); color: var(--text-2); }
td.edit { cursor: text; }
td.edit:hover { outline: 1px dashed var(--rot); outline-offset: -2px; }
td.leer { color: var(--text-2); opacity: .5; }
td input.zelle { width: 100%; min-width: 60px; border: 1px solid var(--rot); border-radius: 4px; padding: 2px 4px; text-align: inherit; background: var(--karte); }
tr.warn td.produkt { box-shadow: inset 4px 0 0 var(--rot); }
td.warnwert { color: var(--rot); font-weight: 700; background: var(--rot-hell); }
td.gutwert { color: var(--gruen); }
.pfeil-hoch { color: var(--rot); font-weight: 700; }
.pfeil-runter { color: var(--gruen); font-weight: 700; }
.ek-alt { font-size: 11px; color: var(--text-2); text-decoration: line-through; margin-right: 4px; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: .3px; vertical-align: 1px; }
.badge.sst { background: #000; color: #fff; }
.badge.cc { background: var(--rot); color: #fff; }
.badge.keine { background: var(--grau-hell); color: var(--text-2); font-weight: 500; }
.badge.fehlt { background: var(--rot-hell); color: var(--rot); }
.badge.waehrung { background: var(--grau-hell); color: var(--text-2); cursor: pointer; }
td.quelle { text-align: left; cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
td.quelle .klein { color: var(--text-2); font-size: 11px; margin-left: 4px; }
td.aktionen { text-align: center; white-space: nowrap; }
body.kompakt .opt { display: none; }

/* Dialoge */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow: auto; }
.dialog { background: var(--karte); border-radius: 12px; box-shadow: var(--schatten); width: min(900px, 100%); padding: 18px 20px; }
.dialog.schmal { width: min(520px, 100%); }
.dialog h2 { margin: 0 0 4px; font-size: 17px; }
.dialog .unter { color: var(--text-2); margin-bottom: 12px; }
.dialog .fuss { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog .zeile { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.dialog label.feld { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); flex: 1; min-width: 140px; }
.dialog label.feld input, .dialog label.feld select, .dialog textarea { padding: 6px 8px; border: 1px solid var(--linie); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--linie); }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-2); }
.tabs button.aktiv { border-color: var(--rot); color: var(--text); font-weight: 600; }
.trefferliste { max-height: 52vh; overflow: auto; border: 1px solid var(--linie); border-radius: 8px; }
.treffer { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--linie); }
.treffer:last-child { border-bottom: 0; }
.treffer:hover { background: var(--hover); }
.treffer .name { font-weight: 600; }
.treffer .meta { color: var(--text-2); font-size: 12px; }
.treffer .preis { font-weight: 700; text-align: right; }
.score { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 0; text-align: center; background: var(--grau-hell); }
.score.hoch { background: var(--gruen-hell); color: var(--gruen); }
.score.mittel { background: #ececec; color: #555; }
body.dunkel .score.mittel { background: #333; color: #ccc; }
table.mini { width: 100%; border-collapse: collapse; }
table.mini th, table.mini td { padding: 6px 8px; border-bottom: 1px solid var(--linie); text-align: left; }
table.mini th { font-size: 12px; color: var(--text-2); font-weight: 600; }
.leerhinweis { padding: 24px; text-align: center; color: var(--text-2); }
.hinweis { background: var(--grau-hell); border-radius: 8px; padding: 8px 10px; color: var(--text-2); font-size: 12px; margin: 8px 0; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #000; color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 99; box-shadow: var(--schatten); border-left: 4px solid var(--rot); }
a { color: var(--rot); }

/* Login */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; background: #000; }
.login-karte { background: var(--karte); padding: 28px; border-radius: 14px; width: min(360px, 92vw); box-shadow: var(--schatten); }
.login-karte .kopf { background: #000; margin: -28px -28px 20px; padding: 18px; border-radius: 14px 14px 0 0; text-align: center; }
.login-karte .kopf img { height: 96px; width: 96px; }
.login-karte h1 { font-size: 18px; margin: 0 0 14px; }
.login-karte input { width: 100%; padding: 9px 10px; margin-bottom: 10px; border: 1px solid var(--linie); border-radius: 8px; }
.login-karte .fehler { color: var(--rot); min-height: 18px; margin-bottom: 6px; }
