:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e4e9;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
}

* { box-sizing: border-box; }

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

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #12172b;
  color: white;
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  font-weight: 600;
  font-size: 16px;
  padding: 0 20px 18px;
}

.sidebar-nav { flex: 1; }

.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8b91a7;
  padding: 18px 20px 6px;
}

.nav-link {
  display: block;
  padding: 9px 20px;
  color: #d4d7e0;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-link.active {
  color: white;
  border-left-color: var(--primary);
  background: rgba(255,255,255,0.08);
  font-weight: 600;
}

.sidebar-logout { padding: 16px 20px 0; }

.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

.public-nav {
  background: #12172b;
  color: white;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.public-nav a { color: #d4d7e0; text-decoration: none; font-size: 14px; }
.public-nav a:hover, .public-nav a.active { color: white; font-weight: 600; }
.public-nav .spacer { flex: 1; }
.public-main { max-width: 700px; margin: 0 auto; padding: 20px; }

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 16px;
}
.stock-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stock-item .qty { font-weight: 600; }
.stock-category-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 16px 0 4px;
}
.stock-category-heading:first-of-type { margin-top: 0; }

main, .app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.app-main {
  flex: 1;
  min-width: 0;
  width: 100%;
}

@media (max-width: 860px) {
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: none;
    background: #12172b;
    color: white;
    font-size: 20px;
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
  }
  .sidebar-overlay.visible { display: block; }

  .app-main {
    padding: 16px;
    padding-top: 68px;
  }

  .grid.cols-2, .grid.cols-3, .grid.cols-4 {
    grid-template-columns: 1fr;
  }
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; margin-top: 12px; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button.secondary, .btn.secondary { background: #e5e7eb; color: var(--text); }
button.secondary:hover { background: #d1d5db; }
button.danger, .btn.danger { background: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.offen { background: #fef3c7; color: #92400e; }
.badge.versandbereit { background: #dbeafe; color: #1e40af; }
.badge.versendet { background: #dcfce7; color: #166534; }
.badge.storniert { background: #fee2e2; color: #991b1b; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.low-stock { color: var(--danger); font-weight: 600; }

form.inline { display: inline; }

.login-box {
  max-width: 360px;
  margin: 80px auto;
  background: white;
  padding: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.hint { background: #fffbeb; border: 1px solid #fde68a; padding: 12px 16px; border-radius: 8px; font-size: 13px; color: #92400e; margin-bottom: 16px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bar-label { width: 90px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; background: #eef0f3; border-radius: 4px; height: 18px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; }
.bar-value { width: 90px; text-align: right; font-size: 13px; flex-shrink: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.kpi-card .kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi-card .kpi-trend { font-size: 13px; margin-top: 4px; }
.kpi-card .kpi-trend.up { color: var(--success); }
.kpi-card .kpi-trend.down { color: var(--danger); }

.row-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 15px;
  text-decoration: none;
  list-style: none;
}
.icon-btn:hover { background: #f0f1f3; }
.icon-btn.danger-icon:hover { background: #fee2e2; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-details { display: inline-block; }
.icon-details[open] summary.icon-btn { background: #e5e7eb; }
.icon-details form {
  margin-top: 8px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  width: 260px;
  text-align: left;
}

.category-group { margin-bottom: 12px; }
.category-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  padding: 10px 14px;
  background: #eef0f3;
  border-radius: 8px;
  list-style: none;
}
.category-summary::-webkit-details-marker { display: none; }
.category-summary::before { content: '▸ '; }
details[open] > .category-summary::before { content: '▾ '; }

.chart-container { width: 100%; overflow-x: auto; }
.chart-svg { width: 100%; height: auto; min-width: 500px; display: block; }
.chart-axis-label { font-size: 11px; fill: var(--muted); }
.chart-bar { transition: opacity 0.15s ease; cursor: pointer; }
.chart-bar-current { fill: var(--primary); }
.chart-bar-prev { fill: #c7d2fe; }
.chart-bar-hover { opacity: 0.75; }

.chart-legend { display: flex; gap: 16px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend-current { background: var(--primary); }
.legend-prev { background: #c7d2fe; }

.chart-tooltip {
  display: none;
  position: fixed;
  background: #12172b;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

.top-product-row { margin-bottom: 14px; }
.top-product-name { font-size: 14px; margin-bottom: 4px; }

.subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.subnav-link {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav-link:hover { color: var(--text); }
.subnav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
