:root {
  --bg: #f5f6f8; --flaeche: #ffffff; --flaeche2: #f0f2f5; --linie: #e1e4ea; --text: #1d232c; --leise: #677183;
  --akzent: #245e8f; --akzent-hell: #e6eff7;
  --rot: #b4232c; --rot-bg: #fdecec; --gelb: #8a5a00; --gelb-bg: #fff4dc; --gruen: #1f7a45; --gruen-bg: #e6f5ec;
  --blau: #2457a8; --blau-bg: #e8efff; --grau: #5c6370; --grau-bg: #eceef1;
  --radius: 8px; --schatten: 0 1px 2px rgba(20, 30, 50, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a; --flaeche: #1a1e25; --flaeche2: #222731; --linie: #2e3440; --text: #e3e7ee; --leise: #949dad;
    --akzent: #6ea8dc; --akzent-hell: #1d2c3c;
    --rot: #f08a8f; --rot-bg: #3a1d20; --gelb: #f0c46a; --gelb-bg: #3a2f17; --gruen: #6fd19a; --gruen-bg: #173323;
    --blau: #8fb1f2; --blau-bg: #1c2742; --grau: #a3aab6; --grau-bg: #262b34;
    --schatten: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; display: flex; gap: .5rem; align-items: center; }
main { max-width: 1400px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.leise { color: var(--leise); }
.klein { font-size: .88rem; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .9em; }
.rechts { margin-left: auto; text-align: right; }

/* Kopf */
.kopf { display: flex; align-items: center; gap: 1.5rem; padding: 0 16px; height: 52px; background: var(--flaeche); border-bottom: 1px solid var(--linie); position: sticky; top: 0; z-index: 5; }
.marke { display: flex; align-items: center; gap: .5rem; font-weight: 650; color: var(--text); }
.logo { width: 20px; height: 20px; border-radius: 5px; background: var(--akzent); display: inline-block; position: relative; }
.logo::after { content: ""; position: absolute; left: 5px; top: 4px; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg); }
.logo.gross { width: 28px; height: 28px; vertical-align: -4px; margin-right: .5rem; }
.logo.gross::after { left: 7px; top: 6px; width: 12px; height: 7px; }
.kopf nav { display: flex; gap: .2rem; overflow-x: auto; }
.kopf nav a { padding: .45rem .75rem; border-radius: 6px; color: var(--leise); white-space: nowrap; }
.kopf nav a:hover { background: var(--flaeche2); text-decoration: none; color: var(--text); }
.kopf nav a.aktiv { background: var(--akzent-hell); color: var(--akzent); font-weight: 600; }
.abmelden { margin-left: auto; }

/* Formulare */
input, select, button, .knopf { font: inherit; color: inherit; }
input, select { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: .4rem .55rem; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .88rem; color: var(--leise); margin-bottom: .6rem; }
label input, label select { color: var(--text); font-size: 1rem; }
button, .knopf { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: .4rem .8rem; cursor: pointer; display: inline-block; white-space: nowrap; }
button:hover, .knopf:hover { background: var(--flaeche2); text-decoration: none; }
button.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; font-weight: 600; }
button.primaer:hover { filter: brightness(1.08); }
button.link { background: none; border: 0; padding: 0; color: var(--akzent); }
button.link:hover { text-decoration: underline; }
button.link.rot { color: var(--rot); }
button:disabled { opacity: .5; cursor: default; }
.knopf.klein { padding: .15rem .5rem; font-size: .88rem; }
form.inline { display: inline; margin-left: .6rem; }
.zeile { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.zeile input { flex: 1 1 180px; }
.raster2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.raster3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .8rem; margin-top: .6rem; }
.raster-zuordnung { display: grid; grid-template-columns: 2fr 2fr 1fr 150px auto; gap: .8rem; align-items: end; }
.raster-zuordnung label { margin: 0; }
details summary { cursor: pointer; }
details.klein { margin: .3rem 0 .8rem; }

/* Layout */
.titelzeile { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.titelzeile p { margin: 0; }
.werkzeuge { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.werkzeuge input[type=search] { width: 200px; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--schatten); }
.karte.rand-rot { border-left: 4px solid var(--rot); }
.karte.rand-gruen { border-left: 4px solid var(--gruen); }
.zweispaltig { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.raster-karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 1rem; }
.scroll { max-height: 420px; overflow: auto; }

/* Meldungen */
.meldung { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; }
.meldung.ok { background: var(--gruen-bg); color: var(--gruen); }
.meldung.fehler { background: var(--rot-bg); color: var(--rot); }
.leer { padding: 2rem; text-align: center; color: var(--leise); }

/* Kennzahlen */
.kacheln { display: grid; grid-template-columns: repeat(6, 1fr); gap: .7rem; margin-bottom: .8rem; }
.kachel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: .75rem .9rem; display: flex; flex-direction: column; gap: .1rem; border-top: 3px solid var(--grau); color: var(--leise); font-size: .88rem; }
.kachel .zahl { text-align: left; font-size: 1.5rem; font-weight: 650; color: var(--text); }
.kachel.rot { border-top-color: var(--rot); }
.kachel.gelb { border-top-color: var(--gelb); }
.kachel.ok { border-top-color: var(--gruen); }
.kachel.potenzial { border-top-color: var(--akzent); }
.quellen { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quelle-chip { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 99px; padding: .2rem .7rem; font-size: .88rem; color: var(--leise); }
.quelle-chip b { color: var(--text); font-weight: 600; margin-right: .2rem; }
.quelle-chip.fehlt { border-style: dashed; }
.quelle-chip.warn { border-color: var(--gelb); }
.hinweisblock { background: var(--gelb-bg); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; }
.hinweisblock details + details { margin-top: .4rem; }
.hinweisblock table { margin-top: .5rem; background: transparent; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--leise); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; padding: .45rem .6rem; border-bottom: 1px solid var(--linie); white-space: nowrap; }
td { padding: .45rem .6rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.zahl { text-align: right; white-space: nowrap; }
td.minus { color: var(--rot); font-weight: 600; }
td.plus { color: var(--gelb); font-weight: 600; }
table.kompakt td, table.kompakt th { padding: .3rem .5rem; }
.kuerzen { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
pre { white-space: pre-wrap; font-size: .85rem; background: var(--flaeche2); padding: .5rem; border-radius: 6px; max-height: 240px; overflow: auto; }

.kunde { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); margin-bottom: .8rem; box-shadow: var(--schatten); overflow: hidden; }
.kunde > header { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; background: var(--flaeche2); border-bottom: 1px solid var(--linie); }
.kunde > header a { color: var(--text); }
.kunde > header .rechts { display: flex; gap: .6rem; align-items: center; }
.kunde table.abgleich th:nth-child(1) { width: 110px; }
.kunde table.abgleich th:nth-child(3), .kunde table.abgleich th:nth-child(4), .kunde table.abgleich th:nth-child(5), .kunde table.abgleich th:nth-child(6), .kunde table.abgleich th:nth-child(7) { width: 88px; }
.kunde table.abgleich th:nth-child(8) { width: 140px; }
.kunde table.abgleich { table-layout: fixed; }
.kunde table.abgleich th:nth-child(2) { width: 26%; }
.potenzial-text { font-weight: 600; color: var(--rot); }

/* Badges */
.pill { display: inline-block; padding: .08rem .55rem; border-radius: 99px; font-size: .82rem; font-weight: 600; white-space: nowrap; background: var(--grau-bg); color: var(--grau); }
.pill.ok { background: var(--gruen-bg); color: var(--gruen); }
.pill.rot { background: var(--rot-bg); color: var(--rot); }
.pill.gelb { background: var(--gelb-bg); color: var(--gelb); }
.pill.blau { background: var(--blau-bg); color: var(--blau); }
.badge.q { display: inline-block; font-size: .78rem; padding: .05rem .45rem; border-radius: 4px; background: var(--flaeche2); border: 1px solid var(--linie); color: var(--leise); white-space: nowrap; }
.tag { display: inline-block; font-size: .8rem; padding: .05rem .4rem; border-radius: 4px; background: var(--akzent-hell); color: var(--akzent); white-space: nowrap; }

table.zuordnung td:nth-child(3) { width: 48%; }

.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { display: flex; align-items: center; }
.login .karte { margin-top: 1.2rem; }
.login button { width: 100%; padding: .6rem; }

@media (max-width: 1100px) { .kacheln { grid-template-columns: repeat(3, 1fr); } .raster-zuordnung { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  .zweispaltig, .raster2, .raster3 { grid-template-columns: 1fr; }
  .kacheln { grid-template-columns: repeat(2, 1fr); }
  .kopf { gap: .6rem; } .abmelden { display: none; }
  .kunde { overflow-x: auto; }
  table.abgleich { min-width: 760px; }
}

/* Benutzer & Login */
.breit { width: 100%; text-align: center; padding: .6rem; }
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; font-weight: 600; }
.knopf.primaer:hover { filter: brightness(1.08); background: var(--akzent); }
.trenner { display: flex; align-items: center; gap: .6rem; color: var(--leise); font-size: .85rem; margin: 1rem 0; }
.trenner::before, .trenner::after { content: ""; flex: 1; border-top: 1px solid var(--linie); }
.abmelden { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.abmelden a { color: var(--text); padding: .3rem .5rem; border-radius: 6px; }
.abmelden a.aktiv, .abmelden a:hover { background: var(--flaeche2); text-decoration: none; }
tr.inaktiv td:not(:last-child) { opacity: .55; }
details.aktionen { position: relative; display: inline-block; }
details.aktionen summary { list-style: none; color: var(--akzent); }
details.aktionen summary::-webkit-details-marker { display: none; }
details.aktionen .popup { position: absolute; right: 0; top: 1.6rem; z-index: 3; width: 300px; text-align: left; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: .8rem; box-shadow: 0 6px 20px rgba(0,0,0,.12); display: flex; flex-direction: column; gap: .8rem; }
details.aktionen .popup form + form { border-top: 1px solid var(--linie); padding-top: .8rem; }
table.benutzer td { vertical-align: middle; }

td.soll { font-weight: 650; }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); margin: 0 0 .5rem; }
label.check input { width: auto; }
[hidden] { display: none !important; }

.version { margin-left: auto; font-size: .78rem; color: var(--leise); font-family: ui-monospace, "SF Mono", Consolas, monospace; white-space: nowrap; }
.version + .abmelden { margin-left: .8rem; }
.fuss { text-align: center; font-size: .78rem; color: var(--leise); padding: 1rem; }
@media (max-width: 800px) { .version { display: none; } }
.kunde .innen { padding: .4rem .9rem 0; margin: 0; }

.artikelname { min-height: 1.2em; color: var(--leise); }
.artikelname.ok { color: var(--gruen); }
.artikelname.warn { color: var(--rot); }

/* Datenstand / Rohdaten */
.reiter { display: flex; gap: .25rem; margin: 1rem 0 .5rem; border-bottom: 1px solid var(--linie, #ddd); flex-wrap: wrap; }
.reiter a { padding: .45rem .9rem; text-decoration: none; color: inherit; border-bottom: 2px solid transparent; }
.reiter a.aktiv { border-bottom-color: currentColor; font-weight: 600; }
pre.roh { max-height: 75vh; overflow: auto; font-size: .8rem; line-height: 1.35; white-space: pre; padding: .75rem; background: var(--grau-bg); border-radius: 6px; }
.umbrechen { word-break: break-all; }
form.vorschlag { display: block; margin: .15rem 0; }
td .rot, span.rot { color: var(--rot); }
