/* PrestaShop CRM – ruhiges Arbeitswerkzeug; einziges Signal ist das Lagergelb */
:root {
    --paper: #f3f5f2;
    --surface: #ffffff;
    --ink: #1f2d34;
    --muted: #5d6a70;
    --line: #d8ded9;
    --line-soft: #e8ece8;
    --slate: #22323a;
    --slate-2: #2c3f48;
    --signal: #e8b422;
    --signal-soft: #fbf1d3;
    --ok: #2f7a57;
    --ok-soft: #e2f1e8;
    --danger: #b8432f;
    --danger-soft: #f8e4df;
    --info: #2d6b9a;
    --info-soft: #e1ecf5;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- Grundgerüst ---------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--slate);
    color: #c9d3d6;
    padding: 1.25rem 0;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
}
.brand { color: #fff; font-weight: 600; font-size: 1.05rem; padding: 0 1.25rem 1.25rem; }
.brand small { display: block; color: #8fa0a6; font-weight: 400; font-size: .8rem; }
.nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav a {
    display: block; padding: .5rem 1.25rem; color: #c9d3d6;
    border-left: 3px solid transparent;
}
.nav a:hover { background: var(--slate-2); color: #fff; text-decoration: none; }
.nav a.active { border-left-color: var(--signal); color: #fff; background: var(--slate-2); }
.nav-admin { flex: none; border-top: 1px solid var(--slate-2); padding: .5rem 0; font-size: .92rem; }
.nav .count { float: right; background: var(--signal); color: var(--slate); border-radius: 9px; padding: 0 .45rem; font-size: .75rem; font-weight: 600; }
.sidebar .me { padding: 1rem 1.25rem 0; border-top: 1px solid var(--slate-2); font-size: .85rem; }
.sidebar .me button { background: none; border: 0; color: #8fa0a6; padding: 0; cursor: pointer; font: inherit; }
.sidebar .me button:hover { color: #fff; }

main { padding: 1.75rem 2.25rem 3rem; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.55rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: .2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .75rem; }

/* ---------- Flächen ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.panel.flush { padding: 0; }
.panel.flush > h2 { padding: 1rem 1.25rem 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
.grid > .panel { margin-bottom: 0; }
.stack > * + * { margin-top: 1.25rem; }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); margin-bottom: 1.25rem; }
.figures div { padding: .9rem 1.25rem; border-left: 1px solid var(--line-soft); }
.figures div:first-child { border-left: 0; }
.figures b { display: block; font-size: 1.45rem; font-weight: 600; }
.figures span { color: var(--muted); font-size: .88rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-weight: 600; font-size: .85rem; color: var(--muted); border-bottom-color: var(--line); white-space: nowrap; }
tbody tr:hover { background: #f8faf8; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.nowrap { white-space: nowrap; }
td .meta { color: var(--muted); font-size: .85rem; }
tr.row-off td { color: var(--muted); }
.panel.flush table th:first-child, .panel.flush table td:first-child { padding-left: 1.25rem; }
.panel.flush table th:last-child, .panel.flush table td:last-child { padding-right: 1.25rem; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; background: var(--line-soft); display: block; }
.empty { color: var(--muted); padding: 1.5rem 1.25rem; }

/* ---------- Lagerkarte (Bestandsanzeige) ---------- */
.gauge { display: inline-flex; align-items: center; gap: .5rem; }
.gauge-num { min-width: 2.5ch; text-align: right; font-weight: 600; }
.gauge-bar { position: relative; width: 56px; height: 6px; background: var(--line-soft); border-radius: 3px; overflow: visible; }
.gauge-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.gauge-min { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--ink); opacity: .45; }
.gauge-low .gauge-bar > span { background: var(--signal); }
.gauge-low .gauge-num { color: #8a6500; }
.gauge-empty .gauge-num { color: var(--danger); }
.stock-big { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.stock-big .gauge { transform: scale(1.6); transform-origin: left center; margin-right: 3.5rem; }

/* ---------- Badges & Status ---------- */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 3px; font-size: .8rem; background: var(--line-soft); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-wait { background: var(--signal-soft); color: #7a5900; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-err { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: transparent; border: 1px solid var(--line); }
.state { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.state i { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; }

/* ---------- Formulare ---------- */
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%; padding: .5rem .6rem; font: inherit; color: var(--ink);
    background: #fff; border: 1px solid var(--line); border-radius: 4px;
}
input:focus, select:focus, textarea:focus { border-color: var(--slate); outline: none; box-shadow: 0 0 0 3px rgba(232, 180, 34, .35); }
textarea { min-height: 6rem; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: 1rem; margin: 0; }
.check input { width: 1.05rem; height: 1.05rem; }
.field-error { display: block; color: var(--danger); font-size: .85rem; margin-top: .25rem; }
.has-error input, .has-error select { border-color: var(--danger); }
.hint { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; }
.form-actions { display: flex; gap: .5rem; margin-top: 1.25rem; align-items: center; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; }
.qty-input { width: 6rem !important; text-align: right; }

.btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .48rem .9rem; font: inherit; font-weight: 500; line-height: 1.2;
    border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink);
    cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--slate); text-decoration: none; }
.btn-primary { background: var(--slate); border-color: var(--slate); color: #fff; }
.btn-primary:hover { background: var(--slate-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { padding: .2rem .5rem; font-size: .85rem; }
.btn-link { background: none; border: 0; color: var(--info); padding: 0; cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

/* ---------- Meldungen ---------- */
.flash { padding: .7rem 1rem; border-radius: 4px; margin-bottom: 1rem; border-left: 4px solid var(--ok); background: var(--ok-soft); }
.flash-error { border-left-color: var(--danger); background: var(--danger-soft); }
.notice { padding: .7rem 1rem; border-radius: 4px; background: var(--signal-soft); margin-bottom: 1rem; }

/* ---------- Bilder ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.gallery figure { margin: 0; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #fff; }
.gallery figure.cover { border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery figcaption { padding: .35rem .5rem; font-size: .8rem; display: flex; justify-content: space-between; gap: .25rem; align-items: center; }

/* ---------- Pager ---------- */
.pager { display: flex; gap: .25rem; align-items: center; padding: .75rem 1.25rem; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: .9rem; }
.pager a, .pager span.current { padding: .15rem .55rem; border-radius: 3px; }
.pager span.current { background: var(--slate); color: #fff; }
.pager .total { margin-left: auto; }

/* ---------- Protokoll ---------- */
.log { font-size: .85rem; }
.log td { padding: .3rem .75rem; }
.log .lvl-error td { color: var(--danger); }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--slate); }
.login form { background: #fff; width: 100%; max-width: 360px; padding: 2rem; border-radius: 6px; border-top: 4px solid var(--signal); }
.login h1 { font-size: 1.3rem; margin: 0 0 1.25rem; }
.login .field { margin-bottom: 1rem; }

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: .5rem; overflow-x: auto; }
    .brand { padding: 0 .75rem; white-space: nowrap; }
    .brand small { display: none; }
    .nav { display: flex; flex: none; }
    .nav-admin { border-top: 0; padding: 0; border-left: 1px solid var(--slate-2); }
    .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: .5rem .75rem; white-space: nowrap; }
    .nav a.active { border-bottom-color: var(--signal); }
    .sidebar .me { border: 0; padding: 0 .75rem; white-space: nowrap; }
    .sidebar .me span { display: none; }
    main { padding: 1.25rem 1rem 2rem; }
    .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
    .figures { grid-template-columns: repeat(2, 1fr); }
    .figures div:nth-child(3) { border-left: 0; }
    .figures div:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
}

@media print {
    .sidebar, .no-print { display: none !important; }
    .shell { display: block; }
    body { background: #fff; }
}

/* Sammelaktion in der Bestellliste */
.bulk-bar { margin: 0; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); background: #f8faf8; border-radius: 6px 6px 0 0; }
.bulk-bar select { width: auto; }
.bulk-bar .meta { min-width: 12rem; }

/* HTML-Editor (Beschreibungen) */
.editor { border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.editor:focus-within { border-color: var(--slate); box-shadow: 0 0 0 3px rgba(232, 180, 34, .35); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .2rem; align-items: center; padding: .35rem; border-bottom: 1px solid var(--line-soft); background: #f8faf8; border-radius: 4px 4px 0 0; }
.editor-toolbar button { font: inherit; font-size: .85rem; padding: .25rem .5rem; border: 1px solid transparent; border-radius: 3px; background: none; color: var(--ink); cursor: pointer; min-width: 2rem; }
.editor-toolbar button:hover:not(:disabled) { border-color: var(--line); background: #fff; }
.editor-toolbar button[aria-pressed="true"] { background: var(--slate); color: #fff; }
.editor-toolbar button:disabled { opacity: .35; cursor: default; }
.editor-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 .25rem; }
.editor-area { padding: .6rem .8rem; outline: none; overflow-y: auto; max-height: 32rem; }
.editor textarea.editor-source { border: 0; border-radius: 0; min-height: 16rem; font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: .85rem; box-shadow: none; }
.editor-counter { padding: .25rem .2rem 0; color: var(--muted); font-size: .8rem; text-align: right; }
.editor-counter.over { color: var(--danger); font-weight: 600; }

/* Formatierter Text (Editor und Produktansicht) */
.richtext { max-width: 72ch; }
.richtext > :first-child { margin-top: 0; }
.richtext > :last-child { margin-bottom: 0; }
.richtext p { margin: 0 0 .7em; }
.richtext h1, .richtext h2 { font-size: 1.2rem; font-weight: 600; margin: 1.1em 0 .4em; }
.richtext h3, .richtext h4 { font-size: 1.02rem; font-weight: 600; margin: 1em 0 .3em; }
.richtext ul, .richtext ol { margin: 0 0 .7em; padding-left: 1.4em; }
.richtext li { margin-bottom: .2em; }
.richtext img { max-width: 100%; height: auto; }
.richtext table { width: auto; margin: 0 0 .7em; }
.richtext td, .richtext th { border: 1px solid var(--line-soft); padding: .3rem .5rem; }
.richtext-lead { padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line-soft); color: var(--muted); }

/* TinyMCE an das CRM anpassen */
.tox.tox-tinymce { border-color: var(--line); border-radius: 4px; }
.tox-tinymce:focus-within { border-color: var(--slate) !important; }
.has-error .tox.tox-tinymce { border-color: var(--danger); }
