/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-300:      #cbd5e1;
  --gray-500:      #64748b;
  --gray-700:      #334155;
  --gray-900:      #0f172a;
  --white:         #ffffff;
  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     16px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --nav-h:         64px;
  --bottom-h:      80px;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Typography ────────────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem;  font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; font-weight: 600; }
p  { color: var(--gray-700); }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--nav-h) 0 calc(var(--bottom-h) + 24px);
  min-height: 100vh;
}
.page-wrap--wide { max-width: 960px; }
.inner { padding: 0 16px; }

/* ─── Top Navigation ─────────────────────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topnav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
}
.topnav__brand img { height: 32px; width: auto; }
.topnav__actions { display: flex; align-items: center; gap: 8px; }

/* ─── Bottom Navigation ──────────────────────────────────────────────────────── */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.bottomnav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  text-decoration: none;
  font-size: .7rem;
  font-weight: 500;
  min-width: 60px;
  transition: color .15s, background .15s;
}
.bottomnav__item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.bottomnav__item.active,
.bottomnav__item:hover { color: var(--primary); }
.bottomnav__item.active { background: var(--primary-light); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: 12px; }
.card__header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card__body  { padding: 16px 20px; }
.card__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  height: 48px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn--primary  { background: var(--primary);  color: var(--white); box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn--primary:hover { background: var(--primary-dark); }
.btn--success  { background: var(--success);  color: var(--white); }
.btn--danger   { background: var(--danger);   color: var(--white); }
.btn--ghost    { background: transparent; color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn--ghost:hover { background: var(--gray-100); }
.btn--sm { height: 38px; padding: 0 14px; font-size: .85rem; }
.btn--full { width: 100%; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ─── Sticky Button Bar ─────────────────────────────────────────────────────── */
.sticky-bar {
  position: fixed;
  bottom: var(--bottom-h);
  left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  z-index: 90;
  box-shadow: 0 -4px 12px rgba(0,0,0,.06);
}
.sticky-bar .btn { flex: 1; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-control::placeholder { color: var(--gray-300); }
textarea.form-control { height: auto; padding: 14px 16px; resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .8rem; color: var(--gray-500); margin-top: 4px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Checkbox & Toggle ─────────────────────────────────────────────────────── */
.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.checkbox-wrap input[type=checkbox] {
  width: 22px; height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Stepper ────────────────────────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.step {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.step__dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  background: var(--gray-200);
  color: var(--gray-500);
  border: 2px solid transparent;
  transition: all .2s;
}
.step.done  .step__dot { background: var(--success); color: var(--white); }
.step.active .step__dot { background: var(--primary); color: var(--white); box-shadow: 0 0 0 3px var(--primary-light); }
.step__line {
  height: 2px;
  width: 32px;
  background: var(--gray-200);
  flex-shrink: 0;
}
.step.done + .step .step__line,
.step.done .step__line { background: var(--success); }

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert--success { background: var(--success-light); color: #14532d; }
.alert--error   { background: var(--danger-light);  color: #7f1d1d; }
.alert--warning { background: var(--warning-light); color: #78350f; }
.alert--info    { background: var(--primary-light); color: #1e3a8a; }

/* ─── Stats Cards ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.stat-card__value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-card__label { font-size: .75rem; color: var(--gray-500); margin-top: 4px; font-weight: 500; }

/* ─── List Items ─────────────────────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--gray-50); }
.list-item:active { background: var(--gray-100); }
.list-item__icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.list-item__icon svg { width: 20px; height: 20px; }
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item__sub   { font-size: .8rem; color: var(--gray-500); margin-top: 1px; }
.list-item__arrow { color: var(--gray-300); flex-shrink: 0; }
.list-item__arrow svg { width: 18px; height: 18px; }

/* ─── Badge ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.6;
}
.badge--success { background: var(--success-light); color: #14532d; }
.badge--warning { background: var(--warning-light); color: #78350f; }
.badge--danger  { background: var(--danger-light);  color: #7f1d1d; }
.badge--gray    { background: var(--gray-100);       color: var(--gray-700); }
.badge--blue    { background: var(--primary-light);  color: #1e3a8a; }

/* ─── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
  padding: 20px 16px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.page-header h1 { flex: 1; }

/* ─── Section Header ─────────────────────────────────────────────────────────── */
.section-head {
  padding: 20px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-head h2 { font-size: 1rem; color: var(--gray-700); font-weight: 600; }

/* ─── Result Row ─────────────────────────────────────────────────────────────── */
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.result-row:last-child { border-bottom: none; }
.result-row__label { font-size: .9rem; color: var(--gray-700); }
.result-row__value { font-size: .95rem; font-weight: 700; color: var(--primary); }
.result-row--total { background: var(--primary-light); }
.result-row--total .result-row__label { font-weight: 700; color: var(--primary-dark); }
.result-row--total .result-row__value { font-size: 1.1rem; color: var(--primary-dark); }

/* ─── Sketch ─────────────────────────────────────────────────────────────────── */
.sketch-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  margin-bottom: 12px;
}

/* ─── Divider ────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-200); margin: 8px 0; }

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}
.empty svg { width: 48px; height: 48px; color: var(--gray-300); }
.empty h3  { color: var(--gray-700); }
.empty p   { font-size: .9rem; }

/* ─── Formula Field ──────────────────────────────────────────────────────────── */
.formula-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary-light);
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius-sm);
  gap: 8px;
}
.formula-result__label { font-size: .85rem; color: var(--primary-dark); font-weight: 500; }
.formula-result__value { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); }
.formula-result__unit  { font-size: .85rem; color: var(--primary); }

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}
.login-logo img { height: 56px; width: auto; }
.login-logo span { font-size: 1.4rem; font-weight: 800; color: var(--primary); letter-spacing: -.02em; }

/* ─── Admin Table ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: 10px 16px; font-size: .75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.mt-4  { margin-top:  4px; }
.mt-8  { margin-top:  8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-sm   { font-size: .85rem; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.font-bold  { font-weight: 700; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ─── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeIn .25s ease both; }

/* ─── Desktop / Tablet Top Nav ──────────────────────────────────────────────── */
.topnav__nav {
  display: none;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 0 16px;
}
.topnav__nav-link {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--gray-700);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.topnav__nav-link:hover { background: var(--gray-100); color: var(--primary); }
.topnav__nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* Admin Dropdown */
.topnav__admin-menu { position: relative; }
.topnav__admin-label { display: none; }
.topnav__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
}
.topnav__dropdown.open { display: block; }
.topnav__dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: .9rem;
  transition: background .1s;
  border-bottom: 1px solid var(--gray-100);
}
.topnav__dropdown-item:last-child { border-bottom: none; }
.topnav__dropdown-item:hover { background: var(--gray-50); color: var(--primary); }
.topnav__dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--gray-500); }

/* ─── Lightbox ───────────────────────────────────────────────────────────────── */
.sketch-img { cursor: zoom-in; }
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
  animation: fadeIn .18s ease;
}
.lightbox-overlay img {
  max-width: 100%;
  max-height: 90dvh;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  cursor: default;
  touch-action: pinch-zoom;
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ─── Foto-Grid & Upload ─────────────────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.photo-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.photo-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  margin: 0;
  border-radius: 0;
  border: none;
  max-height: none;
}
.photo-caption {
  font-size: .75rem;
  color: var(--gray-700);
  padding: 6px 8px;
  background: var(--white);
  line-height: 1.3;
}
.photo-delete {
  position: absolute;
  top: 6px;
  right: 6px;
}
.photo-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background .15s;
}
.photo-delete-btn:hover { background: var(--danger); }
.photo-delete-btn svg { width: 14px; height: 14px; }

.photo-upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--white);
  transition: border-color .2s, background .2s;
}
.photo-upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-upload-zone #uploadPrompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--gray-500);
  font-size: .9rem;
}
.photo-upload-zone #uploadPrompt svg { width: 36px; height: 36px; color: var(--gray-300); }

/* ─── KI-Zusammenfassung ─────────────────────────────────────────────────────── */
.ai-summary-text {
  font-size: .95rem;
  line-height: 1.7;
  color: var(--gray-900);
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 3px solid var(--primary);
  padding: 14px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ─── Spin Animation ─────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .inner { padding: 0 24px; }
  .page-header { padding: 24px 24px 0; }
  .section-head { padding: 24px 24px 8px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .photo-thumb { height: 150px; }
}

@media (min-width: 768px) {
  .bottomnav { display: none; }
  .page-wrap { padding-bottom: 40px; max-width: 860px; }
  .page-wrap--wide { max-width: 1040px; }
  .sticky-bar { bottom: 0; max-width: 860px; left: 0; right: 0; margin: 0 auto; transform: none; border-radius: var(--radius) var(--radius) 0 0; }
  .topnav { padding: 0 24px; }
  .topnav__nav { display: flex; }
  .topnav__admin-label { display: inline; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .photo-thumb { height: 170px; }
}

@media (min-width: 1024px) {
  .page-wrap { max-width: 920px; }
  .page-wrap--wide { max-width: 1200px; }
  .stats-grid { gap: 20px; }
  .stat-card__value { font-size: 2.5rem; }
}

@media (max-width: 400px) {
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
}
