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

:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --warning: #ea8a00;
  --danger: #dc2626;
  --gray: #9ca3af;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}

a { color: var(--primary); text-decoration: none; }

header.app-header {
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
header.app-header h1 {
  font-size: 18px;
  font-weight: 600;
}
header.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
header.app-header .header-actions a {
  color: white;
  margin-left: 4px;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.15);
}

/* Sync-Status (Online/Pending/Offline) */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.18);
  font-size: 12px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
}
.sync-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}
.sync-status.status-green .status-dot { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.7); }
.sync-status.status-yellow .status-dot { background: #facc15; box-shadow: 0 0 6px rgba(250,204,21,0.7); animation: pulse-dot 1.4s infinite; }
.sync-status.status-red .status-dot { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.7); }
.sync-status.status-red { background: rgba(239,68,68,0.25); }
.sync-status.status-yellow { background: rgba(250,204,21,0.25); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Projekt-Karte Sync-Badge */
.sync-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}
.sync-badge.sync-pending { background: #fef3c7; color: #92400e; animation: spin 2.5s linear infinite; }
.sync-badge.sync-error { background: #fee2e2; color: #991b1b; }

/* Foto-Sync-Status-Icon im Thumbnail */
.photo-sync {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.photo-sync.ok { background: #16a34a; }
.photo-sync.pending { background: #f59e0b; animation: spin 2.5s linear infinite; }
.photo-sync.err { background: #dc2626; cursor: pointer; }
header.app-header .back-link {
  color: white;
  font-size: 22px;
  padding: 4px 10px;
  margin-right: 8px;
  border-radius: 6px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: background 0.15s;
  min-height: 44px;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #e5e7eb;
  color: #1f2937;
}
.btn-secondary:hover { background: #d1d5db; }

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover { background: #c97200; }

.btn-gray {
  background: var(--gray);
  color: white;
}
.btn-gray:hover { background: #6b7280; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 14px; min-height: 36px; }

input[type="text"], input[type="number"], input[type="password"],
input[type="date"], textarea, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: white;
}
textarea { min-height: 80px; resize: vertical; }
label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 14px;
}
.form-group { margin-bottom: 14px; }

.fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  z-index: 5;
}

/* Project list */
.project-card {
  cursor: pointer;
  position: relative;
}
.project-card h3 {
  font-size: 17px;
  margin-bottom: 4px;
}
.project-card .meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}
.project-card .progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.project-card .progress-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.3s;
}
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
}
.status-Geplant { background: #dbeafe; color: #1e40af; }
.status-In { background: #fef3c7; color: #92400e; }
.status-Abgeschlossen { background: #dcfce7; color: #166534; }

/* Checklist item */
.category-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 18px 0 8px 4px;
}
.checklist-item {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--danger);
}
.checklist-item.state-photo { border-left-color: var(--success); }
.checklist-item.state-not_possible { border-left-color: var(--warning); }
.checklist-item.state-not_necessary { border-left-color: var(--gray); }

.item-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.item-status-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.item-title {
  font-weight: 600;
  font-size: 15px;
}
.item-position {
  color: var(--text-muted);
  font-weight: 400;
}
.item-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.item-reason {
  font-size: 13px;
  color: var(--warning);
  font-style: italic;
  margin: 6px 0 8px;
  padding: 6px 10px;
  background: #fff7ed;
  border-radius: 6px;
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.thumb .thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border: none;
  padding: 0;
  min-height: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.action-row button {
  flex: 1;
  min-width: 110px;
  padding: 10px 8px;
  font-size: 13px;
  min-height: 40px;
}

/* Progress */
.overall-progress {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.overall-progress .label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}
.overall-progress .bar {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.overall-progress .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.3s;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 14px; }
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions button { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* Image lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 95vh;
  object-fit: contain;
}
.lightbox .close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.2);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}
.checkbox-row input { width: 20px; height: 20px; }
.checkbox-row label { margin: 0; cursor: pointer; flex: 1; font-size: 15px; }

.transfer-result {
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 10px;
  font-size: 14px;
}
.transfer-result.ok { background: #dcfce7; color: #166534; }
.transfer-result.err { background: #fee2e2; color: #991b1b; }

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 18px 0 10px;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 14px;
  margin-top: 8px;
}
.detail-meta .label { font-weight: 500; color: var(--text-muted); }

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

@media (max-width: 480px) {
  .action-row button { flex: 1 1 100%; }
}
