*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── AITwork Design System v2 ────────────────────────── */
  --bg:            #F8FAFC;
  --bg-card:       #FFFFFF;
  --bg-hover:      #F8FAFC;

  --nav-bg:        #FFFFFF;
  --nav-border:    #E2E8F0;
  --nav-text:      #64748B;
  --nav-active:    #2563EB;
  --nav-active-bg: #EFF6FF;

  --accent:        #2563EB;
  --accent-dark:   #1D4ED8;
  --accent-soft:   #EFF6FF;
  --accent-ring:   rgba(37,99,235,0.15);

  --text-1:        #0F172A;
  --text-2:        #475569;
  --text-3:        #94A3B8;
  --text-4:        #CBD5E1;

  --border:        #E2E8F0;
  --border-input:  #CBD5E1;

  --shadow-xs:     0 1px 2px rgba(15,23,42,.04);
  --shadow:        0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:     0 4px 16px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:     0 8px 32px rgba(15,23,42,.10);

  --radius:        8px;
  --radius-sm:     6px;
  --radius-lg:     12px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
[x-cloak] { display: none !important; }

html { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100%;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typographie ──────────────────────────────────────────── */
.t-display  { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; color: var(--text-1); }
.t-title    { font-size: 1.25rem;  font-weight: 600; letter-spacing: -0.01em; color: var(--text-1); }
.t-label    { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.t-mono     { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 0.875rem; font-weight: 600; color: var(--text-1); }
.card-body { padding: 20px; }

/* ── KPI Card ─────────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.kpi-card:hover::after { opacity: 1; }
.kpi-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; margin-bottom: 4px; font-variant-numeric: tabular-nums; color: var(--text-1); }
.kpi-label { font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.kpi-sub   { font-size: 0.75rem; color: var(--text-3); margin-top: 6px; }

/* ── Sidebar Desktop ──────────────────────────────────────── */
.sidebar-desktop {
  width: 228px;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 18px 20px;
  border-bottom: 1px solid var(--nav-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar-logo-text { font-size: 0.875rem; font-weight: 700; color: var(--text-1); letter-spacing: -0.01em; }
.sidebar-logo-sub  { font-size: 0.625rem; color: var(--text-3); margin-top: 1px; letter-spacing: 0.02em; }

.nav-section {
  padding: 16px 12px 4px;
}
.nav-section-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 0 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--nav-text);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  border: none; background: none; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg); color: var(--text-1); }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active); font-weight: 600; }
.nav-item-icon { font-size: 0.9375rem; width: 18px; text-align: center; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .nav-item-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 2px 6px;
  min-width: 16px;
  text-align: center;
}

.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--nav-border);
}
.sidebar-user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-user-card:hover { background: var(--bg); }
.sidebar-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 0.8125rem; font-weight: 600; color: var(--text-1); }
.sidebar-user-role { font-size: 0.6875rem; color: var(--text-3); text-transform: capitalize; }

/* ── Mobile Header ────────────────────────────────────────── */
.mobile-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.mobile-header-title { font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text-1); }

/* ── Mobile Bottom Nav ────────────────────────────────────── */
.mobile-nav {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px 8px;
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s;
  border: none; background: none; gap: 3px;
}
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item-icon { font-size: 1.25rem; line-height: 1; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--bg); border-color: var(--border-input); color: var(--text-1); }

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-2);
  transition: all 0.15s;
  font-size: 0.8125rem;
}
.btn-icon:hover { background: var(--bg); border-color: var(--border-input); color: var(--text-1); }
.btn-icon.danger:hover { background: #FEF2F2; border-color: #FECACA; color: #DC2626; }

/* ── Form Controls ────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 0.875rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: var(--text-4); }

select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A3B8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  appearance: none;
  cursor: pointer;
}

.input-label { font-size: 0.75rem; font-weight: 500; color: var(--text-2); margin-bottom: 4px; display: block; }

/* ── Status Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.6875rem; font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-gray   { background: #F1F5F9; color: #64748B; }
.badge-blue   { background: #EFF6FF; color: #2563EB; }
.badge-indigo { background: #EEF2FF; color: #4338CA; }
.badge-green  { background: #F0FDF4; color: #15803D; }
.badge-orange { background: #FFF7ED; color: #C2410C; }
.badge-teal   { background: #F0FDFA; color: #0F766E; }
.badge-purple { background: #FAF5FF; color: #7C3AED; }
.badge-red    { background: #FEF2F2; color: #DC2626; }
.badge-amber  { background: #FFFBEB; color: #B45309; }

/* ── List Items ───────────────────────────────────────────── */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  background: var(--bg-card);
  text-decoration: none;
  color: inherit;
  border-left: none; border-right: none; width: 100%; text-align: left;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-hover); }
.list-item-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9375rem;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}
.list-item-title { font-size: 0.875rem; font-weight: 500; color: var(--text-1); }
.list-item-sub   { font-size: 0.75rem; color: var(--text-3); margin-top: 1px; }

/* ── Section Header ───────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ── Flash / Toast ────────────────────────────────────────── */
.toast {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  background: var(--text-1);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.8125rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  max-width: 320px;
}
.toast::before { content: '✓'; font-size: 0.875rem; color: #4ADE80; flex-shrink: 0; }

/* ── Page Container ───────────────────────────────────────── */
.page { padding: 24px; }
.space-y-4 > * + * { margin-top: 16px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-2 > * + * { margin-top: 8px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,0.4);
  display: flex; align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) {
  .modal-box { border-radius: var(--radius-lg); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.modal-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-1); }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none; background: var(--bg);
  color: var(--text-3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text-1); }
.modal-body { padding: 20px; }

/* ── Grid Utilities ───────────────────────────────────────── */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ── Offline Banner ───────────────────────────────────────── */
.offline-banner {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
  background: #FEF3C7; border: 1px solid #FCD34D; color: #92400E;
  border-radius: var(--radius); padding: 8px 16px;
  font-size: 0.75rem; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow-md);
  z-index: 90;
  white-space: nowrap;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1023px) {
  .hidden { display: none !important; }
  .page { padding: 16px; }
}
@media (min-width: 1024px) {
  .lg\:flex { display: flex !important; }
  .lg\:hidden { display: none !important; }
  .lg\:pt-0 { padding-top: 0 !important; }
  .lg\:pb-0 { padding-bottom: 0 !important; }
}
.pb-20 { padding-bottom: 80px; }
.pt-14 { padding-top: 56px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-col { flex-direction: column; }
.h-screen { height: 100vh; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }
.w-full { width: 100%; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-auto { margin-top: auto; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-gray-400 { color: var(--text-3); }
.text-gray-500 { color: var(--text-2); }
.text-gray-600 { color: var(--text-2); }
.text-gray-700 { color: var(--text-2); }
.text-gray-900 { color: var(--text-1); }
.text-red-600 { color: #DC2626; }
.text-green-600 { color: #16A34A; }
.text-blue-600 { color: #2563EB; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.rounded-full { border-radius: 9999px; }
.rounded-xl { border-radius: 12px; }
.rounded-lg { border-radius: 8px; }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }
.absolute { position: absolute; }
.inset-0 { inset: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }
.select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }
.opacity-50 { opacity: 0.5; }
.transition { transition: all 0.15s; }
.w-5 { width: 20px; }
.h-5 { height: 20px; }
.w-4 { width: 16px; }
.h-4 { height: 16px; }
.stroke-current { stroke: currentColor; }
fill-none { fill: none; }
/* Plantafel + Pipeline: Vollbild-Container */
.plantafel-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  overflow: hidden;
}
@media (min-width: 1024px) {
  .plantafel-container {
    height: 100vh;
  }
}
