/* Farbschema: Systemstandard, außer der Benutzer wählt unter „Optionen“ fest hell oder dunkel
   (data-theme am <html>-Element, gesetzt von theme.js/app.js). */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5f6b7a;
  --border: #dde1e7;
  --accent: #0b5cad;
  --accent-text: #ffffff;
  --produced-bg: #e3f4e6;
  --produced-bar: #2e9d4a;
  --called-bg: #e7f0fb;
  --called-text: #0b4f94;
  --shipped-text: #8a94a3;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --error: #b42318;
  --draft-bg: #fff4dc;
  --draft-bar: #d48806;
  --draft-text: #8a5300;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12161c;
    --surface: #1a2029;
    --text: #e6e9ee;
    --muted: #98a2b1;
    --border: #2c3440;
    --accent: #4a9be8;
    --accent-text: #0b1420;
    --produced-bg: #183522;
    --produced-bar: #4cc26d;
    --called-bg: #1b2d44;
    --called-text: #8cc0f5;
    --shipped-text: #6c7686;
    --warn-bg: #3a3014;
    --warn-text: #f3d98a;
    --error: #f97066;
    --draft-bg: #33280e;
    --draft-bar: #e0a52a;
    --draft-text: #f2c46b;
  }
}

/* Gleiche Werte wie oben, für die feste Auswahl „Dunkel“. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161c;
  --surface: #1a2029;
  --text: #e6e9ee;
  --muted: #98a2b1;
  --border: #2c3440;
  --accent: #4a9be8;
  --accent-text: #0b1420;
  --produced-bg: #183522;
  --produced-bar: #4cc26d;
  --called-bg: #1b2d44;
  --called-text: #8cc0f5;
  --shipped-text: #6c7686;
  --warn-bg: #3a3014;
  --warn-text: #f3d98a;
  --error: #f97066;
  --draft-bg: #33280e;
  --draft-bar: #e0a52a;
  --draft-text: #f2c46b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.demo-banner {
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; }
.brand-name { color: var(--accent); }
.brand-sep { color: var(--muted); margin: 0 0.35rem; }
.user { color: var(--muted); font-size: 0.9rem; }

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.options { position: relative; }
.options summary { list-style: none; }
.options summary::-webkit-details-marker { display: none; }
.options summary::after { content: " ▾"; color: var(--muted); }
.options-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 10;
  min-width: 13rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
.options fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.options legend { font-weight: 600; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; padding: 0; }
.options label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.intro h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.intro p { margin: 0; color: var(--muted); }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  min-width: 9rem;
}
.stat-value { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.search { flex: 1 1 22rem; }
.search input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
}
.chip:has(input:checked) { border-color: var(--accent); color: var(--accent); }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.orders {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.orders th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 0.6rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.orders td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.orders .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.orders .nowrap { white-space: nowrap; }

tr.week td {
  background: var(--bg);
  font-weight: 600;
  padding-top: 0.9rem;
}
tr.week .week-meta { font-weight: 400; color: var(--muted); margin-left: 0.5rem; }

tr.produced td { background: var(--produced-bg); }
tr.produced td:first-child { box-shadow: inset 4px 0 0 var(--produced-bar); }
tr.shipped td { color: var(--shipped-text); }

.orders td:nth-child(3) { min-width: 13rem; }
.article { font-weight: 600; }
.sub { color: var(--muted); font-size: 0.8rem; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.badge-called { background: var(--called-bg); color: var(--called-text); border-color: transparent; }
.badge-early { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

.btn {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.6; cursor: default; }

.empty { text-align: center; color: var(--muted); padding: 2rem; }

/* Vormerkungen */
tr.draft td { background: var(--draft-bg); }
tr.draft td:first-child { box-shadow: inset 4px 0 0 var(--draft-bar); }
.badge-draft {
  background: transparent;
  color: var(--draft-text);
  border: 1px dashed var(--draft-bar);
}
.was { text-decoration: line-through; color: var(--muted); font-size: 0.78rem; margin-left: 0.35rem; }

.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger-ghost { background: transparent; color: var(--error); border-color: transparent; }
.btn-danger-ghost:hover { border-color: var(--error); }
.dlg-left { margin-right: auto; }
.dlg-text { color: var(--muted); margin: 0 0 1rem; }

.transfer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 2px solid var(--draft-bar);
  font-weight: 600;
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.12);
  padding: 0.75rem 1.5rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
}
.transfer-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}
.transfer-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.transfer-bar:not(.has-drafts) { border-top-color: var(--border); }
main { padding-bottom: 7rem; }
.toast { bottom: 6rem; }

.bar-date { display: flex; align-items: center; gap: 0.6rem; }
.bar-date input {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg);
  color: inherit;
}
.bar-date.attention input { border-color: var(--error); animation: nudge 0.35s ease-in-out 2; }
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) { .bar-date.attention input { animation: none; } }
.bar-hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.bar-hint.error { color: var(--error); font-weight: 600; }
.bar-count { font-weight: 600; }
.row-actions { display: flex; flex-direction: column; align-items: stretch; gap: 0.3rem; }
.orders td:nth-child(10) { min-width: 9rem; }

@media (max-width: 640px) {
  .transfer-bar { padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
  .transfer-bar-inner { gap: 0.4rem 0.75rem; }
  .bar-hint:not(.error) { display: none; }
  .bar-date span { font-size: 0.85rem; }
  .bar-count { font-size: 0.85rem; }
  .transfer-actions { margin-left: 0; width: 100%; }
  .transfer-actions .btn { flex: 1; }
}

dialog.dialog-wide { width: min(60rem, calc(100vw - 2rem)); }
table.compact td, table.compact th { padding: 0.4rem 0.5rem; }
.transfer-summary { font-weight: 600; margin: 0 0 0.75rem; }
.badge-new { background: var(--called-bg); color: var(--called-text); border-color: transparent; }
.badge-change { background: var(--draft-bg); color: var(--draft-text); border: 1px dashed var(--draft-bar); }
tr.row-change td { background: var(--draft-bg); }
.was-value { text-decoration: line-through; color: var(--muted); }
.new-value { font-weight: 600; }
tr.row-error td { background: color-mix(in srgb, var(--error) 12%, transparent); }
.row-error-text { color: var(--error); font-size: 0.8rem; }

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(30rem, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog h2 { margin: 0 0 1rem; font-size: 1.2rem; }

.dlg-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}
.dlg-facts dt { color: var(--muted); }
.dlg-facts dd { margin: 0; }

.field { display: grid; gap: 0.35rem; font-weight: 600; }
.field input {
  font: inherit;
  font-weight: 400;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: inherit;
}
.field-hint { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 0; }
.field-error { color: var(--error); font-size: 0.9rem; margin: 0.6rem 0 0; }

.dlg-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  max-width: calc(100vw - 2rem);
}
