:root {
  --bg: #f4f6f8; --card: #ffffff; --ink: #1c2733; --muted: #64748b;
  --accent: #0b5fff; --danger: #d92d20; --ok: #12805c; --border: #e2e8f0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--ink); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.warn { color: #92400e; }
.ok { color: var(--ok); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 1.3rem; letter-spacing: .08em; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
        padding: 20px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .85rem; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--border);
        border-radius: 8px; }
.btn { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px;
       border: 1px solid var(--border); background: #fff; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
a.btn { display: inline-block; text-decoration: none; }
.btn.danger { color: var(--danger); }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px;
          background: var(--card); border-bottom: 1px solid var(--border); }
.topbar strong { letter-spacing: .06em; }
.topbar span { flex: 1; }

.layout { display: flex; min-height: calc(100vh - 53px); }
.sidenav { width: 210px; padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; }
.sidenav a { padding: 10px 14px; border-radius: 8px; color: var(--ink);
             text-decoration: none; font-weight: 600; }
.sidenav a.active, .sidenav a:hover { background: #e3ecff; color: var(--accent); }
.content { flex: 1; padding: 24px; max-width: 1200px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
             gap: 14px; margin-bottom: 20px; }
.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 800; }

table { width: 100%; border-collapse: collapse; background: var(--card);
        border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
         vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem;
         font-weight: 700; background: #eef2f7; }
.badge.ok { background: #d9f2e5; color: var(--ok); }
.badge.warn { background: #fff2d9; color: #92400e; }
.badge.err { background: #fde2df; color: var(--danger); }

.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
             gap: 12px; }
h2 { margin-top: 0; }

/* Freigabe: Kacheln und Bildpaare */
.freigabe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
                 gap: 14px; }
.kachel { display: flex; flex-direction: column; gap: 10px; padding: 12px; color: inherit;
          text-decoration: none; transition: box-shadow .15s, transform .15s; }
.kachel:hover { box-shadow: 0 6px 20px rgba(28, 39, 51, .12); transform: translateY(-2px); }
.kachel-bild { aspect-ratio: 4 / 3; background: #eef2f7; border-radius: 8px; overflow: hidden;
               display: flex; align-items: center; justify-content: center; }
.kachel-bild img { width: 100%; height: 100%; object-fit: contain; }
.kachel-text { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }

.freigabe-kopf { display: flex; justify-content: space-between; align-items: start; gap: 16px;
                 flex-wrap: wrap; margin-bottom: 16px; }
.freigabe-kopf h2 { margin-bottom: 4px; }
.pruefliste { margin-bottom: 20px; }
.pruefliste p { margin: 8px 0 0; }
.pruefliste ul { margin: 4px 0 0; padding-left: 20px; }

.bildpaar { margin-bottom: 14px; padding: 14px; }
.bildpaar header { margin-bottom: 10px; }
.bildpaar-spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
                    gap: 14px; }
.bild-figur { position: relative; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.bild-figur img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #eef2f7;
                  border-radius: 8px; border: 1px solid var(--border); }
.bild-figur figcaption { display: flex; justify-content: space-between; font-size: .85rem;
                         font-weight: 600; }
.bild-leer { min-height: 180px; align-items: center; justify-content: center;
             border: 1px dashed var(--border); border-radius: 8px; }
.bild-aktionen { display: flex; gap: 6px; flex-wrap: wrap; }
.hauptbild-marke { position: absolute; top: 8px; left: 8px; z-index: 1; padding: 2px 10px;
                   border-radius: 999px; background: var(--accent); color: #fff;
                   font-size: .75rem; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidenav { width: 100%; flex-direction: row; overflow-x: auto; }
  .content { padding: 14px; }
}

/* Artikel bearbeiten */
.artikel-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.artikel-form h3, .card h3 { margin: 0 0 12px; }
.form-grid .breit, .artikel-form label.breit { grid-column: 1 / -1; }
label > span:first-child { display: flex; gap: 6px; align-items: center; }
.quelle { font-size: .7rem; font-weight: 700; padding: 0 6px; border-radius: 999px;
          background: #e3ecff; color: var(--accent); }
textarea { resize: vertical; }
.merkmale { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.merkmal-zeile { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
                 gap: 8px; width: 100%; }
.merkmal-zeile input, .form-grid input, .form-grid select, .form-grid textarea { min-width: 0; width: 100%; }
@media (max-width: 760px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
}
.speicherleiste { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px 0 0; }
/* Nur beim langen Artikelformular bleibt „Speichern“ unten im Blick. */
.artikel-form > .speicherleiste { position: sticky; bottom: 0; z-index: 2; padding: 12px 0;
                                  background: var(--bg); }
.fragen { margin-bottom: 14px; border-color: #f5c46a; background: #fffaf0; }
.frage { padding: 10px 0; border-top: 1px solid var(--border); }
.frage:first-of-type { border-top: none; }
.frage p { margin: 0 0 8px; }
.kandidaten { display: flex; gap: 8px; flex-wrap: wrap; }
.marktpreis { margin: 12px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card + .card, section.card { margin-bottom: 14px; }

/* KI-Kosten: Anteile je Zweck als schlichte Balken */
td.zahl, th.zahl { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ki-anteile { width: 100%; }
.ki-anteile td { padding: 6px 8px; }
.ki-balken { width: 45%; }
.ki-balken span { display: block; height: 10px; border-radius: 4px; background: #2a78d6; min-width: 2px; }
@media (max-width: 640px) { .ki-balken, .ki-laeufe { display: none; } }

/* „Angemeldet bleiben“ auf der Anmeldeseite */
.login-card label.merken { display: flex; flex-direction: row; align-items: center; gap: 8px;
  font-weight: 500; cursor: pointer; }
.login-card label.merken input { width: auto; margin: 0; }

/* Offene Aufgaben */
.aufgaben-liste { margin: 0; padding-left: 1.1em; }
.aufgaben-liste li { margin: 2px 0; }
#nav a .badge { margin-left: 4px; font-size: 11px; padding: 0 6px; vertical-align: 1px; }
#nav a[href="#aufgaben"] { white-space: nowrap; }

/* Bestand korrigieren und Artikel löschen */
form.korrektur { background: #f6f8fb; border: 1px solid var(--border, #e2e5ea); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card.gefahr { border-color: #f1c4c4; }
.card.gefahr h3 { color: var(--danger); }

/* Vertriebskanäle und Kleinanzeigen-Assistent */
.kanal-liste { list-style: none; margin: 10px 0 14px; padding: 0; display: grid; gap: 8px; }
.kanal-liste li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.kanal-liste label { display: inline-flex; flex-direction: row; align-items: center; gap: 8px;
                     cursor: pointer; font-size: 1rem; font-weight: 400; }
.kanal-liste label .muted { font-size: .85rem; }
.kanal-liste input[type=checkbox] { width: 18px; height: 18px; padding: 0; margin: 0; }
#kleinanzeigen-assistent .toolbar #ka-url { flex: 1 1 320px; min-width: 0; }
.ka-schritte { margin: 10px 0; padding-left: 1.3em; }
.ka-schritte li { margin: 6px 0; }
.ka-felder { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: end; margin: 14px 0; }
.ka-felder label { display: grid; gap: 4px; }
.ka-felder input, .ka-felder textarea { width: 100%; }
.ka-bilder { display: flex; flex-wrap: wrap; gap: 10px; }
.ka-bilder a { display: grid; gap: 4px; width: 110px; font-size: .85rem; text-decoration: none; }
.ka-bilder img { width: 110px; height: 110px; object-fit: contain; background: #f3f4f3; border-radius: 6px; }
@media (max-width: 640px) { .ka-felder { grid-template-columns: 1fr; } }

/* Preise je Kanal */
.kanal-preis { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 8px; }
.preis-feld { width: 7em; padding: 4px 8px; }
td.preis-regel { white-space: nowrap; }
td.preis-regel label, label.haken { display: inline-flex; flex-direction: row; align-items: center; gap: 4px; }
td.preis-regel .preis-feld { width: 4.5em; }
label.haken input { width: auto; }
.form-grid label.haken { align-self: end; padding-bottom: 12px; }
.knopf-spalte { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 150px; }
.muted.klein { font-size: 0.85em; }

/* Wareneingang */
.we-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.we-drop { flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; padding: 18px;
  border: 2px dashed #c9d2de; border-radius: 12px; cursor: pointer; }
.we-drop.ueber { border-color: #2563eb; background: #eff6ff; }
.we-drop input[type=file] { display: none; }
.we-raster { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin: 16px 0; }
@media (max-width: 1100px) { .we-raster { grid-template-columns: 1fr; } }
.we-anzeige iframe { width: 100%; height: 70vh; border: 0; }
.we-anzeige img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.we-kopf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.we-hinweise { border-left: 4px solid #f59e0b; }
.we-positionen td { vertical-align: top; }
.we-positionen input.breit { width: 100%; min-width: 14em; }
.we-positionen input.schmal { width: 11em; font-size: .85em; }
.we-positionen input.zahl { width: 6em; }
.we-nummern { display: flex; gap: 6px; margin-top: 4px; }
.we-handschrift { margin-top: 4px; color: #1d4ed8; font-style: italic; }
.we-defekt { margin-top: 4px; }
.we-defekt input.zahl { width: 4em; }
.we-ignoriert td { opacity: .55; }
.we-artikel { margin-top: 4px; }
.we-suche { position: relative; margin-top: 4px; }
.we-treffer { position: absolute; z-index: 5; left: 0; right: 0; list-style: none; margin: 2px 0 0; padding: 4px;
  background: #fff; border: 1px solid #c9d2de; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.we-treffer button { width: 100%; text-align: left; background: none; border: 0; padding: 6px; cursor: pointer; }
.we-treffer button:hover { background: #eff6ff; }

/* Werbebilder (Freigabe) */
.werbe-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 10px 0; }
.werbe-form label { display: flex; flex-direction: column; gap: 4px; }
.werbe-form label.breit { flex: 1 1 320px; }
.werbe-galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 10px; }
.werbe-figur img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.werbe-kanaele { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.werbe-quellen { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.werbe-quellen legend { font-weight: 600; margin-bottom: 4px; }
.werbe-quelle { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px;
  border: 2px solid transparent; border-radius: 8px; cursor: pointer; }
.werbe-quelle input { position: absolute; opacity: 0; }
.werbe-quelle img { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 6px; }
.werbe-quelle:has(input:checked) { border-color: var(--primary, #0b5cff); background: rgba(11, 92, 255, .06); }
.werbe-aus { display: flex; align-items: center; gap: 6px; font-size: .85em; color: var(--muted, #667); margin-top: 4px; }
.werbe-aus img { width: 28px; height: 28px; object-fit: contain; background: #fff; border-radius: 4px; }
.werbe-figur figcaption { flex-direction: column; align-items: flex-start; gap: 2px; }

/* Benutzer: Rechte */
.rechte-zelle { display: flex; flex-direction: column; gap: 2px; min-width: 260px; }
.rechte-zelle .recht { font-size: .9em; }
.rechte-wahl { display: flex; flex-wrap: wrap; gap: 6px 16px; border: 1px solid var(--border, #ddd); border-radius: 8px; }

/* Inventur */
.inv-info ul { margin: 6px 0 0 18px; }
.inv-fortschritt { height: 10px; background: var(--border, #e5e7eb); border-radius: 6px; overflow: hidden; }
.inv-fortschritt div { height: 100%; background: var(--ok, #16a34a); }
.inv-zaehlen { display: flex; gap: 4px; margin-top: 4px; }
.inv-zaehlen input { width: 5em; }
.inv-protokoll td { background: var(--bg-soft, #f8fafc); }
.inv-fehlend { columns: 2; font-size: .9em; }
.nur-druck { display: none; }
.inv-unterschrift div { margin-top: 28px; }
@media print {
  .sidenav, header, .kein-druck, .inv-zaehlen, .inv-protokoll { display: none !important; }
  .nur-druck { display: block; }
  .content { padding: 0; }
}
#inv-leer-blatt { display: none; }
.inv-unsicher td { background: #fffbeb; }
@media print {
  body.druck-leer #main > :not(#inv-leer-blatt) { display: none !important; }
  body.druck-leer #inv-leer-blatt { display: block; }
  @page { size: A4; margin: 12mm; }
  .inv-leer-tabelle { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .inv-leer-tabelle th, .inv-leer-tabelle td { border: 1px solid #000; padding: 1mm 2mm; height: 9mm; text-align: left; }
  .inv-leer-tabelle thead { display: table-header-group; }
  .inv-leer-tabelle tr { break-inside: avoid; }
  .inv-leer-tabelle .sku { font-family: monospace; white-space: nowrap; }
  .inv-leer-tabelle .feld { width: 22mm; }
}

/* Auswertung */
.aw-zeitraum label { flex-direction: row; align-items: center; gap: 6px; }
.aw-zeitraum input[type=date] { padding: 4px 8px; }
.aw-kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.aw-kachel { padding: 14px 16px; }
.aw-wert { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.aw-delta { display: block; margin-top: 4px; font-size: .8rem; color: var(--muted); }
.aw-delta.ok { color: var(--ok); }
.aw-delta.error { color: var(--danger); }
.aw-hinweise { margin-bottom: 16px; border-color: #f5d48a; background: #fffaf0; }
.aw-hinweise ul { margin: 6px 0 0; padding-left: 20px; }
.aw-ki { margin-bottom: 16px; }
.aw-ki-kopf { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.aw-ki-kopf .muted { flex: 1 1 260px; }
.aw-ki-ergebnis { white-space: pre-wrap; margin-top: 12px; line-height: 1.6; }
.aw-diagramm { margin-bottom: 16px; }
.aw-legende { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 8px; }
.aw-legende span, .aw-tipp div { display: inline-flex; align-items: center; gap: 6px; }
.aw-legende i, .aw-tipp i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.aw-flaeche { position: relative; }
.aw-flaeche svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
@media (max-width: 700px) { .aw-flaeche { overflow-x: auto; } .aw-flaeche svg { min-width: 640px; } }
.aw-raster { stroke: #eef2f6; stroke-width: 1; }
.aw-null { stroke: #94a3b8; stroke-width: 1; }
.aw-achse { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.aw-zeigerlinie { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 3 3; }
.aw-tipp { position: absolute; top: 4px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--border);
           border-radius: 8px; padding: 8px 10px; font-size: .82rem; pointer-events: none; box-shadow: 0 4px 14px rgba(15, 23, 42, .12);
           display: flex; flex-direction: column; gap: 2px; min-width: 170px; }
.aw-tipp div { display: flex; }
.aw-tipp b { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.aw-tabellen { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 600px), 1fr)); gap: 16px; margin-bottom: 16px; }
.aw-anteil { display: inline-block; width: 48px; height: 6px; background: #eef2f6; border-radius: 3px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.aw-anteil span { display: block; height: 100%; background: #2563eb; border-radius: 3px; }
