:root {
  color-scheme: light;
  --bg: oklch(97% 0.006 85);
  --surface: oklch(100% 0 0);
  --surface-muted: oklch(96% 0.012 75);
  --fg: oklch(20% 0.02 60);
  --muted: oklch(50% 0.02 60);
  --muted-2: oklch(58% 0.02 60);
  --border: oklch(90% 0.014 75);
  --accent: oklch(66% 0.15 45);
  --accent-strong: oklch(58% 0.17 45);
  --accent-wash: oklch(95% 0.03 45);
  --danger: oklch(50% 0.18 25);
  --danger-wash: oklch(94% 0.045 25);
  --dark: oklch(30% 0.02 60);
  --ok-fg: oklch(40% 0.13 145);
  --ok-bg: oklch(95% 0.05 145);
  --warn-fg: oklch(45% 0.14 85);
  --warn-bg: oklch(93% 0.06 85);
  --muted-fg: oklch(45% 0.01 60);
  --muted-bg: oklch(92% 0.01 75);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--fg);
}

#app { max-width: 640px; margin: 0 auto; padding: 1.1rem 1rem 3rem; }

h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0.9rem 0 0.4rem;
}

h2 {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--dark);
  margin: 1.4rem 0 0.6rem;
}

p { color: var(--muted); line-height: 1.5; }

a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { color: var(--accent-strong); }

nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

nav a, .chip {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
}

nav a:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 110px;
  box-shadow: 0 12px 24px -12px oklch(20% 0.02 60 / 0.3);
  z-index: 5;
}

.export-menu[hidden] { display: none; }

.export-menu a {
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

.export-menu a:hover { background: var(--surface-muted); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.stat-tile {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0.6rem 0.3rem;
  text-align: center;
  cursor: pointer;
}

.stat-tile.active {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.1rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
}

.card-row {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.card-row:hover { border-color: var(--accent); }

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface-muted);
  color: var(--muted);
}

.card-body { flex: 1; min-width: 0; }

.card-title {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.65rem 1.1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: var(--accent-strong); }

button.danger { background: var(--dark); }
button.danger:hover { background: var(--fg); }

button.warn {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger-wash);
}
button.warn:hover { background: var(--danger-wash); }

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.6rem;
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--fg);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

::placeholder { color: var(--muted-2); }

.status-verfuegbar, .status-verliehen, .status-defekt, .status-ausgebucht, .status-werkstatt, .status-ausgemustert {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-verfuegbar { color: var(--ok-fg); background: var(--ok-bg); }
.status-verliehen { color: var(--warn-fg); background: var(--warn-bg); }
.status-defekt { color: var(--danger); background: var(--danger-wash); }
.status-ausgebucht { color: var(--muted-fg); background: var(--muted-bg); }
.status-werkstatt { color: var(--warn-fg); background: var(--warn-bg); }
.status-ausgemustert { color: var(--muted-fg); background: var(--muted-bg); }

.qty-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.qty-btn.qty-in { background: var(--ok-fg); }
.qty-btn.qty-out { background: var(--danger); }

.qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  margin-right: 0.4rem;
  vertical-align: middle;
  flex: none;
}
.qty-badge.qty-in { background: var(--ok-fg); }
.qty-badge.qty-out { background: var(--danger); }

ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }

li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
}

.row-with-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.row-wrap { flex-wrap: wrap; }

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.edit-form-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 8px;
  flex: none;
}

#toast-root {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  z-index: 10;
}

#toast-root .card {
  cursor: default;
  max-width: 320px;
  box-shadow: 0 12px 24px -12px oklch(20% 0.02 60 / 0.25);
}
