:root {
  --ink: #16110d;
  --ink-2: #2a211a;
  --gold: #b88a4a;
  --gold-soft: #f3e6d0;
  --bg: #f7f3ec;
  --card: #ffffff;
  --line: #e7dfd2;
  --text: #221a14;
  --muted: #7a6d60;
  --ok: #2f7a4b;
  --warn: #b26a00;
  --bad: #b3261e;
  --radius: 12px;
}
* { box-sizing: border-box; }
img { max-width: 100%; height: auto; }
body { margin: 0; font: 15px/1.5 Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.serif { font-family: "Cormorant Garamond", Georgia, serif; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #eadfcd; padding: 24px 16px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: "Cormorant Garamond", Georgia, serif; font-size: 24px; letter-spacing: .06em; color: #fff; padding: 0 12px 20px; }
.brand small { display: block; font-family: Inter, sans-serif; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: #d8cbb6; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--gold); color: var(--ink); font-weight: 600; }
.side .foot { margin-top: auto; padding: 12px; font-size: 13px; color: #a8998a; }
.side .foot form { margin-top: 8px; }
.side .foot button { background: none; border: 1px solid #4a3d31; color: #eadfcd; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.main { padding: 32px clamp(16px, 4vw, 48px); min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head h1 { font-size: 26px; }
.head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Bausteine ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stat .label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 600; margin-top: 6px; }
.stat .hint { font-size: 13px; color: var(--muted); }
.cols { display: grid; gap: 16px; grid-template-columns: 2fr 1fr; margin-top: 16px; }
.card h2 { font-size: 16px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--gold-soft); color: #6b4a1c; }
.badge.ok { background: #e3f1e8; color: var(--ok); }
.badge.warn { background: #fbecd6; color: var(--warn); }
.badge.bad { background: #f8e1df; color: var(--bad); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { background: #000; }
.btn.gold { background: var(--gold); color: var(--ink); }

/* ---------- Anmeldung ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 70% 30%, #3b2717, var(--ink) 70%); }
.login-box { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; padding: 36px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-box .brand { color: var(--ink); padding: 0 0 8px; font-size: 30px; }
.login-box p.sub { margin: 0 0 24px; color: var(--muted); }
label { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.login-box .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 12px; }
.alert { padding: 10px 12px; border-radius: 8px; background: #f8e1df; color: var(--bad); font-size: 14px; }
.back-link { display: block; text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .brand { padding: 0 8px 0 0; font-size: 20px; }
  .brand small { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 10px; font-size: 14px; }
  .side .foot { margin: 0 0 0 auto; padding: 0; display: flex; gap: 8px; align-items: center; }
  .side .foot form { margin: 0; }
  .cols { grid-template-columns: 1fr; }
}

/* ---------- Meldungen ---------- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: #e3f1e8; color: var(--ok); border: 1px solid #c6e3d0; }
.flash.bad { background: #f8e1df; color: var(--bad); border-color: #efc4c0; }

/* ---------- Formulare ---------- */
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.crumb { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.crumb:hover { color: var(--text); }
.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.form-grid aside { display: grid; gap: 16px; }
.form-grid label:first-of-type { margin-top: 0; }
textarea { resize: vertical; }
.prefix { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.prefix span { padding: 11px 0 11px 12px; color: var(--muted); white-space: nowrap; font-size: 14px; }
.prefix input { border: 0; padding-left: 0; min-width: 0; }
.checks { display: grid; gap: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; font-size: 14px; cursor: pointer; }
.check.sub { padding-left: 24px; }
.btn.wide { width: 100%; justify-content: center; padding: 13px; }
.btn.danger { background: var(--bad); }
button.link { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--text); text-decoration: underline; cursor: pointer; }
button.link.danger { color: var(--bad); }
.block { margin-top: 16px; scroll-margin-top: 16px; }
.block > h2 { font-size: 18px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.tabs a:hover { border-color: var(--gold); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px; }
.filters input { flex: 1 1 220px; width: auto; }
.filters select { flex: 0 1 200px; width: auto; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-form label { margin-top: 0; }
.inline-form .grow { flex: 1 1 260px; }
.inline-form.generate { border-top: 0; padding-top: 0; margin: 0 0 16px; }
.danger-zone { border-color: #efc4c0; }

/* ---------- Produkte ---------- */
.products td.thumb { width: 56px; }
.products img, .noimg { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: grid; place-items: center; background: var(--bg); color: var(--muted); }
.images { display: grid; grid-template-columns: repeat(auto-fill, 130px); gap: 12px; margin-bottom: 16px; }
.images figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.images figure.main { border: 2px solid var(--gold); }
.images img { width: 130px; height: 130px; object-fit: cover; display: block; }
.images figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px; padding: 6px 8px; background: #fff; font-size: 12px; }
.upload { display: grid; gap: 12px; }
.drop { display: block; border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; margin: 0; font-weight: 400; }
.drop:hover { border-color: var(--gold); }
.drop input { display: block; margin: 0 auto 8px; }
.preview { display: flex; gap: 8px; flex-wrap: wrap; }
.preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.upload .btn { justify-self: start; }
.option { padding: 12px 0; border-top: 1px solid var(--line); }
.option-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--gold-soft); font-size: 14px; }
.chip button { background: none; border: 0; cursor: pointer; font-size: 16px; line-height: 1; color: #6b4a1c; padding: 0 4px; border-radius: 50%; }
.chip button:hover { background: rgba(0,0,0,.08); }
.variants input { padding: 7px 8px; }
.variants .w-sku { width: 190px; }
.variants .w-num { width: 90px; text-align: right; }
.variants .w-qty { width: 76px; text-align: right; }

@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Fotos: Drag & Drop ---------- */
.drop strong { display: block; color: var(--text); margin-bottom: 4px; }
.drop span { font-size: 13px; }
.drop.over { border-color: var(--gold); background: var(--gold-soft); }
.images figure { cursor: grab; transition: opacity .15s; }
.images figure.dragging { opacity: .4; }
.images figure:first-child { border: 2px solid var(--gold); }
.images figure .main-badge { display: none; }
.images figure:first-child .main-badge { display: inline-block; }
.images figure:first-child .make-main { display: none; }
.preview img { border: 1px solid var(--line); }
.btn:disabled { opacity: .6; cursor: progress; }

/* ---------- Kategorien ---------- */
tr.selected td { background: var(--gold-soft); }
.depth-1 { padding-left: 30px !important; }
.depth-2 { padding-left: 52px !important; }
.depth-3 { padding-left: 74px !important; }
.mt { margin-top: 18px; }
.m0 { margin-top: 0; }

/* ---------- Bestellungen ---------- */
.stack { display: grid; gap: 16px; min-width: 0; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
img.mini { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
table.totals { width: 100%; max-width: 360px; margin: 12px 0 0 auto; }
table.totals td { border: 0; padding: 4px 8px; }
table.totals .grand td { border-top: 2px solid var(--text); font-size: 17px; font-weight: 600; padding-top: 8px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; align-content: start; }
.step.done { background: #f3f8f4; border-color: #cfe5d6; }
.ship-form { display: grid; gap: 8px; }
.ship-form input { padding: 8px 10px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--gold); background: #fff; }
.note-form { display: flex; gap: 8px; margin-bottom: 12px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid #fff; }
.timeline li.canceled::before, .timeline li.returned::before, .timeline li.refunded::before { background: var(--bad); }
.timeline li.note::before { background: var(--muted); }
.timeline p { margin: 2px 0; }
.print-links { display: flex; gap: 8px; flex-wrap: wrap; }
.order-lines select { min-width: 280px; }
[data-add-line] { margin-top: 10px; }
@media (max-width: 860px) {
  .steps { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
}

/* ---------- Druckstation ---------- */
.station-status { display: flex; align-items: center; gap: 14px; font-size: 16px; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: var(--muted); flex: none; }
.dot[data-state="ok"] { background: var(--ok); box-shadow: 0 0 0 6px #e3f1e8; }
.dot[data-state="busy"] { background: var(--gold); box-shadow: 0 0 0 6px var(--gold-soft); }
.dot[data-state="bad"] { background: var(--bad); box-shadow: 0 0 0 6px #f8e1df; }
.print-frame { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }
.howto { padding-left: 18px; margin: 0; display: grid; gap: 8px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }

/* ---------- Korrekturen ---------- */
img.mini, .products img { max-width: none; flex: none; }
.form-grid > * { min-width: 0; }
.wrap td, .wrap th { white-space: normal; }
@media (max-width: 860px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 20px 16px; }
  .head h1 { font-size: 22px; }
  .note-form { flex-wrap: wrap; }
}
select { max-width: 100%; text-overflow: ellipsis; }
.cols > *, .grid > *, .stack > * { min-width: 0; }
@media (max-width: 860px) {
  /* Tabellen ohne eigenen Scrollbereich dürfen umbrechen */
  table:not(.table-wrap table) td, table:not(.table-wrap table) th { white-space: normal; }
  .order-lines select { min-width: 200px; }
}
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }
input.upper { text-transform: uppercase; }
input[type=datetime-local] { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* ---------- Inventar & Benachrichtigungen ---------- */
.link-card { text-decoration: none; }
.link-card:hover { border-color: var(--gold); }
.bad-text { color: var(--bad); }
.inline-min { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.inline-min input { width: 72px; padding: 7px 8px; }
.stock-form { display: flex; gap: 6px; align-items: center; }
.stock-form select { width: auto; padding: 7px 6px; }
.stock-form input[type=number] { width: 80px; padding: 7px 8px; }
.stock-form input[type=text] { width: 130px; padding: 7px 8px; }
.stock-form .btn { padding: 7px 12px; }
tr.low td { background: #fdf6ec; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.notes li a { text-decoration: none; display: grid; }
.notes li a span { color: var(--muted); font-size: 14px; }
.notes li.read { opacity: .55; }
.notes li.low_stock:not(.read) { border-left: 3px solid var(--warn); }
.notes li.new_order:not(.read) { border-left: 3px solid var(--ok); }
.bell { display: flex; align-items: center; gap: 8px; }
.bell .count { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 600; padding: 1px 7px; }
.exchange { border-top: 1px solid var(--line); padding: 12px 0; }
.exchange:first-of-type { border-top: 0; }
.ex-lines { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.ship-form.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.ship-form.inline input { width: auto; flex: 1 1 180px; }
.mt-s { margin-top: 6px; }
.subnav { margin: -8px 0 16px; }
.subnav a.current { background: var(--ink); color: #fff; border-color: var(--ink); }
code.big { display: inline-block; margin: 8px 0; font-size: 14px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); user-select: all; }
.wrap-cell { white-space: normal; min-width: 240px; }
tr.muted td { opacity: .55; }
/* Inventar: Formular kompakt, darf umbrechen */
.inventory .stock-form { flex-wrap: nowrap; }
.inventory .stock-form select { width: 74px; }
.inventory .stock-form input[type=number] { width: 64px; }
.inventory td:first-child + td small { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.inventory td { vertical-align: middle; }
.tiny { font-size: 12px; color: var(--muted); }
