/* Box Count App – Aussehen.
   Gebaut für das Handy im Lager: große Schrift, große Tippflächen, starker Kontrast. */

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #d1d5db;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
  --ok: #15803d;
  --ok-light: #dcfce7;
  --warn: #92400e;
  --warn-light: #fef3c7;
  --danger: #b91c1c;
  --danger-light: #fee2e2;
  --started: #2563eb;
  --started-light: #dbeafe;
  --started-dark: #1e40af;
  --tap: 60px; /* Mindesthöhe für alles, was man antippt */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  overflow-x: hidden;
}

button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

h1 { font-size: 26px; margin: 8px 0 16px; line-height: 1.2; }
.h1-small { font-size: 24px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.big-line { font-size: 20px; font-weight: 700; margin: 0 0 4px; }

/* ---------- Kopfbereich (bleibt oben stehen) ---------- */
.sticky-top { position: sticky; top: 0; z-index: 10; }

.demo-banner {
  background: repeating-linear-gradient(45deg, #facc15 0 14px, #fde047 14px 28px);
  color: #000;
  border-bottom: 2px solid #000;
  padding: 6px 16px;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
}

.storage-error {
  background: var(--danger);
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 8px 16px;
  background: var(--primary-dark);
  color: #fff;
}
.nav { display: flex; gap: 8px; }
.nav-btn {
  min-height: 46px;
  padding: 6px 14px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 12px;
  background: transparent;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}
.nav-btn.current { background: rgba(255, 255, 255, .18); border-color: #fff; }

.lang-switch { display: flex; border: 2px solid #fff; border-radius: 12px; overflow: hidden; }
.lang-switch button {
  min-width: 60px;
  min-height: 46px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}
.lang-switch button.active { background: #fff; color: var(--primary-dark); }

/* Leiste unter dem Kopf: Fortschritt bzw. laufende Summe.
   Das Padding hält den Inhalt auf breiten Bildschirmen in derselben Spalte wie main. */
.subbar {
  background: #fff;
  border-bottom: 2px solid var(--line);
  padding: 10px max(16px, calc((100% - 608px) / 2));
}
.subbar-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 16px; }
.progress { height: 12px; margin-top: 8px; background: #e5e7eb; border-radius: 6px; overflow: hidden; }
.progress { display: flex; }
.seg-done { height: 100%; background: var(--ok); }
.seg-started { height: 100%; background: var(--started); }

.total-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.total-label { font-size: 18px; font-weight: 700; }
.total-value { font-size: 38px; font-weight: 800; line-height: 1; }
.small-total { font-size: 28px; }

/* ---------- Karten, Felder, Buttons ---------- */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin: 0 0 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.field { display: block; margin-bottom: 20px; }
.field > span { display: block; font-weight: 700; margin-bottom: 8px; }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 20px;
}
.input.big { font-size: 30px; font-weight: 700; }
.input:focus { outline: 3px solid #93c5fd; border-color: var(--primary); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  margin-top: 12px;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.success { background: var(--ok); color: #fff; }
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }

/* Rückfrage-Fenster */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, .55);
}
.dialog {
  width: 100%;
  max-width: 420px;
  padding: 20px 16px 16px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.dialog-text { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.link-btn {
  min-height: 48px;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
  text-align: left;
}
.bottom-links { display: flex; flex-direction: column; align-items: flex-start; margin-top: 20px; }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice.stack { grid-template-columns: 1fr; }
.choice-btn {
  min-height: 72px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}
.choice-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.error {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 700;
}

/* ---------- Boxtypen-Liste ---------- */
.box-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  margin-bottom: 10px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
}
.box-card.state-done { border-color: var(--ok); }
.box-card.state-started { border-color: var(--started); }
.box-card.inactive { opacity: .6; }
.box-card.missing { border-color: var(--danger); }

.thumb {
  flex: 0 0 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background: #e5e7eb;
  color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.box-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.box-sku { font-size: 19px; font-weight: 800; }
.box-name { font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.box-total { flex: 0 0 auto; font-size: 24px; font-weight: 800; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.chip.new { background: #e5e7eb; color: #374151; }
.chip.started { background: var(--started-light); color: var(--started-dark); }
.chip.done { background: var(--ok-light); color: var(--ok); }
.chip.demo { background: #fde047; color: #000; vertical-align: middle; }
.chip.warn { background: var(--warn-light); color: var(--warn); }

/* ---------- Erfassung je Boxtyp ---------- */
.box-head { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 16px; }

.entries { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
}
.entry-num {
  flex: 0 0 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e5e7eb;
  font-weight: 800;
}
.entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-note { display: block; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.entry-qty { font-size: 26px; font-weight: 800; }

.calc { min-height: 44px; margin-top: 10px; color: var(--ok); font-size: 30px; font-weight: 800; }

/* ---------- Warnung ---------- */
.warning-panel {
  padding: 16px;
  border: 3px solid var(--warn);
  border-radius: 14px;
  background: var(--warn-light);
}
.warning-panel h1 { color: var(--warn); margin-top: 0; }
.ok-panel {
  padding: 16px;
  border: 3px solid var(--ok);
  border-radius: 14px;
  background: var(--ok-light);
}
.ok-panel h1 { color: var(--ok); margin-top: 0; }
.neutral-panel { padding: 16px; border: 3px solid var(--line); border-radius: 14px; background: #fff; }
.neutral-panel h1 { margin-top: 0; }

/* Echtbetrieb: Verbindungsstatus und Hinweis auf zwischengespeicherten Bestand */
.server-status { margin: 16px 0 0; font-size: 15px; font-weight: 700; color: var(--muted); }
.server-status.ok { color: var(--ok); }
.server-status.noShiphero, .server-status.offline { color: var(--danger); }
.stock-note { margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--warn); }
.warning-msg { margin: 10px 0; font-size: 21px; font-weight: 800; }

.facts { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 14px 0 0; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; font-weight: 800; text-align: right; }

.success-card { border: 3px solid var(--ok); }
.success-card h1 { color: var(--ok); margin-top: 0; }

/* ---------- Historie ---------- */
.hist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hist-entries { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.hist-entries li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.card .chip.warn { margin-top: 8px; white-space: normal; }

/* ---------- Stapel: Art-Kennzeichen und Eingabezeile ---------- */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  vertical-align: 1px;
}
.type-badge.height { background: var(--started-light); color: var(--started-dark); }
.type-badge.label { background: #f3e8ff; color: #6b21a8; }

.editor {
  padding: 12px;
  border: 3px solid var(--primary);
  border-radius: 14px;
  background: #fff;
}
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.type-toggle { flex: 1; display: flex; border: 2px solid var(--primary); border-radius: 12px; overflow: hidden; }
.type-toggle button {
  flex: 1;
  min-height: 48px;
  border: 0;
  background: #fff;
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
}
.type-toggle button.active { background: var(--primary); color: #fff; }
.editor-type { flex: 1; font-weight: 800; color: #6b21a8; }
.icon-btn {
  flex: 0 0 48px;
  height: 48px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
}

.editor-main { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.editor-main .input { flex: 1; min-width: 0; }
.editor .calc {
  flex: 0 0 76px;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}
.calc-num { font-size: 26px; color: var(--ok); }
.calc-unit { font-size: 14px; font-weight: 700; color: var(--muted); }
.btn-check {
  flex: 0 0 68px;
  height: 68px;
  border: 0;
  border-radius: 14px;
  background: var(--ok);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
}
.danger-link { color: var(--danger); margin-top: 4px; }

.add-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-buttons .btn { font-size: 18px; padding: 10px; }

/* ---------- Warnung: Verbrauch ---------- */
.usage-card { margin-top: 12px; }
.usage-card h2 { font-size: 19px; }
.usage-card .facts { margin-top: 8px; }

/* ---------- Historie: Monatstabelle und Zählungen ---------- */
h3 { font-size: 18px; margin: 16px 0 6px; }
.series { width: 100%; border-collapse: collapse; font-size: 16px; }
.series th, .series td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.series th:first-child, .series td:first-child { text-align: left; }
.series th { font-size: 14px; color: var(--muted); }
.series tr.est td { color: var(--muted); font-style: italic; }

.count-card summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
}
.count-card summary::-webkit-details-marker { display: none; }
.count-card summary > span { display: flex; flex-direction: column; }
.count-card summary::after { content: "▾"; color: var(--muted); }
.count-card[open] summary::after { content: "▴"; }

/* ---------- Einstellungen ---------- */
.spacer { height: 12px; }
.field-group { background: #fff; border-radius: 14px; padding: 14px 14px 4px; margin-bottom: 18px; }
.field-group .field { margin-bottom: 14px; }
.field small { display: block; margin-top: 6px; font-size: 14px; }
.input:disabled { background: #e5e7eb; color: var(--muted); }
.check {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--tap);
  margin-bottom: 18px;
  font-weight: 700;
}
.check input { width: 28px; height: 28px; flex: 0 0 28px; accent-color: var(--primary); }

/* ---------- Historie: breiter am Rechner, Diagramm ---------- */
main.wide { max-width: 1100px; }

.wh-picker { display: flex; border: 2px solid var(--primary); border-radius: 12px; overflow: hidden; margin: 8px 0 14px; max-width: 420px; }
.wh-picker button {
  flex: 1;
  min-height: 48px;
  border: 0;
  background: #fff;
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
}
.wh-picker button.active { background: var(--primary); color: #fff; }

/* Nur das Diagramm scrollt waagrecht, nie die Seite */
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding-bottom: 4px; }
.chart { display: block; font-family: inherit; }

:root {
  --chart-usage: #2563eb;
  --chart-lastyear: #9ca3af;
  --chart-stock: #ea580c;
}
.chart-grid { stroke: #e5e7eb; stroke-width: 1; }
.chart-axis { font-size: 12px; fill: var(--muted); }
.chart-axis-title { font-size: 12px; font-weight: 800; }
.chart-axis-usage { fill: var(--chart-usage); }
.chart-axis-stock { fill: var(--chart-stock); }
.chart-year { font-weight: 800; fill: var(--text); }
.chart-year-line { stroke: #9ca3af; stroke-width: 1; stroke-dasharray: 2 3; }
.chart-hover { fill: transparent; }
.chart g:hover .chart-hover { fill: rgba(37, 99, 235, .06); }

.chart-usage { fill: var(--chart-usage); }
.chart-usage-est { fill: url(#hatch-usage); stroke: var(--chart-usage); stroke-width: 1; stroke-dasharray: 3 2; opacity: .75; }
.chart-lastyear { fill: var(--chart-lastyear); }
.chart-lastyear-est { fill: url(#hatch-lastyear); stroke: var(--chart-lastyear); stroke-width: 1; opacity: .8; }
.chart-hatch-bg { fill: #fff; }
.chart-hatch-usage { stroke: var(--chart-usage); stroke-width: 2.5; }
.chart-hatch-lastyear { stroke: var(--chart-lastyear); stroke-width: 2.5; }

.chart-stock { stroke: var(--chart-stock); stroke-width: 2.5; }
.chart-stock-est { stroke: var(--chart-stock); stroke-width: 2; stroke-dasharray: 5 4; opacity: .7; }
.chart-stock-dot { fill: var(--chart-stock); stroke: #fff; stroke-width: 1.5; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 16px; height: 12px; border-radius: 2px; }
.sw-usage { background: var(--chart-usage); }
.sw-usage-est { background: repeating-linear-gradient(45deg, var(--chart-usage) 0 2px, #fff 2px 5px); border: 1px dashed var(--chart-usage); opacity: .75; }
.sw-lastyear { background: var(--chart-lastyear); width: 8px; }
.sw-stock { height: 3px; background: var(--chart-stock); position: relative; }
.sw-stock::after { content: ""; position: absolute; left: 4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--chart-stock); }
.sw-stock-est { height: 0; border-top: 2px dashed var(--chart-stock); border-radius: 0; opacity: .7; }

/* ---------- Einstellungen: SKU-Abgleich ---------- */
.sku-check-ok { color: var(--ok); font-weight: 700; }
.sku-check-bad { color: var(--danger); font-weight: 700; }
.sku-list {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px;
  resize: vertical;
}
.sku-check-note { margin: 16px 0 4px; font-weight: 700; color: var(--warn); }
.sku-pairs { margin: 0 0 8px; padding-left: 20px; }
.sku-pairs li { padding: 2px 0; }

/* ---------- LA SIESTA: Nachbestellvorschau und Freigabe ---------- */
.lasiesta-links { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.reorder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.reorder-grid .card { margin: 0; }
.reorder-card.is-overdue { border: 3px solid var(--danger); }
.reorder-head { margin-bottom: 6px; }
.reorder-note { color: var(--warn); font-weight: 700; }
.facts dd.overdue { color: var(--danger); }
.forecast-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: 15px; }
.fc { white-space: nowrap; }
.fc-ly { font-size: 12px; font-weight: 800; color: var(--started-dark); background: var(--started-light); padding: 0 4px; border-radius: 4px; }

/* Tabellen: am Handy nur die Tabelle waagrecht wischen, nie die Seite */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; }
.movements { width: 100%; border-collapse: collapse; font-size: 15px; background: #fff; border-radius: 12px; }
.movements th, .movements td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.movements th { font-size: 13px; color: var(--muted); white-space: nowrap; }
.movements .num { text-align: right; white-space: nowrap; }
.movements td.diff { font-weight: 800; }
.movements .reason { min-width: 260px; }
.approval input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--primary); }
.approve-actions { display: flex; gap: 20px; }

/* ---------- Ladeanzeige: drehender Kreis, damit nichts wie "hängt" aussieht ---------- */
.busy::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 10px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: busy-spin 0.8s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
.btn.busy:disabled { opacity: 0.85; }
.slow-hint { margin: 8px 0 0; font-size: 15px; font-weight: 700; color: var(--started-dark); }
