/* =============================================================
   Design tokens — mandantenfähig via ?t=slug (API) oder URL-Parameter
   ============================================================= */

:root {
  /* Palette — cool off-white + deep ink */
  --bg: oklch(0.99 0.003 250);
  --bg-elev: oklch(1 0 0);
  --bg-sunk: oklch(0.965 0.005 250);
  --border: oklch(0.91 0.006 250);
  --border-strong: oklch(0.82 0.008 250);
  --ink: oklch(0.22 0.01 260);
  --ink-2: oklch(0.42 0.012 260);
  --ink-3: oklch(0.62 0.012 260);
  --ink-4: oklch(0.76 0.01 260);

  /* Accent — overridable via API oder ?accent=H,C oder L,C,H */
  --accent-h: 130;
  --accent-c: 0.20;
  --accent-l: 0.62;
  --accent: oklch(var(--accent-l) var(--accent-c) var(--accent-h));
  --accent-ink: oklch(0.45 0.15 var(--accent-h));
  --accent-soft: oklch(0.97 0.02 var(--accent-h));
  /* Automatischer Kontrast: L < 0.78 → heller Text, L ≥ 0.78 → dunkler Text */
  --_con: clamp(0, calc((0.78 - var(--accent-l)) * 9999), 1);
  --accent-on-base: oklch(calc(0.12 + var(--_con) * 0.88) 0.01 var(--accent-h));
  --accent-on: var(--accent-on-force, var(--accent-on-base));

  /* Feedback */
  --success: oklch(0.62 0.11 155);
  --danger:  oklch(0.58 0.17 25);

  /* Typography */
  --font-display: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --font-body:    "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-num:     "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
  --fs-base: 16px;

  /* Radii + shadows */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.04), 0 1px 1px oklch(0 0 0 / 0.03);
  --shadow-2: 0 8px 24px oklch(0 0 0 / 0.06), 0 2px 6px oklch(0 0 0 / 0.04);
  --shadow-pop: 0 20px 50px oklch(0 0 0 / 0.10), 0 6px 16px oklch(0 0 0 / 0.06);
}

:root[data-mode="dark"] {
  --bg: oklch(0.18 0.01 260);
  --bg-elev: oklch(0.22 0.012 260);
  --bg-sunk: oklch(0.15 0.01 260);
  --border: oklch(0.30 0.012 260);
  --border-strong: oklch(0.42 0.014 260);
  --ink: oklch(0.96 0.005 85);
  --ink-2: oklch(0.82 0.008 85);
  --ink-3: oklch(0.62 0.01 260);
  --ink-4: oklch(0.45 0.012 260);
  --accent: oklch(var(--accent-l) var(--accent-c) var(--accent-h));
  --accent-ink: oklch(calc(var(--accent-l) + 0.10) var(--accent-c) var(--accent-h));
  --accent-soft: oklch(0.30 0.04 var(--accent-h));
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-2: 0 8px 24px oklch(0 0 0 / 0.35);
  --shadow-pop: 0 20px 50px oklch(0 0 0 / 0.5);
}

/* ------- App shell ------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Mobile app container */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  position: relative;
  font-size: var(--fs-base);
}

/* App bar (top) */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 14px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.appbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  flex: 1; min-width: 0;
}
.appbar .brand .logo-dot {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--accent-on);
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.appbar .brand .logo-img { height: 22px; width: auto; display: block; }
.appbar button.icon-btn {
  border: 0; background: transparent; color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center;
}
.appbar button.icon-btn:hover { background: var(--bg-sunk); color: var(--ink); }

/* Progress */
.progress-wrap { padding: 10px 18px 12px; background: var(--bg); }
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--ink-3);
  margin-bottom: 6px; letter-spacing: 0.02em;
}
.progress-track {
  height: 6px; background: var(--bg-sunk);
  border-radius: 999px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(.2,.8,.2,1);
}

/* Scroll area */
.scroll {
  flex: 1; overflow-y: auto;
  padding: 22px 18px 120px;
  -webkit-overflow-scrolling: touch;
}
.scroll.no-pad-bottom { padding-bottom: 22px; }

/* Step title */
.step-eyebrow {
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px; font-weight: 500;
}
.step-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.65rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 6px;
  text-wrap: pretty;
}
.step-sub {
  color: var(--ink-2);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 22px;
}

/* Form blocks */
.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.005em;
}
.field-label .req { color: var(--accent-ink); margin-left: 2px; }
.field-hint {
  font-size: 0.78rem; color: var(--ink-3);
  margin-top: 6px;
}

/* Text inputs */
.input, .textarea, .select {
  width: 100%;
  font: inherit; font-size: 1rem;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.textarea { resize: vertical; min-height: 110px; padding: 16px 18px; border-radius: var(--r-lg); }

/* Suffix (units) */
.input-group {
  position: relative;
}
.input-group .suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); font-size: 0.9rem; pointer-events: none;
}
.input-group .input { padding-right: 58px; }

/* Option cards (checkbox / radio look) */
.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.options.one-col { grid-template-columns: 1fr; }
.option {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s, transform .06s;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.3;
  min-height: 52px;
}
.option:active { transform: scale(0.99); }
.option .mark {
  width: 22px; height: 22px; border-radius: 7px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  display: grid; place-items: center; flex-shrink: 0;
  transition: all .15s;
}
.option.radio .mark { border-radius: 999px; }
.option .mark svg { opacity: 0; transition: opacity .12s; }
.option.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.option.selected .mark {
  background: var(--accent);
  border-color: var(--accent);
}
.option.selected .mark svg { opacity: 1; }
.option.selected .mark svg * { stroke: var(--accent-on); }

/* Radio "pill" variant (small options like Ja/Nein) */
.pills {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.pill {
  flex: 1; min-width: 80px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--r-md);
  text-align: center;
  font-size: 0.95rem; color: var(--ink);
  cursor: pointer;
  transition: all .15s;
  white-space: normal; word-break: break-word; line-height: 1.3;
}
.pills-grid { display: grid; gap: 8px; }
.pills-grid .pill { flex: none; min-width: 0; }
.pill.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

/* Card section divider */
.section-head {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 26px 0 12px;
}
.section-head:first-child { margin-top: 0; }

/* Info callout */
.callout {
  display: flex; gap: 10px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: var(--r-md);
  color: var(--accent-ink);
  font-size: 0.85rem;
  line-height: 1.45;
  margin-bottom: 16px;
}
.callout .ico {
  flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px;
}

/* Bottom action bar */
.actionbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
  z-index: 15;
}
.btn {
  font: inherit; font-size: 1rem; font-weight: 500;
  padding: 14px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, transform .06s, box-shadow .15s, border-color .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px;
}
.btn:active { transform: scale(0.985); }
.btn-primary {
  background: var(--accent); color: var(--accent-on);
  flex: 1;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-sunk); color: var(--ink); }
.btn-icon { padding: 14px; min-width: 50px; }

/* Photo upload tiles */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border-strong);
  background: var(--bg-sunk);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 10px; text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.photo-tile:hover { border-color: var(--accent); }
.photo-tile .icn {
  width: 26px; height: 26px; color: var(--ink-3);
}
.photo-tile .lbl {
  font-size: 0.78rem; color: var(--ink-2);
  line-height: 1.25;
}
.photo-tile.filled { border-style: solid; border-color: var(--accent); background: transparent; }
.photo-tile.filled img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.photo-tile.filled .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, oklch(0 0 0 / 0.55), transparent 50%);
  display: flex; align-items: flex-end; padding: 8px;
  color: white; font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.01em;
}
.photo-tile.filled .remove {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 999px;
  background: oklch(0 0 0 / 0.55); color: white;
  border: 0; cursor: pointer;
  display: grid; place-items: center;
}

/* Summary cards */
.summary-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.summary-card .head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.summary-card .head h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500; font-size: 0.95rem;
}
.summary-card .head .edit {
  background: transparent; border: 0; color: var(--accent-ink);
  font: inherit; font-size: 0.82rem; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
}
.summary-card .edit:hover { background: var(--accent-soft); }
.summary-card dl {
  margin: 0; display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  font-size: 0.85rem;
}
.summary-card dt { color: var(--ink-3); font-weight: 400; }
.summary-card dd { margin: 0; color: var(--ink); text-align: right; }

/* Photo thumbnails in summary */
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 2px; }
.photo-thumb  { width: 58px; height: 58px; object-fit: cover; border-radius: 8px;
                border: 1px solid var(--border); }

/* Submit error */
.submit-error {
  margin: 0 18px 10px;
  padding: 12px 14px;
  background: oklch(0.97 0.02 25);
  border: 1px solid oklch(0.85 0.06 25);
  border-radius: var(--r-md);
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Home/entry screen */
.entry {
  padding: 24px 18px 0; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.entry-brand-bar {
  display: flex; align-items: center;
  margin-bottom: 14px;
}
.entry-scroll {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}
.entry-footer {
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.entry-hero {
  border-radius: 14px;
  aspect-ratio: 16 / 10;
  min-height: 140px;
  background:
    linear-gradient(135deg,
      color-mix(in oklab, var(--accent) 25%, var(--bg-sunk)),
      var(--bg-sunk));
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.entry-hero .hero-slide {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease-in-out;
}
.entry-hero .hero-slide--active { opacity: 1; }
.entry-hero .hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.greeting-eyebrow {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-ink);
  letter-spacing: -0.005em;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.greeting-eyebrow .kundennr {
  color: var(--ink-3);
  font-weight: 400;
  font-size: 0.78rem;
}
.entry h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  text-wrap: pretty;
}
.entry p.lede {
  color: var(--ink-2);
  font-size: 0.98rem;
  line-height: 1.5;
  margin: 0 0 24px;
}
.entry-tiles { display: grid; gap: 8px; margin-bottom: 10px; }
.entry-tile {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all .18s;
  text-align: left; color: var(--ink);
  font: inherit;
  position: relative;
}
.entry-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.entry-tile.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.entry-tile .tile-ico {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--border-strong);
  color: white;
  transition: background .18s, color .18s;
  display: grid; place-items: center;
}
.entry-tile:hover .tile-ico {
  background: var(--ink-4);
  color: white;
}
.entry-tile.selected .tile-ico {
  background: var(--accent); color: var(--accent-on);
}
.entry-tile .tile-text .t { font-weight: 500; font-size: 0.92rem; letter-spacing: -0.01em; }
.entry-tile .tile-text .s { color: var(--ink-3); font-size: 0.76rem; margin-top: 2px; }
.entry-tile .tile-check {
  width: 24px; height: 24px; border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  transition: all .15s;
}
.entry-tile.selected .tile-check {
  background: var(--accent); border-color: var(--accent); color: var(--accent-on);
}
.entry-tile.selected .tile-check svg { opacity: 1; }
.entry-tile .tile-check svg { opacity: 0; }

/* Done screen */
.done-wrap {
  height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 24px 40px;
  text-align: center;
}
.done-ring {
  width: 92px; height: 92px; border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: grid; place-items: center;
  margin: 0 auto 22px;
  animation: pop .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* DSGVO Consent Block */
.consent-block {
  margin-top: 24px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--bg-sunk);
  border: 1px solid var(--border);
}
.consent-row {
  display: flex; gap: 12px; align-items: flex-start;
  cursor: pointer;
}
.consent-cb {
  flex-shrink: 0;
  width: 22px; height: 22px;
  min-width: 22px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
}
/* Setzt Klickfläche auf mind. 44×44 px via Padding auf dem Label */
.consent-row { padding: 11px; margin: -11px; border-radius: var(--r-sm); }
.consent-text {
  font-size: 0.875rem; line-height: 1.55; color: var(--ink-2);
}
.consent-link {
  color: var(--accent-ink); text-decoration: underline;
}
.consent-error .consent-cb {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
  border-radius: 3px;
}
.consent-err-msg {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--danger);
  line-height: 1.4;
}

/* Spinner (for submit loading state) */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid color-mix(in oklab, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Chevron */
.chev {
  width: 18px; height: 18px;
}

/* Hide scrollbars for clean look */
.scroll::-webkit-scrollbar { width: 0; }

/* Transitions between steps */
.step-enter {
  animation: stepIn .28s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Tenant loading / error screen */
.tenant-loading,
.tenant-error {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}
