:root {
  --blue: #1f6f8b;
  --blue-dark: #145066;
  --red: #d9534f;
  --border: #d7dde3;
  --muted: #6b7785;
  --bg: #f5f7f9;
  --card-bg: #ffffff;
  --text: #1c2733;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121820;
    --card-bg: #1b232d;
    --text: #e7edf3;
    --border: #2c3945;
    --muted: #93a1b0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar h1 {
  margin: 0 0 10px 0;
  font-size: 20px;
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
}

.controls label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 4px;
}

.controls select, .controls button {
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.controls button {
  cursor: pointer;
  align-self: flex-end;
  background: var(--blue);
  color: white;
  border: none;
}

.controls button:hover { background: var(--blue-dark); }

main {
  padding: 16px 20px 60px;
  max-width: 1100px;
  margin: 0 auto;
}

details.category {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

details.category summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary::-webkit-details-marker { display: none; }

/* Inventur Layout: kräftige rosa/pinke Kategorie-Balken, schwarze Schrift (wie Original-Excel) */
body.layout-inventur details.category summary {
  background: #FB6574;
  color: #000;
  justify-content: center;
  gap: 12px;
}

body.layout-inventur .artikel-name {
  font-weight: 400;
}

/* QSL Layout: kleine, dezente Überschrift ohne Hintergrundfarbe */
body.layout-qsl details.category {
  border-radius: 4px;
}
body.layout-qsl details.category summary {
  background: none;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
body.layout-qsl summary .badge {
  color: var(--muted);
}

summary .arrow {
  transition: transform 0.15s;
  margin-right: 8px;
}

details[open] > summary .arrow {
  transform: rotate(90deg);
}

summary .badge {
  font-weight: 400;
  font-size: 12px;
  opacity: 0.9;
}

table.article-table {
  width: 100%;
  border-collapse: collapse;
}

table.article-table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

table.article-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.article-table tr:last-child td { border-bottom: none; }

/* Lagerbestand, Einheit, Bestellmenge, Einheit: rechtsbündig */
table.article-table th:nth-child(n+3),
table.article-table td:nth-child(n+3) {
  text-align: right;
}

/* Beide Einheit-Spalten: fett */
table.article-table th:nth-child(4),
table.article-table th:nth-child(6) {
  font-weight: 700;
}

/* QSL Layout: Zeilen abwechselnd einfärben (Zebra-Streifen), unabhängig von der Bestellmenge */
body.layout-qsl table.article-table tbody tr:nth-child(even) {
  background: #FFF5F4;
}

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
  display: block;
}

.thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px dashed var(--border);
}

.artikel-name {
  font-weight: 600;
  font-size: 14px;
}

.artikel-sub {
  font-size: 12px;
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
}

.lager-stepper {
  display: inline-flex;
  align-items: stretch;
}

input.lager-input {
  width: 60px;
  padding: 5px 6px;
  border-radius: 5px 0 0 5px;
  border: 1px solid var(--border);
  border-right: none;
  background: var(--card-bg);
  color: var(--text);
  text-align: right;
}

input.lager-input:disabled {
  opacity: 0.4;
}

.stepper-btns {
  display: flex;
  flex-direction: column;
}

.step-btn {
  width: 18px;
  height: 12.5px;
  line-height: 1;
  font-size: 8px;
  padding: 0;
  border: 1px solid var(--border);
  border-left: none;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
}

.step-btn.step-up {
  border-radius: 0 5px 0 0;
  border-bottom: none;
}

.step-btn.step-down {
  border-radius: 0 0 5px 0;
}

.step-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.menge-value {
  font-weight: 700;
  font-size: 15px;
}

.no-data-label {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.unit-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

footer {
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* Admin-Link vorerst ausgeblendet - Seite /admin.html bleibt erreichbar */
footer.admin-link-hidden {
  display: none;
}

footer a {
  color: var(--blue);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* --- admin --- */

.admin-wrap {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px;
}

.login-box {
  max-width: 320px;
  margin: 80px auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 8px;
  margin: 12px 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.login-box button, .admin-actions button {
  background: var(--blue);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
}

.login-box button:hover, .admin-actions button:hover { background: var(--blue-dark); }

.error-msg { color: var(--red); font-size: 13px; min-height: 18px; }

.admin-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.admin-tabs button {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
}
.admin-tabs button.active { background: var(--blue); color: white; border-color: var(--blue); }

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

table.edit-table { border-collapse: collapse; width: 100%; font-size: 13px; }
table.edit-table th, table.edit-table td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  white-space: nowrap;
}
table.edit-table input {
  width: 100%;
  min-width: 60px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
table.edit-table input:focus { outline: 1px solid var(--blue); }

.admin-actions { margin: 14px 0; display: flex; gap: 10px; align-items: center; }
.save-status { font-size: 13px; color: var(--muted); }

.thumb-cell { display: flex; align-items: center; gap: 6px; }
.thumb-cell img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.thumb-cell input[type=file] { font-size: 11px; width: 110px; }

.row-actions button { cursor: pointer; }
