/* Neutrales Grau, flach. Warme Pastellfarben nur für Buttons und Pills – Text bleibt immer neutral. Kein Monospace. */
:root {
  color-scheme: light;
  --bg: #ececec;
  --card: #f6f6f6;
  --card-2: #ffffff;
  --border: #d6d6d6;
  --border-strong: #a8a8a8;
  --text: #262626;
  --muted: #626262;
  --ro-bg: #e8e8e8;
  --apricot: #f6cfa8;
  --apricot-line: #d9a371;
  --sand: #e4e4e4;
  --green: #c4e5b8;
  --green-line: #84b974;
  --orange: #fad3a0;
  --orange-line: #e0a24f;
  --rose: #f4c6c0;
  --rose-line: #d98d84;
  --mauve: #e9d6e4;
  --shadow: 0 4px 16px rgba(0, 0, 0, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: clamp(16px, 2.4vw, 20px); letter-spacing: .12em; font-weight: 800; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Layout */
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 80px; display: grid; gap: 22px; }
.wrap > * { min-width: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow); }
.card-title { margin: 0 0 18px; font-size: 18px; display: flex; align-items: center; gap: 12px; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 14px; font-weight: 800; background: var(--apricot); border: 1.5px solid var(--apricot-line); }
.count-badge { margin-left: auto; font-size: 13px; font-weight: 700; padding: 2px 12px; border-radius: 99px; background: var(--sand); border: 1px solid var(--border-strong); }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: 12px; }

/* ---------- Banner / Progress */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-radius: 14px; background: var(--green); border: 1.5px solid var(--green-line); font-weight: 600; }
.progress { display: grid; gap: 8px; }
.progress-text { color: var(--muted); font-size: 14px; }
.progress-text strong { color: var(--text); }
.bar { height: 10px; background: var(--ro-bg); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--green-line); border-radius: 99px; transition: width .4s ease; }

/* ---------- Fields */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.span-2 { grid-column: span 2; }
.field { display: grid; gap: 7px; align-content: start; }
.label { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.label small { font-weight: 500; text-transform: none; letter-spacing: 0; }

.input {
  width: 100%; height: 50px; padding: 0 16px;
  font: inherit; color: var(--text);
  background: var(--card-2);
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: var(--apricot-line); }
.input:focus { border-color: var(--apricot-line); box-shadow: 0 0 0 4px var(--apricot); }
.input-xl { height: 62px; font-size: 20px; }
.input-ro { background: var(--ro-bg); border-color: var(--border); border-style: dashed; cursor: default; text-overflow: ellipsis; }
.input-ro:hover, .input-ro:focus { border-color: var(--border); box-shadow: none; }
.input-pool { font-weight: 700; }
.num { text-align: right; }
.input-qty { font-size: 28px; font-weight: 700; text-align: center; max-width: 260px; }
.input-qty[readonly] { background: var(--ro-bg); border-style: dashed; border-color: var(--border); }
/* keine Hoch/Runter-Pfeile */
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.qty-field { grid-column: span 2; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 18px; border-radius: 14px; background: var(--sand); border: 1px solid var(--border); }
.input-note { height: auto; min-height: 106px; padding: 12px 16px; line-height: 1.45; resize: vertical; font-size: 16px; }
.input-note[readonly] { background: var(--ro-bg); border-style: dashed; border-color: var(--border); }
.qty-row { display: flex; align-items: center; gap: 12px; }
.diff { margin: 2px 0 0; min-height: 28px; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }

.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.form-error { margin: 0; padding: 10px 14px; border-radius: 10px; font-size: 14px; background: var(--rose); border: 1.5px solid var(--rose-line); }

/* ---------- Pills (Farbe nur als Fläche, Text bleibt neutral) */
.pill, .chip { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 99px; border: 1.5px solid var(--border-strong); background: var(--ro-bg); white-space: nowrap; }
.pill-pos, .pill-green { background: var(--green); border-color: var(--green-line); }
.pill-neg { background: var(--rose); border-color: var(--rose-line); }
.pill-zero { background: var(--ro-bg); }
.pill-new { background: var(--sand); border-color: var(--border-strong); }
.pill-orange { background: var(--orange); border-color: var(--orange-line); }
.chip-cey { background: var(--apricot); border-color: var(--apricot-line); }
.chip-none { background: var(--sand); border-color: var(--border-strong); }
.chip-graf, .chip-mixed { background: var(--mauve); border-color: #c4a2ba; }

/* ---------- Search */
.search-box { position: relative; }
.results {
  list-style: none; margin: 8px 0 0; padding: 6px;
  position: absolute; left: 0; right: 0; z-index: 10;
  background: var(--card-2); border: 2px solid var(--apricot-line); border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 420px; overflow-y: auto;
}
.result { padding: 10px 14px; border-radius: 10px; cursor: pointer; display: grid; gap: 2px; }
.result[aria-selected=true], .result:hover { background: var(--sand); }
.r-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.r-art { font-weight: 600; }
.r-desc { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-results { padding: 14px; color: var(--muted); text-align: center; }
.result-add { border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; margin-top: 4px; padding-top: 12px; font-weight: 500; }
.result-add:first-child { border-top: 0; margin-top: 0; }
.table td.d .dtext, .table td.d .note { display: block; overflow: hidden; text-overflow: ellipsis; }
.table td.d .note { font-size: 13px; color: var(--muted); }

/* ---------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; font: inherit; font-weight: 700; text-decoration: none;
  color: var(--text); background: transparent; border: 2px solid transparent; border-radius: 12px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { height: 54px; padding: 0 28px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--apricot); border-color: var(--apricot-line); }
.btn-primary:hover:not(:disabled) { background: #f2c08f; }
.btn-green { background: var(--green); border-color: var(--green-line); }
.btn-green:hover:not(:disabled) { background: #b3dba5; }
.btn-ghost { background: var(--card-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--sand); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--apricot-line); outline-offset: 2px; }
.icon-btn {
  flex: none; width: 54px; height: 54px; display: grid; place-items: center; cursor: pointer;
  color: var(--text); background: var(--apricot); border: 2px solid var(--apricot-line); border-radius: 14px;
}
.icon-btn:hover { background: #f2c08f; }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- Table */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table td.art { white-space: nowrap; }
.table td.d { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.wrapcell { white-space: normal; max-width: none; }
.table td.mpn { font-size: 13px; }
.table td.when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.table td.act, .table th.act { width: 52px; text-align: right; }
.table .row-edit { width: 38px; height: 38px; border-radius: 10px; }
.table .row-edit svg { width: 18px; height: 18px; }
.table tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--sand); } to { background: transparent; } }

/* ---------- Übersicht */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filter-btn { height: 40px; padding: 0 16px; font: inherit; font-weight: 700; color: var(--text); background: var(--card-2); border: 2px solid var(--border-strong); border-radius: 99px; cursor: pointer; }
.filter-btn[aria-pressed=true] { background: var(--sand); border-color: var(--apricot-line); }
.filter-btn.f-green[aria-pressed=true] { background: var(--green); border-color: var(--green-line); }
.filter-btn.f-orange[aria-pressed=true] { background: var(--orange); border-color: var(--orange-line); }
.filters .field { margin-left: auto; min-width: 220px; }
.filters .input { height: 40px; }

/* ---------- Toast & Dialog */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 14px 22px; border-radius: 14px; font-weight: 600; background: var(--green); border: 1.5px solid var(--green-line); box-shadow: var(--shadow); animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 12px); } }
dialog { max-width: min(480px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h2 { margin: 0 0 10px; font-size: 20px; }
dialog p { margin: 0 0 22px; color: var(--muted); }
dialog .actions { justify-content: flex-end; }

/* ---------- Login */
.login-body { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 420px); padding: 36px 32px; background: var(--card); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); text-align: center; }
.login-card form { display: grid; gap: 18px; text-align: left; }
.login-title { margin: 0; font-size: 20px; letter-spacing: .14em; font-weight: 800; line-height: 1.4; }
.login-sub { margin: 6px 0 26px; color: var(--muted); }

/* ---------- Responsive */
@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; }
  .span-2, .qty-field { grid-column: auto; }
  .qty-field { grid-template-columns: minmax(0, 1fr); }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1 1 auto; padding: 0 12px; }
  .actions .btn-lg { flex: 1; padding: 0 16px; }
  .input-qty { max-width: none; }
  .table .when, .table td.pool, .table th.pool { display: none; }
  .table td.d { max-width: 160px; }
  .filters .field { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
