/* Lagerverwaltung — Design-Tokens nach Vorlage (Sage/Lager-Dashboards):
   helles Grau, weiße Karten, Grün-Akzent, Status-Pills, flache Optik. */
:root {
  --bg: #F2F4F6;
  --card: #FFFFFF;
  --border: #E4E8EC;
  --text: #101828;
  --muted: #5B6573;
  --primary: #047857;
  --primary-dark: #064E3B;
  --primary-soft: #D9F2E5;
  --orange: #EA7A23;
  --orange-soft: #FCE9D8;
  --red: #D92D20;
  --red-soft: #FBE4E2;
  --blue: #2563EB;
  --blue-soft: #DEE9FC;
  --purple: #6D4FC4;
  --purple-soft: #E9E3F9;
  --gray-soft: #EAECEF;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
svg { display: block; flex-shrink: 0; }

#app { min-height: 100vh; }

/* ---------- Layout: mobil bottom-nav, Desktop Sidebar ---------- */
.shell { display: flex; min-height: 100vh; }
.main {
  flex: 1; min-width: 0;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 24px);
  max-width: 1100px; margin: 0 auto; width: 100%;
}
.sidebar { display: none; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600;
  min-width: 56px; min-height: 48px; justify-content: center; border-radius: 10px;
}
.bottomnav a.active { color: var(--primary); }
.bottomnav a.nav-plus { position: relative; top: -14px; }
.bottomnav a.nav-plus span.plus {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(4, 120, 87, .35);
}

@media (min-width: 1024px) {
  .bottomnav { display: none; }
  .main { padding: 28px 36px 60px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    width: 230px; flex-shrink: 0; background: var(--card);
    border-right: 1px solid var(--border); padding: 20px 12px;
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand {
    display: flex; align-items: center; gap: 10px; font-weight: 800;
    font-size: 17px; padding: 6px 10px 20px; color: var(--primary-dark);
  }
  .sidebar a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 600; font-size: 14.5px;
    transition: background .15s, color .15s; cursor: pointer;
  }
  .sidebar a:hover { background: var(--bg); color: var(--text); }
  .sidebar a.active { background: var(--primary-soft); color: var(--primary-dark); }
  .sidebar .spacer { flex: 1; }
}

/* ---------- Typo / Kopf ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; flex: 1; }
.page-head .sub { width: 100%; color: var(--muted); font-size: 14px; margin-top: -6px; }
.greeting { color: var(--muted); font-size: 14px; }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.card.tap { cursor: pointer; transition: border-color .15s; }
.card.tap:active, .card.tap:hover { border-color: var(--primary); }

/* ---------- KPI-Kacheln ---------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; gap: 12px; align-items: center; cursor: pointer;
  transition: border-color .15s;
}
.kpi:hover { border-color: var(--primary); }
.kpi .ico {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi .val { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Schnellaktionen (runde Buttons wie Vorlage) ---------- */
.quick-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-bottom: 14px;
}
.quick {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer; padding: 8px 2px;
  font-size: 12px; font-weight: 600; color: var(--text); border-radius: 12px;
}
.quick .bubble {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: transform .15s ease, background .15s;
}
.quick:hover .bubble { background: #c5ead8; }
.quick:active .bubble { transform: scale(.94); }
.quick .badge {
  position: absolute; top: -2px; right: -4px; min-width: 22px; height: 22px;
  border-radius: 11px; background: var(--orange); color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 6px;
}

/* ---------- Listen / Zeilen ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
  cursor: pointer; min-height: 56px;
}
.row:last-child { border-bottom: none; }
.row .ico {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--gray-soft); display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.row .body { flex: 1; min-width: 0; }
.row .title { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .right { text-align: right; flex-shrink: 0; }
.row .qty { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.row .sub { font-size: 12px; color: var(--muted); }

/* ---------- Status-Pills ---------- */
.pill {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.pill.s-verfuegbar    { background: var(--primary-soft); color: var(--primary-dark); }
.pill.s-ausgegeben    { background: var(--orange-soft); color: #9A4D10; }
.pill.s-reserviert    { background: var(--blue-soft); color: #1D4FB8; }
.pill.s-zurueckgegeben{ background: var(--primary-soft); color: var(--primary-dark); }
.pill.s-verbraucht    { background: var(--gray-soft); color: var(--muted); }
.pill.s-defekt        { background: var(--red-soft); color: #B42318; }
.pill.s-verloren      { background: #3F4754; color: #fff; }
.pill.s-reparatur     { background: var(--purple-soft); color: var(--purple); }
.pill.s-geplant       { background: var(--blue-soft); color: #1D4FB8; }
.pill.s-laufend       { background: var(--orange-soft); color: #9A4D10; }
.pill.s-abgeschlossen { background: var(--gray-soft); color: var(--muted); }
.pill.s-offen         { background: var(--orange-soft); color: #9A4D10; }
.pill.warn            { background: var(--red-soft); color: #B42318; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: none;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: background .15s; width: 100%;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; width: auto; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 50%; border: none; z-index: 40;
  background: var(--primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(4, 120, 87, .4);
}
@media (min-width: 1024px) { .fab { bottom: 28px; right: 28px; } }

/* ---------- Formulare ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  font-size: 16px; /* verhindert iOS-Zoom */
  transition: border-color .15s;
}
.field textarea { min-height: 86px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Suche + Filterchips ---------- */
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar input {
  width: 100%; min-height: 48px; padding: 10px 14px 10px 44px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); font-size: 16px;
}
.searchbar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.searchbar svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--muted); transition: all .15s;
  min-height: 38px; display: inline-flex; align-items: center;
}
.chip.active { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

/* ---------- Sheet (mobiles Modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 8px 18px calc(20px + var(--safe-b));
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: slideup .22s ease;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; padding-bottom: 22px; max-height: 86vh; }
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } * { transition: none !important; } }
.sheet .grab { width: 42px; height: 4px; border-radius: 2px; background: var(--border); margin: 6px auto 14px; }
.sheet h2 { font-size: 18px; font-weight: 800; margin-bottom: 14px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-item .dot {
  position: absolute; left: -26px; top: 4px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--primary); border: 4px solid var(--card);
  box-shadow: 0 0 0 1px var(--border);
}
.tl-item .dot.orange { background: var(--orange); }
.tl-item .dot.red { background: var(--red); }
.tl-item .dot.blue { background: var(--blue); }
.tl-item .dot.gray { background: var(--muted); }
.tl-item .t-title { font-weight: 700; font-size: 14px; }
.tl-item .t-meta { font-size: 12.5px; color: var(--muted); }
.tl-item .t-comment { font-size: 13px; margin-top: 3px; background: var(--bg); border-radius: 8px; padding: 6px 10px; }

/* ---------- Tabellen (Auswertungen) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Lagerort-Baum ---------- */
.tree-node { border-bottom: 1px solid var(--border); }
.tree-node:last-child { border-bottom: none; }
.tree-row { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 2px; }
.tree-row .toggle {
  width: 34px; height: 34px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  border-radius: 8px; flex-shrink: 0;
}
.tree-row .toggle:hover { background: var(--bg); }
.tree-row .name { flex: 1; font-weight: 600; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .count { font-size: 12px; color: var(--muted); background: var(--gray-soft); border-radius: 999px; padding: 2px 9px; font-weight: 700; }
.tree-kids { padding-left: 22px; border-left: 2px solid var(--border); margin-left: 18px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  background: var(--primary-dark); color: #fff; border-radius: 12px;
  padding: 12px 20px; font-size: 14px; font-weight: 600; max-width: 90%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); animation: slideup .2s ease;
}
.toast.error { background: var(--red); }

/* ---------- Diverses ---------- */
.empty { text-align: center; color: var(--muted); padding: 34px 16px; font-size: 14px; }
.empty svg { margin: 0 auto 10px; color: var(--border); }
.menu-list .row .right svg { color: var(--muted); }
.value-line { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.value-line:last-child { border-bottom: none; }
.value-line .k { color: var(--muted); font-weight: 600; }
.value-line .v { font-weight: 600; text-align: right; }
.section-link { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-link h2 { margin: 0; }
.section-link a { font-size: 13.5px; font-weight: 700; cursor: pointer; }
.skel { background: linear-gradient(90deg, var(--gray-soft) 25%, #f5f6f8 50%, var(--gray-soft) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.diff-pos { color: var(--primary); font-weight: 700; }
.diff-neg { color: var(--red); font-weight: 700; }
input.count-input { width: 86px; min-height: 42px; text-align: right; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 16px; }
