:root {
  --forest: #1e3a1e;
  --forest-mid: #2d5a27;
  --forest-light: #4a7c3f;
  --bark: #5c3d1e;
  --bark-light: #8b6340;
  --earth: #f5f0e8;
  --earth-dark: #e8dcc8;
  --leaf: #7ab648;
  --fog: #f8f6f2;
  --text: #1a1a18;
  --text-muted: #6b6b5e;
  --danger: #c0392b;
  --warning: #e67e22;
  --card-shadow: 0 2px 12px rgba(30,58,30,0.10);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  background: var(--fog);
  color: var(--text);
  overflow: hidden;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Loading */
.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100dvh; gap: 12px;
  background: var(--forest);
}
.loading-mark { font-size: 48px; animation: pulse 1.5s ease-in-out infinite; }
.loading-text {
  font-family: 'Playfair Display', serif;
  font-size: 24px; color: var(--earth); letter-spacing: 3px;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Header */
.app-header {
  background: var(--forest);
  color: white;
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.header-logo {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  letter-spacing: 1px;
  flex: 1;
}
.header-logo span { color: var(--leaf); }
.header-user {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  display: flex; align-items: center; gap: 8px;
}
.header-revier-badge {
  background: var(--forest-mid);
  border: 1px solid var(--forest-light);
  color: var(--earth);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}

/* Main content area */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
}

/* Bottom navigation */
.app-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--earth-dark);
  display: flex;
  z-index: 20;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; color: var(--text-muted); transition: color 0.15s;
  border: none; background: none; padding: 0; -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--forest-mid); }
.nav-item:active { opacity: 0.7; }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; letter-spacing: 0.3px; }

/* Pages */
.page { padding: 16px; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 700;
  color: var(--forest);
  margin-bottom: 16px;
}
.page-subtitle {
  font-size: 13px; color: var(--text-muted);
  margin-top: -10px; margin-bottom: 16px;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 8px;
}

/* Erlegung list item */
.erlegung-item {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; gap: 14px; align-items: flex-start;
  cursor: pointer; transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.erlegung-item:active { transform: scale(0.98); }
.erlegung-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.icon-reh { background: #e8f4e0; }
.icon-schwarz { background: #f0e8e0; }
.erlegung-main { flex: 1; min-width: 0; }
.erlegung-title { font-size: 15px; font-weight: 600; color: var(--text); }
.erlegung-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.erlegung-date {
  font-size: 12px; color: var(--text-muted);
  flex-shrink: 0; text-align: right;
}
.tag {
  display: inline-block;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
  margin-top: 4px;
}
.tag-m { background: #dbeafe; color: #1e40af; }
.tag-w { background: #fce7f3; color: #9d174d; }
.tag-revier { background: var(--earth); color: var(--forest); margin-left: 4px; }

/* Form styles */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--earth-dark);
  border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit;
  color: var(--text); background: white;
  appearance: none; -webkit-appearance: none;
  transition: border-color 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--forest-mid); }
.form-control:disabled { background: var(--fog); color: var(--text-muted); }

select.form-control {
  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 d='M1 1l5 5 5-5' stroke='%236b6b5e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: inherit;
  border: none; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  width: 100%; text-align: center;
}
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn-primary { background: var(--forest-mid); color: white; }
.btn-secondary { background: var(--earth); color: var(--forest); }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
  background: transparent; color: var(--forest-mid);
  border: 1.5px solid var(--forest-mid);
}
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 8px; }

/* Gender selector */
.gender-select {
  display: flex; gap: 10px;
}
.gender-btn {
  flex: 1; padding: 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--earth-dark);
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: white; color: var(--text-muted);
  transition: all 0.15s; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.gender-btn.selected-m { border-color: #3b82f6; background: #dbeafe; color: #1e40af; }
.gender-btn.selected-w { border-color: #ec4899; background: #fce7f3; color: #9d174d; }

/* Filter bar */
.filter-bar {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 0 16px 12px 16px;
  scrollbar-width: none; -ms-overflow-style: none;
  margin: 0 -16px;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 6px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--earth-dark);
  background: white; color: var(--text-muted);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}
.filter-chip.active { background: var(--forest); color: white; border-color: var(--forest); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--card-shadow); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-family: 'Playfair Display', serif; font-size: 32px; font-weight: 700; color: var(--forest); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-card.accent { background: var(--forest); }
.stat-card.accent .stat-num { color: var(--leaf); }
.stat-card.accent .stat-label { color: rgba(255,255,255,0.7); }

/* FAB */
.fab {
  position: fixed; right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px;
  background: var(--forest-mid);
  color: white; font-size: 26px;
  border: none; border-radius: 50%;
  box-shadow: 0 4px 16px rgba(45,90,39,0.4);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 15; -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.92); }

/* Modal / Sheet */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100; display: flex; align-items: flex-end;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  background: white; width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 0 0 calc(20px + var(--safe-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: sheetUp 0.25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
  width: 36px; height: 4px; background: var(--earth-dark);
  border-radius: 2px; margin: 12px auto 0;
}
.modal-header {
  padding: 16px 20px;
  font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 700; color: var(--forest);
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--earth-dark);
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--fog); border: none; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.modal-body { padding: 20px; }

/* Export section */
.export-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--card-shadow); padding: 16px;
  margin-bottom: 12px;
}
.export-title {
  font-weight: 600; font-size: 15px; margin-bottom: 4px;
}
.export-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.export-buttons { display: flex; gap: 8px; }

/* Empty state */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 15px; }

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  background: var(--forest); color: white;
  padding: 10px 20px; border-radius: 20px;
  font-size: 14px; font-weight: 500;
  z-index: 200; white-space: nowrap;
  animation: toastIn 0.25s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Section header */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Divider */
.divider { height: 1px; background: var(--earth-dark); margin: 16px 0; }

/* Spinner */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--earth-dark);
  border-top-color: var(--forest-mid); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin section */
.admin-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--earth-dark);
}
.admin-row:last-child { border-bottom: none; }
