/* Gadebusch Katalog-Hub — Admin-UI (dependency-frei) */
:root {
    --bg: #f4f4f2;
    --surface: #ffffff;
    --ink: #1c1c1e;
    --muted: #6e6e73;
    --line: #e3e3e0;
    --accent: #8a6d3b;          /* Gold-Ton */
    --accent-ink: #ffffff;
    --danger: #b3261e;
    --success: #1e7d3c;
    --info: #2d5d8f;
    --warn: #8a6207;
    --radius: 10px;
    --sidebar-w: 240px;
}
* { box-sizing: border-box; }
/* Das hidden-Attribut muss immer verstecken — auch wenn eine Klasse display setzt. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
small, .muted { color: var(--muted); }
code { background: #efefec; border-radius: 4px; padding: 1px 5px; font-size: .85em; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: #23211d; color: #d8d5cf;
    display: flex; flex-direction: column; padding: 1rem .75rem;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: #fff; padding: .25rem .5rem 1rem; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.brand-logo { height: 40px; width: auto; display: block; flex: 0 0 auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
    color: #d8d5cf; padding: .5rem .6rem; border-radius: 7px; font-size: .92rem;
    display: flex; align-items: center; gap: .6rem;
}
.sidebar nav a svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .8; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar nav a:hover svg { opacity: 1; }
.sidebar nav a.active { background: var(--accent); color: var(--accent-ink); }
.sidebar nav a.active svg { opacity: 1; }
.nav-sep {
    margin: .7rem .6rem .25rem; padding-top: .6rem; border-top: 1px solid rgba(255,255,255,.12);
    font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: #8f8b83;
}
.nav-badge {
    margin-left: auto; display: inline-grid; place-content: center; min-width: 19px; height: 19px;
    padding: 0 5px; font-size: .72rem; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px;
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.12); padding-top: .75rem; }
.user-info { font-size: .85rem; margin-bottom: .5rem; color: #fff; }
.main { flex: 1; padding: 1.5rem 2rem 3rem; max-width: 1400px; }

/* Cards, Tabellen */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.stat { position: relative; display: flex; flex-direction: column; gap: .15rem; }
.stat .num { font-size: 1.7rem; font-weight: 650; }
.stat-ic {
    position: absolute; top: 1rem; right: 1.05rem;
    width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-content: center;
    background: #f4efe7; color: var(--accent);
}
.stat-ic svg { width: 21px; height: 21px; }
.stat-ic-ok   { background: #e9f5ec; color: #2e7d46; }
.stat-ic-mute { background: #f0efec; color: #8a857c; }

/* Anfragen-Management: aufklappbare Karten (native details — ohne JS bedienbar) */
.inq-list { display: flex; flex-direction: column; gap: .6rem; }
.inq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.inq-item.is-new { border-left: 3px solid var(--accent); }
.inq-item > summary { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; cursor: pointer; list-style: none; }
.inq-item > summary::-webkit-details-marker { display: none; }
.inq-item > summary:hover { background: #faf9f7; }
.inq-sum-id { flex: none; }
.inq-sum-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.inq-sum-top { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inq-sum-preview { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inq-sum-meta { flex: none; display: flex; align-items: center; gap: .5rem; }
.inq-sum-date { font-size: .82rem; white-space: nowrap; }
.inq-chevron { color: var(--muted); transition: transform .18s; }
.inq-item[open] .inq-chevron { transform: rotate(180deg); }
.inq-body { padding: .4rem 1rem 1rem; border-top: 1px solid var(--line); background: #faf9f7; }
.inq-detail-grid { display: grid; grid-template-columns: minmax(0,3fr) minmax(260px,2fr); gap: 1.2rem; padding-top: .6rem; }
.inq-detail-grid h4 { margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.inq-msg { margin: 0 0 .8rem; white-space: pre-line; max-width: 70ch; }
.inq-detail-grid .btn { margin-right: .4rem; }
@media (max-width: 900px) {
    .inq-detail-grid { grid-template-columns: 1fr; }
    .inq-item > summary { flex-wrap: wrap; gap: .3rem .6rem; }
    .inq-sum-main { flex: 1 1 100%; order: 3; }
    .inq-sum-meta { margin-left: auto; }
}

/* Preislisten-Vorschau: Wirkungs-Leiste + Anomalie-Hervorhebung */
.impact { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; padding: .9rem 1.1rem; margin-bottom: 1rem; }
.impact-item { display: flex; flex-direction: column; gap: .1rem; }
.impact-item .lbl { font-size: .78rem; color: var(--muted); }
.impact-item .val { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.price-diff td.col-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-diff tr.is-anomaly { background: #fdf6e7; }
.price-diff tr.is-anomaly:hover { background: #fbf0d8; }
.price-diff tr.is-anomaly td { border-bottom-color: #ecdcae; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #faf9f7; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fbfaf8; }
.table-wrap { overflow-x: auto; }

/* Formulare */
form { margin: 0; }
label { display: block; font-size: .85rem; font-weight: 600; margin: .8rem 0 .25rem; }
/* Alle text-artigen Inputs (text/url/email/password/number/search/tel/date/… und
   ohne type = text) einheitlich gestalten; Checkbox/Radio/Buttons ausgenommen. */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not([type=hidden]),
select, textarea {
    width: 100%; max-width: 640px;
    padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 7px;
    font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, white); border-color: var(--accent); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 220px; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin: 1rem 0; }
legend { font-size: .85rem; font-weight: 600; padding: 0 .4rem; }

/* Buttons, Badges */
.btn {
    display: inline-block; padding: .48rem .95rem; border-radius: 7px;
    border: 1px solid transparent; background: var(--accent); color: var(--accent-ink);
    font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.25); }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.badge {
    display: inline-block; padding: .1rem .5rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: #ececea; color: var(--muted);
}
.badge-success { background: #e2f2e6; color: var(--success); }
.badge-warn { background: #fdf1dc; color: #8a6207; }
.badge-danger { background: #fbe4e2; color: var(--danger); }
.badge-info { background: #e2ecf6; color: var(--info); }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e9f6ec; border-color: #bfe3c8; color: var(--success); }
.flash-error { background: #fbecea; border-color: #efc4c0; color: var(--danger); }
.flash-info { background: #eaf1f8; border-color: #c3d6e8; color: var(--info); }
.flash-warn { background: #fdf6e7; border-color: #ecdcae; color: var(--warn); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #23211d; }
.login-card { background: var(--surface); border-radius: 14px; padding: 2rem 2.2rem; width: 380px; max-width: 92vw; }
.login-card h1 { font-size: 1.2rem; }
.login-logo { height: 92px; width: auto; display: block; margin: 0 auto 1.1rem; }

/* Utility */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters label { margin: 0 0 .25rem; }
.filters input, .filters select { max-width: 220px; }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 980px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .main { padding: 1rem; }
    .grid-2 { grid-template-columns: 1fr; }
}
.pagination { display: flex; gap: .35rem; margin: 1rem 0; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .gap { border: 0; background: none; padding: .3rem .2rem; color: var(--muted); }
.help { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.danger-zone { border-color: #efc4c0; }

/* ------------------------------------------------------------------ */
/* Produkt-Editor: zweispaltiges Layout (Hauptinhalt + klebrige Seitenleiste) */
/* ------------------------------------------------------------------ */
.product-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.pe-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.pe-side { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.pe-main .card, .pe-side .card { margin-bottom: 0; }
@media (max-width: 1080px) {
    .product-editor { grid-template-columns: 1fr; }
    .pe-side { position: static; }
}
/* Abschnitts-Überschrift innerhalb einer Karte */
.sec { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
       margin: 0 0 .8rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); font-weight: 700; }
/* Kompaktes Feld (label + control) */
.field { margin-bottom: .85rem; }
.field:last-child { margin-bottom: 0; }
.field > label { margin: 0 0 .3rem; display: block; font-size: .85rem; font-weight: 600; }
.field input, .field select, .field textarea { max-width: none; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 560px) { .fields-2 { grid-template-columns: 1fr; } }
/* Speichern-Kopf der Seitenleiste */
.save-card { display: flex; flex-direction: column; gap: .6rem; }
.save-card .btn-save { width: 100%; padding: .6rem; font-size: 1rem; }
/* Einstellungs-Zeilen (Checkbox rechts) */
.setting { display: flex; align-items: center; justify-content: space-between; gap: .75rem;
           padding: .55rem 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: none; }
.setting > span { font-weight: 600; font-size: .9rem; }
.setting input[type=checkbox] { width: 20px; height: 20px; flex: 0 0 auto; }
/* Geschäft-Auswahl als klickbare Zeilen */
.store-pick { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border: 1px solid var(--line);
              border-radius: 8px; margin-bottom: .5rem; cursor: pointer; }
.store-pick:last-child { margin-bottom: 0; }
.store-pick:hover { background: #fbfaf8; }
.store-pick input { width: 18px; height: 18px; }
/* ------------------------------------------------------------------ */
/* Attribut-Bereich — kompaktes Facetten-Grid (Redesign)              */
/* Gruppen = flache Sektionen (kein Box-in-Box); Facetten (Dropdowns/  */
/* Checkbox/kurze Felder) liegen nebeneinander im Auto-fill-Grid;      */
/* Beschreibungen (Textareas) bilden ein ruhiges 2-Spalten-Band.       */
/* overflow bewusst NICHT hidden — sonst würden die ss-Panels beschnitten */
/* ------------------------------------------------------------------ */
.attr-group { border: 0; border-radius: 0; margin: 0 0 1.4rem; padding: 0; }
.attr-group:last-child { margin-bottom: 0; }
.attr-group > summary {
    cursor: default; list-style: none;
    display: flex; align-items: center; gap: .4rem;
    margin: 0 0 .85rem; padding: 0 0 .45rem;
    font-size: .74rem; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted);
    background: none; border: 0; border-bottom: 1px solid var(--line);
}
.attr-group > summary::-webkit-details-marker { display: none; }
.attr-group > summary::before { content: none; }

.attr-body { display: flex; flex-direction: column; gap: 1.1rem; padding: 0; }
.attr-band-title { font-size: .7rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }

/* Facetten-Band: Dropdowns nebeneinander, reflowt nach verfügbarer Breite.
   215px min → i. d. R. 3 Spalten im Hauptbereich (dichter, „PIM-Grid"). */
.attr-facets { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: .7rem .8rem; align-items: start; }
/* Beschreibungs-Band: kompaktes 2-Spalten-Raster */
.attr-descs { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem .8rem; align-items: start; }

.attr-field { display: flex; flex-direction: column; min-width: 0; margin: 0; }
.attr-field > label { display: block; margin: 0 0 .28rem; font-size: .78rem; font-weight: 600; color: var(--ink); }
.attr-descs .attr-field > label { color: var(--muted); }
.attr-field input, .attr-field select, .attr-field textarea { max-width: none; width: 100%; }
.attr-field input[type=text], .attr-field input[type=number] { min-height: 34px; padding: .32rem .55rem; }
.attr-field .searchselect { width: 100%; }
.attr-field .help { margin-top: .3rem; }

/* Bool = Gold-Pill-Toggle (kompakt, inline, oben ausgerichtet) */
.attr-field.is-bool { align-self: start; }
.attr-field.is-bool > label.checkbox {
    display: inline-flex; align-items: center; gap: .5rem;
    min-height: 34px; margin: 0; padding: 0 .7rem;
    border: 1px solid var(--line); border-radius: 7px; background: #fff;
    font-size: .85rem; font-weight: 600; color: var(--ink);
    white-space: nowrap; cursor: pointer;
}
.attr-field.is-bool > label.checkbox:has(input:checked) { border-color: var(--accent); background: #fbf8f2; color: var(--accent); }
.attr-field.is-bool input[type=checkbox] { width: 17px; height: 17px; flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
/* Leer-Label in Label-Höhe: rückt die Checkbox-Box auf Control-Höhe der Nachbarfelder. */
.attr-bool-spacer { display: block; font-size: .78rem; line-height: 1.55; margin: 0 0 .28rem; }

/* Kompakte Textareas (überschreibt globales textarea min-height:110px) */
.attr-descs textarea { min-height: 64px; height: 64px; resize: vertical; padding: .45rem .6rem; line-height: 1.4; }

/* searchselect im Attributgitter: kleiner, Gold-getönte Chips */
.attr-field .ss-control { min-height: 34px; padding: .28rem .5rem; gap: .3rem; border-radius: 8px; }
.attr-field .ss-control:hover { border-color: #cfcabf; }
.attr-field .ss-caret { font-size: .72rem; }
.attr-field .ss-chip {
    background: color-mix(in srgb, var(--accent) 12%, #fff);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, #fff);
    color: #6f5628; font-weight: 500; font-size: .78rem;
    border-radius: 999px; padding: .08rem .2rem .08rem .5rem;
}
.attr-field .ss-chip button:hover { color: var(--danger); }

.opt-list { display: flex; flex-wrap: wrap; gap: .35rem .9rem; }
.opt-list .checkbox { min-height: 0; margin: 0; font-weight: 400; font-size: .85rem; }

@media (max-width: 700px) { .attr-facets { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
@media (max-width: 520px) {
    .attr-facets { grid-template-columns: 1fr; }
    .attr-descs  { grid-template-columns: 1fr; }
    .attr-descs textarea { height: 74px; }
    .attr-bool-spacer { display: none; }   /* einspaltig: kein Ausrichtungs-Platzhalter nötig */
}

/* ------------------------------------------------------------------ */
/* Durchsuchbares Custom-Dropdown (dependency-frei, progressive enhancement) */
/* ------------------------------------------------------------------ */
.searchselect { position: relative; }
/* visuell versteckt, aber im DOM & Formular aktiv (native Feld = Wahrheit) */
.ss-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; clip: rect(0 0 0 0); overflow: hidden; }
.ss-control {
    display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; width: 100%; min-height: 38px;
    text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 7px;
    padding: .35rem .6rem; font: inherit; color: var(--ink); cursor: pointer;
}
.ss-control .ss-caret { margin-left: auto; color: var(--muted); }
.ss-control.ss-placeholder { color: var(--muted); }
.searchselect.ss-open .ss-control { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 45%, white); }
.ss-panel {
    display: none; position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.13); overflow: hidden;
}
.searchselect.ss-open .ss-panel { display: block; }
.ss-search { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: .5rem .65rem; font: inherit; }
.ss-search:focus { outline: none; background: #fbfaf8; }
.ss-list { max-height: 240px; overflow-y: auto; }
.ss-opt { padding: .45rem .65rem; cursor: pointer; display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.ss-opt:hover, .ss-opt.ss-active { background: #f5f2ec; }
.ss-opt.ss-sel { font-weight: 600; }
.ss-opt.ss-sel::after { content: '✓'; margin-left: auto; color: var(--accent); }
.ss-empty { padding: .55rem .65rem; color: var(--muted); font-size: .9rem; }
.ss-chip { display: inline-flex; align-items: center; gap: .3rem; background: #efeae0; border: 1px solid var(--line); border-radius: 999px; padding: .12rem .2rem .12rem .55rem; font-size: .82rem; }
.ss-chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 .25rem; }
.ss-chip button:hover { color: var(--danger); }
/* ------------------------------------------------------------------ */
/* Medien-Manager: Dropzone, Hauptbild, sortierbare Galerie            */
/* ------------------------------------------------------------------ */
.media-manager { display: flex; flex-direction: column; }

/* Drag&Drop-Upload-Zone */
.dropzone {
    border: 2px dashed var(--line); border-radius: 12px; background: #faf9f7;
    padding: 1.6rem 1rem; text-align: center; cursor: pointer; color: var(--muted);
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: #fbf8f2; outline: none; }
.dropzone.dz-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--ink); }
.dropzone.dz-busy { pointer-events: none; opacity: .7; }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.dz-icon { font-size: 1.5rem; color: var(--accent); }
.dz-text { font-size: .95rem; color: var(--ink); }
.dz-progress { margin-top: .7rem; font-size: .85rem; font-weight: 600; color: var(--accent); }

.media-section { margin-top: 1.3rem; }
.media-section .sec { margin-bottom: .7rem; }

/* Karten-Raster */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.media-item { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.media-item.is-main { max-width: 240px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, #fff); }
.media-item .m-thumb { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; background: #faf9f7; display: block; }
.media-item .m-ph { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; background: #faf9f7; color: var(--muted); }
.media-item .m-body { padding: .5rem .6rem; display: flex; flex-direction: column; gap: .45rem; }
.media-item .m-meta { font-size: .74rem; color: var(--muted); }
.m-actions { display: flex; gap: .35rem; }
.m-actions form { margin: 0; }
.m-actions form:first-child { flex: 1; }
.m-actions .btn-sm { width: 100%; padding: .3rem .4rem; }

/* Sortierbare Galerie-Karten */
.is-draggable { cursor: grab; }
.is-draggable.dragging { opacity: .4; cursor: grabbing; }
.is-draggable .m-thumb { pointer-events: none; }   /* Bild fängt den Drag nicht ab */
.drag-handle {
    position: absolute; top: .35rem; left: .35rem; z-index: 2;
    background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 6px;
    padding: 0 .35rem; color: var(--muted); font-size: .9rem; line-height: 1.4; cursor: grab;
}

/* Selbstlöschender Speicher-Status */
.mm-status {
    position: sticky; bottom: 1rem; align-self: flex-start; margin-top: 1rem;
    padding: .4rem .85rem; border-radius: 999px; background: var(--ink); color: #fff;
    font-size: .82rem; font-weight: 600; opacity: 0; transform: translateY(6px);
    transition: opacity .2s, transform .2s; pointer-events: none;
}
.mm-status.show { opacity: 1; transform: translateY(0); }
.mm-status.is-ok { background: var(--success); }
.mm-status.is-err { background: var(--danger); }

.media-classic { margin-top: 1.4rem; }

/* ------------------------------------------------------------------ */
/* KI-Datenerfassung: Modal + Vorschau                                */
/* ------------------------------------------------------------------ */
.ai-modal[hidden] { display: none; }
.ai-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.ai-modal-backdrop { position: absolute; inset: 0; background: rgba(20,18,15,.55); backdrop-filter: blur(2px); }
.ai-modal-box {
    position: relative; z-index: 1; width: 720px; max-width: 100%; max-height: 88vh;
    background: var(--surface); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
    display: flex; flex-direction: column; overflow: hidden;
}
.ai-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.ai-modal-head h3 { margin: 0; font-size: 1.05rem; }
.ai-x { border: none; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); line-height: 1; padding: .2rem .4rem; border-radius: 6px; }
.ai-x:hover { background: #f0efec; color: var(--ink); }
.ai-modal-body { padding: 1.1rem 1.25rem; overflow-y: auto; }
.ai-modal-foot { display: flex; align-items: center; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: #faf9f7; }
.ai-foot-note { font-size: .78rem; color: var(--muted); }

.ai-loading { display: flex; align-items: center; gap: .7rem; color: var(--muted); padding: 1.5rem 0; }
.ai-spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: ai-spin .8s linear infinite; flex: 0 0 auto; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

.ai-comp { padding: .6rem .85rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid; }
.ai-comp-ok { background: #e9f6ec; border-color: #bfe3c8; color: var(--success); }
.ai-comp-warn { background: #fdf5e6; border-color: #ecd9ad; color: #8a6207; }

.ai-section { margin-bottom: 1.1rem; }
.ai-section h4 { margin: 0 0 .45rem; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.ai-kv { display: grid; grid-template-columns: 170px 1fr; gap: .3rem .8rem; }
.ai-k { font-weight: 600; font-size: .82rem; color: var(--ink); }
.ai-v { font-size: .88rem; color: var(--ink); word-break: break-word; }
.ai-v.ai-empty { color: var(--muted); }

.ai-imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.ai-imgpick { position: relative; display: block; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: #faf9f7; aspect-ratio: 1/1; }
.ai-imgpick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-imgpick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, #fff); }
.ai-imgcb { position: absolute; top: .3rem; left: .3rem; z-index: 2; width: 18px; height: 18px; accent-color: var(--accent); }
.ai-img-broken { display: none; }   /* nicht ladbare Kandidaten ausblenden */
/* Tatsächliche Bildauflösung (per JS eingeblendet) */
.ai-imgres { position: absolute; bottom: 0; left: 0; right: 0; z-index: 2;
    background: rgba(20,18,15,.68); color: #fff; font-size: .66rem; line-height: 1.35;
    text-align: center; padding: 1px 3px; pointer-events: none; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
    .ai-kv { grid-template-columns: 1fr; gap: .1rem .5rem; }
    .ai-k { margin-top: .5rem; }
}

/* ------------------------------------------------------------------ */
/* KI-Bildauswahl: sortierbare Auswahl (oben) + Kandidaten + Lightbox  */
/* ------------------------------------------------------------------ */
.imgpick { display: block; }

/* Auswahl-Bereich (ausgewählte Bilder, per Drag&Drop sortierbar) */
.imgpick-sel { border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
    border-radius: 10px; background: #fbf8f2; padding: .6rem .7rem; margin-bottom: .9rem; }
.imgpick-sel-head { display: flex; align-items: baseline; justify-content: space-between;
    gap: .6rem; margin-bottom: .5rem; flex-wrap: wrap; }
.imgpick-sel-title { font-size: .8rem; font-weight: 700; color: var(--ink); }
.imgpick-sel-title b { color: var(--accent); }
.imgpick-sel-hint { font-size: .72rem; color: var(--muted); }
.imgpick-sel-row { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 78px; align-items: center; }
.imgpick-empty { margin: 0; font-size: .8rem; color: var(--muted); }
.imgpick-chip { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden;
    border: 2px solid var(--accent); background: #fff; cursor: grab; box-shadow: 0 1px 3px rgba(20,18,15,.12); }
.imgpick-chip.dragging { opacity: .45; cursor: grabbing; }
.imgpick-chip.drop-target { outline: 2px dashed var(--accent); outline-offset: 1px; }
.imgpick-chip img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.imgpick-ord { position: absolute; top: .2rem; left: .2rem; z-index: 2; min-width: 17px; height: 17px;
    padding: 0 3px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .68rem;
    font-weight: 700; line-height: 17px; text-align: center; }
.imgpick-chip .imgpick-main { position: absolute; bottom: 0; left: 0; right: 0; z-index: 2; text-align: center;
    background: var(--accent); color: #fff; font-size: .6rem; font-weight: 700; letter-spacing: .03em;
    text-transform: uppercase; line-height: 1.5; }
.imgpick-rm { position: absolute; top: .15rem; right: .15rem; z-index: 3; width: 18px; height: 18px;
    border: none; border-radius: 999px; background: rgba(20,18,15,.72); color: #fff; font-size: .7rem;
    line-height: 1; cursor: pointer; padding: 0; }
.imgpick-rm:hover { background: var(--danger); }

/* Kandidaten-Kopf mit Größensortierung */
.imgpick-cand-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    margin: 0 0 .5rem; flex-wrap: wrap; }
.imgpick-cand-title { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 700; }
.imgpick-sort { font-size: .76rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.imgpick-sort select { font-size: .78rem; padding: .2rem 1.5rem .2rem .45rem; }

/* Kandidaten-Raster */
.imgpick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.imgpick-tile { position: relative; border: 2px solid var(--line); border-radius: 8px; overflow: hidden;
    cursor: pointer; background: #faf9f7; aspect-ratio: 1/1; }
.imgpick-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgpick-tile.is-sel { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, #fff); }
.imgpick-tile.ai-img-broken { display: none; }
.imgpick-check { position: absolute; top: .3rem; left: .3rem; z-index: 2; width: 20px; height: 20px;
    border-radius: 999px; background: var(--accent); color: #fff; font-size: .8rem; line-height: 20px;
    text-align: center; opacity: 0; transform: scale(.55); transition: opacity .12s, transform .12s; }
.imgpick-tile.is-sel .imgpick-check { opacity: 1; transform: none; }
.imgpick-zoom { position: absolute; bottom: .3rem; right: .3rem; z-index: 3; width: 22px; height: 22px;
    border: none; border-radius: 6px; background: rgba(20,18,15,.66); color: #fff; font-size: .82rem;
    line-height: 1; cursor: pointer; padding: 0; opacity: .85; }
.imgpick-zoom:hover { opacity: 1; background: rgba(20,18,15,.88); }
.imgpick-chip .imgpick-zoom { bottom: .15rem; right: .15rem; width: 18px; height: 18px; font-size: .66rem; }

/* Lightbox */
.imgpick-lightbox[hidden] { display: none; }
.imgpick-lightbox { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center;
    justify-content: center; padding: 2.4rem; background: rgba(20,18,15,.84); backdrop-filter: blur(3px); }
.imgpick-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px;
    background: #fff; box-shadow: 0 12px 44px rgba(0,0,0,.5); }
.imgpick-lightbox-x { position: absolute; top: 1rem; right: 1.1rem; width: 40px; height: 40px; border: none;
    border-radius: 999px; background: rgba(255,255,255,.15); color: #fff; font-size: 1.2rem; cursor: pointer; }
.imgpick-lightbox-x:hover { background: rgba(255,255,255,.3); }
.imgpick-lightbox-cap { position: absolute; bottom: 1rem; left: 0; right: 0; text-align: center;
    color: rgba(255,255,255,.78); font-size: .78rem; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
    .imgpick-chip { width: 72px; height: 72px; }
}

/* Curl-Rohdaten-Vorschau */
.curl-badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.curl-sec { margin-top: .7rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.curl-sec > summary { cursor: pointer; padding: .5rem .7rem; font-weight: 600; font-size: .82rem; background: #faf9f7; }
.curl-pre { margin: 0; padding: .6rem .7rem; max-height: 320px; overflow: auto; background: #fff;
    border-top: 1px solid var(--line); font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: .76rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* Preisspalte: nie umbrechen (Betrag + Währungssymbol zusammenhalten) */
.col-price { white-space: nowrap; text-align: right; min-width: 116px; }

/* Datenprüfung: klickbare Kennzahlen-Karten */
.comp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1.1rem; }
.comp-card { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .85rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    color: var(--ink); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
.comp-card:hover { text-decoration: none; border-color: var(--accent); }
.comp-card .num { font-size: 1.35rem; font-weight: 650; }
.comp-card .lbl { font-size: .74rem; color: var(--muted); line-height: 1.3; }
.comp-card.is-active { border-color: var(--accent); background: #fbf8f2; box-shadow: 0 0 0 1px var(--accent); }
.comp-card.is-empty .num { color: var(--success); }
.comp-card.is-empty { opacity: .65; }

/* Massenauswahl in der Produktliste */
.col-check { width: 34px; text-align: center; }
.col-check input { width: 17px; height: 17px; cursor: pointer; }
.bulk-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .55rem .85rem; margin-bottom: .8rem; border-radius: 10px;
    background: #fbf8f2; border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line)); }
.bulk-count { font-size: .9rem; }
.bulk-actions select { max-width: 220px; }

/* Live-URLs in der Produktbearbeitung */
.live-url { display: inline-block; font-size: .82rem; word-break: break-all; line-height: 1.3; }

/* KI-Massenimport: Fortschritt + Prüfliste */
.bulk-bar { height: 8px; background: #eceae6; border-radius: 999px; overflow: hidden; margin-top: .45rem; }
.bulk-bar span { display: block; height: 100%; background: var(--accent); transition: width .35s ease; }
.bulk-list { display: flex; flex-direction: column; gap: .7rem; margin: 1rem 0; }
.bulk-item { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; background: #fff; }
.bulk-item-head { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.bulk-keep { margin: 0; }
.bulk-keep input { width: 18px; height: 18px; }
.bulk-item-body { margin-top: .6rem; padding-left: .2rem; }
.bulk-item-body .ai-imggrid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); }

/* ------------------------------------------------------------------ */
/* Visueller Bild-Downloader (KI-Import: Modal, Prüfansicht, Produkt)  */
/* ------------------------------------------------------------------ */
.imgdl { display: block; }
.imgdl-head { display: flex; align-items: center; gap: .8rem; }
.imgdl-head-main { flex: 1; min-width: 0; }
.imgdl-list { display: flex; flex-direction: column; gap: .25rem; margin-top: .7rem;
    max-height: 280px; overflow-y: auto; }
.imgdl-row { display: flex; align-items: center; gap: .6rem; padding: .3rem .45rem;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: .8rem; }
.imgdl-row[data-status="failed"] { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: #fdf6f5; }
.imgdl-row[data-status="processing"], .imgdl-row[data-status="pending"] { opacity: .75; }
.imgdl-thumb { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 6px; overflow: hidden;
    background: #eceae6; display: flex; align-items: center; justify-content: center; }
.imgdl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgdl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--ink); }
.imgdl-state { display: inline-flex; align-items: center; gap: .35rem; flex: 0 0 auto;
    color: var(--muted); font-variant-numeric: tabular-nums; }
.imgdl-ok { color: var(--success); font-weight: 600; }
.imgdl-err { color: var(--danger); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imgdl-foot { display: flex; align-items: center; gap: .7rem; margin-top: .7rem; flex-wrap: wrap; font-size: .85rem; }

/* Kennzeichnung laut Marken-Vorgabe umgeformter Bild-URLs im Picker */
.imgpick-tr { position: absolute; top: .2rem; right: .2rem; z-index: 2; background: rgba(20,18,15,.72);
    color: #fff; font-size: .6rem; line-height: 1.4; padding: 1px 5px; border-radius: 999px; pointer-events: none; }

/* Unvollständigkeits-Hinweis je Massenimport-Eintrag (was fehlt konkret) */
.ai-missing { margin: .1rem 0 .5rem; padding: .35rem .55rem; border-radius: 8px;
    background: #fdf1dc; color: #8a6207; font-size: .8rem; line-height: 1.45; }

/* Geschäftsauswahl in Aktionsleisten (Massenimport-Freigabe, Produktliste) */
.store-picks { display: inline-flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.store-picks .checkbox { margin: 0; font-size: .85rem; white-space: nowrap; }

/* KI-Import: Suchen&Ersetzen-Regeln (Marken-Formular) */
.repl-rules { margin-top: .4rem; }
.repl-head, .repl-row { display: grid; grid-template-columns: 1fr 1fr 54px 36px; gap: .5rem; align-items: center; }
.repl-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
    font-weight: 700; margin-bottom: .3rem; padding: 0 .1rem; }
.repl-head span:nth-child(3), .repl-head span:nth-child(4) { text-align: center; }
.repl-row { margin-bottom: .45rem; }
.repl-row input[type=text] { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.repl-regex { justify-content: center; margin: 0; }
.repl-regex input { width: 17px; height: 17px; }
.repl-row [data-repl-remove] { padding: .3rem; line-height: 1; }
@media (max-width: 640px) {
    .repl-head { display: none; }
    .repl-row { grid-template-columns: 1fr 1fr auto auto; }
}

/* Massenimport: Attribut-Editor je Eintrag (fehlende Attribute ergänzen) */
.bulk-attrs { margin-top: .7rem; margin-bottom: 1rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.bulk-attrs > summary { cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--ink);
    display: flex; align-items: center; gap: .5rem; list-style: none; }
.bulk-attrs > summary::-webkit-details-marker { display: none; }
.bulk-attrs > summary::before { content: '▸'; color: var(--muted); font-size: .75rem; }
.bulk-attrs[open] > summary::before { content: '▾'; }
.bulk-attrs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .55rem .7rem; margin-top: .6rem; align-items: start; }
.bulk-attr { display: flex; flex-direction: column; min-width: 0; }
.bulk-attr.is-wide { grid-column: 1 / -1; }
.bulk-attr > label { font-size: .76rem; font-weight: 600; color: var(--ink); margin-bottom: .22rem; }
.bulk-attr.is-missing > label { color: #8a6207; }
.bulk-attr.is-missing select, .bulk-attr.is-missing input[type=text] { border-color: #e6c98a; background: #fffdf6; }
.bulk-attr-flag { color: var(--accent); font-size: .6rem; vertical-align: middle; }
.bulk-attr select, .bulk-attr input[type=text] { width: 100%; font-size: .82rem; padding: .3rem .45rem; }
.bulk-attr-checks { display: flex; flex-wrap: wrap; gap: .3rem .8rem; }
.bulk-attr-checks .checkbox { margin: 0; font-size: .82rem; }

/* API-Key anzeigen/kopieren (Geschäfte-Seite) */
.key-reveal { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.key-reveal .key-input { width: auto; min-width: 260px; max-width: 420px; flex: 1 1 260px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; padding: .32rem .5rem; }
.key-reveal .btn-sm { flex: 0 0 auto; }
.key-reveal [data-key-toggle].is-on { border-color: var(--accent); color: var(--accent); }
.key-reveal [data-key-copy].is-done { color: var(--success); border-color: var(--success); }
