:root {
  /* Curena-Markenfarben (Royalblau); Variablennamen historisch „teal" beibehalten */
  --teal-900: #103a8e; /* tiefes Blau */
  --teal-700: #1857d5; /* Hauptblau (Logo-Schriftzug) */
  --teal-600: #2f6be0; /* helleres Blau für Verläufe */
  --teal-100: #d7e3fb; /* heller Fokus-Ring */
  --teal-50: #eef3fd;  /* sehr helles Blau (Hintergründe) */
  --green-500: #22c55e;
  --amber-500: #f59e0b;
  --red-500: #ef4444;
  --gray-900: #1f2937;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --max-width: 640px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Header ---------- */
.app-header {
  background: var(--white);
  color: var(--gray-900);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-logo { height: 30px; width: auto; display: block; }
.icon-btn {
  border: none;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.icon-btn[hidden] { display: none; }

.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subtitle { font-size: 13px; color: var(--gray-500); font-weight: 600; }

.role-switch {
  display: flex;
  background: var(--teal-50);
  border-radius: 999px;
  padding: 3px;
}
.role-btn {
  border: none;
  background: transparent;
  color: var(--teal-700);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.role-btn.is-active { background: var(--teal-700); color: var(--white); }

/* ---------- Layout ---------- */
.view {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 16px 90px;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-700);
  margin: 4px 2px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-size: 16px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ---------- Distance / status pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-green { background: #dcfce7; color: #15803d; }
.pill-amber { background: #fef3c7; color: #b45309; }
.pill-gray  { background: var(--gray-100); color: var(--gray-500); }
.pill-red   { background: #fee2e2; color: #b91c1c; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green-500); }
.dot-amber { background: var(--amber-500); }
.dot-gray  { background: var(--gray-300); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: transform 0.05s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--teal-700); color: var(--white); }
.btn-success { background: var(--green-500); color: var(--white); }
.btn-danger  { background: var(--red-500); color: var(--white); }
.btn-ghost   { background: var(--gray-100); color: var(--gray-700); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--white);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px var(--teal-100);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ---------- Activity checklist ---------- */
.activity-list { display: flex; flex-direction: column; gap: 2px; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.activity-item:last-child { border-bottom: none; }
.activity-item input { width: 22px; height: 22px; accent-color: var(--teal-600); flex-shrink: 0; }
.activity-item .a-label { font-size: 15px; }
.activity-item .a-cat { font-size: 12px; color: var(--gray-500); }
.activity-item.checked { background: var(--teal-50); }

/* ---------- Timer ---------- */
.timer-card { text-align: center; background: linear-gradient(135deg, var(--teal-700), var(--teal-600)); color: var(--white); }
.timer-card .card-title, .timer-card .card-sub { color: var(--white); }
.timer-display { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; margin: 8px 0; }
.timer-card .card-sub { opacity: 0.9; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}
.empty .emoji { display: block; margin-bottom: 10px; }
.empty .emoji svg { width: 48px; height: 48px; fill: var(--gray-300); }

/* Inline Material-Icons (skalieren mit der Textgröße) */
.mi { width: 1.2em; height: 1.2em; fill: currentColor; vertical-align: -0.22em; flex-shrink: 0; }
.mi-rec { fill: var(--red-500); }

/* Sprachnachrichten-Liste */
.audio-row { margin-bottom: 12px; }
.audio-row:last-child { margin-bottom: 0; }
.audio-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 8px; }
.audio-label { font-size: 12px; color: var(--gray-500); font-weight: 600; }
.audio-row audio { border-radius: 10px; }

/* Login-Screen */
.login-wrap { min-height: 65vh; display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-icon { width: 64px; height: 64px; margin: 4px auto 12px; border-radius: 50%; background: var(--teal-50); display: flex; align-items: center; justify-content: center; }
.login-icon svg { width: 34px; height: 34px; fill: var(--teal-700); }
.login-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.login-sub { color: var(--gray-500); font-size: 14px; margin-bottom: 20px; }
.login-card .field { text-align: left; }
.login-hint { font-size: 12px; margin-top: 16px; }

/* Anklickbarer Kundenname in der Liste */
.cust-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.cust-open .card-title { display: flex; align-items: center; gap: 4px; }
.cust-chevron { fill: var(--gray-300); }

/* Kunden-Detailansicht */
.detail-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-row .mi { fill: var(--teal-700); margin-top: 2px; vertical-align: top; }
.detail-label { font-size: 12px; color: var(--gray-500); font-weight: 600; margin-bottom: 1px; }

.contact-card { padding: 10px 0; border-top: 1px solid var(--gray-100); }
.contact-name { font-weight: 600; font-size: 15px; }
.contact-rel { color: var(--gray-500); font-weight: 400; font-size: 13px; }
.contact-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.contact-link { display: inline-flex; align-items: center; gap: 6px; color: var(--teal-700); text-decoration: none; font-size: 14px; font-weight: 600; }

/* Kontakt-Editor (Verwaltung) */
.contact-edit { border: 1px solid var(--gray-200); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.contact-edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.contact-edit-title { font-size: 12px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: var(--max-width);
  margin: 0 auto;
}
.nav-btn {
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 14px;
  cursor: pointer;
  flex: 1;
}
.nav-btn .nav-icon { display: inline-flex; }
.nav-btn .nav-svg { width: 24px; height: 24px; display: block; }
.nav-btn.is-active { color: var(--teal-700); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red-500); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  padding: 0;
}
.modal {
  background: var(--white);
  width: 100%;
  max-width: var(--max-width);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* ---------- Misc ---------- */
.list-meta { font-size: 13px; color: var(--gray-500); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.list-meta span { display: inline-flex; align-items: center; gap: 4px; }
.divider { height: 1px; background: var(--gray-200); margin: 14px 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { background: var(--teal-50); color: var(--teal-700); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 8px; }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
}
