/* OrderHub – ruhige, warme Arbeitsoberfläche für viele Bestellungen */
:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-2: #fbfaf7;
  --ink: #27241f;
  --muted: #716b61;
  --line: #e7e2d8;
  --line-strong: #d6cfc2;
  --accent: #2f6f73;
  --accent-ink: #ffffff;
  --accent-soft: #e3efef;
  --danger: #b4432f;
  --danger-soft: #f8e2dd;
  --ok: #3d7a45;
  --ok-soft: #e1efe1;
  --warn-soft: #fbf0d0;
  --focus: #2f6f73;
  --row-mix: 55%;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --shadow-pop: 0 10px 30px rgba(40, 33, 20, .14), 0 1px 3px rgba(40, 33, 20, .08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1c19; --panel: #262521; --panel-2: #2b2a26; --ink: #ece8df; --muted: #a39d92;
    --line: #36342f; --line-strong: #47443e; --accent: #6fb3b5; --accent-ink: #12201f; --accent-soft: #23393a;
    --danger: #e08a77; --danger-soft: #45261f; --ok: #8cc493; --ok-soft: #22352a; --warn-soft: #3d3420;
    --shadow-pop: 0 10px 30px rgba(0,0,0,.45); color-scheme: dark; --row-mix: 16%;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1c19; --panel: #262521; --panel-2: #2b2a26; --ink: #ece8df; --muted: #a39d92;
  --line: #36342f; --line-strong: #47443e; --accent: #6fb3b5; --accent-ink: #12201f; --accent-soft: #23393a;
  --danger: #e08a77; --danger-soft: #45261f; --ok: #8cc493; --ok-soft: #22352a; --warn-soft: #3d3420;
  --shadow-pop: 0 10px 30px rgba(0,0,0,.45); color-scheme: dark; --row-mix: 16%;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.num, td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Gerüst ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--panel-2); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { font-family: var(--serif); font-size: 20px; padding: 2px 10px 14px; letter-spacing: -.01em; }
.brand small { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); letter-spacing: 0; }
.nav-group { margin: 10px 0 2px; padding: 0 10px; font-size: 12px; color: var(--muted); }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-s); color: var(--ink); }
.nav a:hover { background: var(--line); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a.on .count { color: var(--accent); }
.nav .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; border: 1px solid rgba(0,0,0,.12); }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.side-foot button { all: unset; cursor: pointer; color: var(--muted); }
.side-foot button:hover { color: var(--ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 26px 10px; }
.top h1 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 0; letter-spacing: -.01em; }
.top .sub { color: var(--muted); font-size: 13px; }
.top .grow { flex: 1; }
.content { padding: 0 26px 26px; }

/* ---------- Bedienelemente ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); padding: 6px 12px; border-radius: var(--radius-s); font: inherit; font-size: 13.5px; cursor: pointer; line-height: 1.3; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex: none; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 6px 9px; min-width: 0;
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
label.f input, label.f select, label.f textarea { font-size: 14px; color: var(--ink); }

/* Filterleiste */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 10px 12px; margin-bottom: 10px; }
.filters .search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 6px 4px 12px; }
.filters .search svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.filters .search input { border: 0; background: transparent; flex: 1; padding: 4px 0; box-shadow: none; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.seg a { padding: 5px 12px; color: var(--ink); font-size: 13px; border-right: 1px solid var(--line); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--accent); color: var(--accent-ink); }
.seg a:hover { text-decoration: none; }

/* Werkzeugleiste über der Tabelle */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.toolbar .sel { color: var(--muted); font-size: 13px; margin-right: 6px; min-width: 92px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; }

/* ---------- Tabelle ---------- */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: auto; max-height: calc(100vh - 262px); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.grid th a { color: inherit; }
table.grid th.num { text-align: right; }
table.grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr { background: var(--row, color-mix(in srgb, var(--rc, transparent) var(--row-mix), transparent)); }
table.grid tbody tr td:first-child { box-shadow: inset 4px 0 0 var(--stripe, transparent); }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--ink) 4%, transparent); }
table.grid tbody tr.picked td { background: color-mix(in srgb, var(--accent) 14%, transparent); }
table.grid td.title { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid td.title a { color: var(--ink); }
table.grid td.chk, table.grid th.chk { width: 34px; text-align: center; padding-left: 12px; }
.flag { font-size: 12px; font-weight: 600; letter-spacing: .02em; display: inline-block; min-width: 24px; padding: 1px 5px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); text-align: center; }
.plat { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 700; color: #fff; }
.plat.ebay { background: #5b6fd6; } .plat.woocommerce { background: #7f54b3; } .plat.amazon { background: #e08a1e; } .plat.manual { background: #6b7d6e; }
.yes { color: var(--ok); font-weight: 700; } .no { color: var(--line-strong); }
.badge { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.badge.new { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.used { background: var(--bg); }
.badge.warn { background: var(--warn-soft); color: #7a5b07; border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.good { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.est { color: var(--muted); font-style: italic; }

.totals { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 22px; justify-content: flex-end; padding: 9px 16px; margin-top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); font-size: 13px; color: var(--muted); }
.totals b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; margin-left: 6px; }
.pager { display: flex; gap: 6px; align-items: center; margin-right: auto; }

/* Spaltenwahl */
.pop { position: relative; }
.pop > .panel { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-pop); padding: 10px; min-width: 240px; max-height: 70vh; overflow: auto; }
.colpick li { list-style: none; display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: grab; }
.colpick li:hover { background: var(--bg); }
.colpick ul { margin: 0 0 8px; padding: 0; }
.colpick li.dragging { opacity: .4; }

/* ---------- Karten / Formulare (Bestellung) ---------- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 18px; margin-bottom: 16px; }
.box h2 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0 0 12px; }
.box h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 12px; }
.formgrid .wide { grid-column: 1 / -1; }
.addr2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
table.items { width: 100%; border-collapse: collapse; }
table.items th { font-size: 12px; color: var(--muted); text-align: left; font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line-strong); }
table.items td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.items input, table.items select { width: 100%; }
table.items td.q input { width: 64px; }
table.items td.p input { width: 96px; text-align: right; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
.kv .badge { white-space: normal; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inv-list { list-style: none; padding: 0; margin: 0; }
.inv-list li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.inv-list li:last-child { border-bottom: 0; }
.locked { font-size: 12.5px; background: var(--warn-soft); border-radius: var(--radius-s); padding: 8px 10px; margin-bottom: 10px; }

/* Meldungen */
.flash { padding: 10px 14px; border-radius: var(--radius-m); margin: 0 26px 12px; font-size: 13.5px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-m); box-shadow: var(--shadow-pop); font-size: 13.5px; z-index: 50; max-width: 420px; }

/* Inline-Bearbeitung (Artikel) */
td.edit { cursor: text; }
td.edit:hover { outline: 1px dashed var(--line-strong); outline-offset: -3px; }
td.edit input { width: 84px; text-align: right; padding: 3px 6px; }
td.edit.saving { opacity: .5; }
td.edit.ok { animation: okflash 1.2s ease-out; }
td.edit.fail { background: var(--danger-soft) !important; }
@keyframes okflash { from { background: var(--ok-soft); } to { background: transparent; } }
.thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; background: var(--bg); display: block; }

/* Farbregeln */
.rules { display: grid; gap: 6px; }
.rules .rule { display: grid; grid-template-columns: 26px 46px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s); border: 1px solid var(--line); }
.rules input[type=color] { width: 40px; height: 28px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0; background: none; cursor: pointer; }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 28px; width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-family: var(--serif); font-weight: 500; margin: 0; font-size: 26px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .nav-group, .side-foot { display: none; }
  .cols { grid-template-columns: 1fr; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .addr2, .formgrid { grid-template-columns: 1fr; }
  .tablewrap { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
