:root {
  --blue: #2457a6;
  --blue-dark: #1b4485;
  --light: #e7eef8;
  --dark: #1c2a38;
  --bg: #f4f6f8;
  --card: #fff;
  --muted: #667380;
  --border: #d9dee4;
  --danger: #b3261e;
  --ok: #1e7b3c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--dark);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(60px + env(safe-area-inset-bottom));
}

h1 { font-size: 27px; margin: 4px 2px 10px; }
h2 { font-size: 19px; margin: 6px 0 8px; }
h3 { font-size: 15px; margin: 12px 0 4px; color: var(--blue); }
p { margin: 4px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sub { color: var(--muted); margin: -4px 2px 14px; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 6px 0 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.card > h2:first-child { margin-top: 0; }

/* ---------- Buttons ---------- */
button, .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  margin: 7px 0;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:hover { background: var(--blue-dark); }
button:disabled { opacity: .5; cursor: default; }
button.light { background: var(--light); color: var(--blue); }
button.light:hover { background: #d6e2f3; }
button.danger { background: #fbe9e7; color: var(--danger); }
button.small {
  width: auto;
  min-height: 38px;
  margin: 0;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 10px;
}
button.back { width: auto; min-height: 44px; padding: 6px 16px; margin: 0 0 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- Formulare ---------- */
label.field { display: block; margin: 10px 0 4px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=search], select {
  width: 100%;
  min-height: 52px;
  margin: 4px 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--dark);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: thin;
}
.chips button {
  flex: 0 0 auto;
  width: auto;
  min-width: 64px;
  min-height: 46px;
  margin: 0;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--light);
  color: var(--blue);
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}
.chips button.active { background: var(--blue); color: #fff; }
.chips button .count { font-size: 11px; font-weight: 500; opacity: .8; }
.chips button.empty { opacity: .45; }

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid #eef1f4;
  cursor: pointer;
}
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); flex: 0 0 auto; }
.check.indent { padding-left: 18px; }

/* ---------- Listen / Tabellen ---------- */
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 4px 4px; }
ul.bullets { margin: 2px 0; padding-left: 22px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--light);
  color: var(--blue);
}
.badge.loaned { background: #fff3d6; color: #8a5a00; }
.badge.retired { background: #eceff1; color: var(--muted); }
.badge.inactive { background: #eceff1; color: var(--muted); }

.empty-note { color: var(--muted); padding: 6px 0; }

/* ---------- Toast & Laden ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--dark);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  z-index: 20;
}
#toast.error { background: var(--danger); }

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 246, 248, .6);
  z-index: 10;
}
#loading[hidden], #toast[hidden] { display: none; }
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Druck (Packlisten) ---------- */
@media print {
  body { background: #fff; }
  .no-print, #toast, #loading { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; padding: 0; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

.stats { text-align: center; margin-top: 14px; }
.list-row { padding: 8px 0; border-bottom: 1px solid #eef1f4; }
.edit-card { background: #f8fafc; box-shadow: inset 0 0 0 1px var(--border); }
.row.actions { justify-content: flex-end; flex-wrap: nowrap; }
.row.actions > * { flex: 0 0 auto; }
