/* BMW i5 Buchung — iPhone-first, hell/dunkel */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: rgba(60, 60, 67, 0.16);
  --fill: rgba(118, 118, 128, 0.12);
  --accent: #1c69d4;
  --accent-weak: rgba(28, 105, 212, 0.12);
  --ok: #1f8a3b;
  --ok-weak: rgba(52, 199, 89, 0.16);
  --warn: #b25000;
  --warn-weak: rgba(255, 159, 10, 0.18);
  --bad: #d70015;
  --bad-weak: rgba(255, 59, 48, 0.13);
  --radius: 14px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989f;
    --faint: #6c6c70;
    --line: rgba(84, 84, 88, 0.65);
    --fill: rgba(118, 118, 128, 0.24);
    --accent: #4d94ff;
    --accent-weak: rgba(77, 148, 255, 0.18);
    --ok: #30d158;
    --ok-weak: rgba(48, 209, 88, 0.18);
    --warn: #ff9f0a;
    --warn-weak: rgba(255, 159, 10, 0.2);
    --bad: #ff453a;
    --bad-weak: rgba(255, 69, 58, 0.18);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }
p { margin: 0 0 10px; }
.icon { flex: none; vertical-align: -0.2em; }

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
}
.splash { min-height: 100vh; display: grid; place-items: center; }

/* ---------- Kopfzeile */
header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: calc(var(--safe-t) + 6px) 8px 6px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
header.top h1 { font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-side { display: flex; align-items: center; min-width: 0; }
.top-side.right { justify-content: flex-end; }
.large-title { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; padding: 0 16px 6px; }

.link-btn {
  background: none; border: 0; color: var(--accent); padding: 8px; display: inline-flex; align-items: center; gap: 2px;
  font-size: 17px;
}
.link-btn.small { font-size: 14px; padding: 8px 0 0; }
.link-btn.center { display: block; margin: 10px auto 0; }
.link-btn:disabled { color: var(--faint); }
.icon-btn {
  background: none; border: 0; color: var(--accent); width: 44px; height: 44px; display: inline-grid; place-items: center;
  border-radius: 50%;
}
.icon-btn:active { background: var(--fill); }
.plain { background: none; border: 0; padding: 0; text-align: inherit; }
.left { text-align: left; }

/* ---------- Karten & Listen */
.card {
  background: var(--card);
  border-radius: var(--radius);
  margin: 10px 16px;
  padding: 14px 16px;
}
.card.link { display: flex; gap: 10px; align-items: flex-start; color: inherit; }
.list {
  background: var(--card);
  border-radius: var(--radius);
  margin: 8px 16px;
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--line);
  color: inherit;
}
.row:last-child { border-bottom: 0; }
.row.link:active, a.row:active { background: var(--fill); }
.row-main { flex: 1; min-width: 0; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row.inactive { opacity: 0.55; }
.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 22px 32px 6px;
}
.pad { padding: 12px 16px; }
.pad-x { padding-left: 16px; padding-right: 16px; }
.stack { display: grid; gap: 10px; }
.stack.pad { padding: 12px 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-accent { color: var(--accent); }
.h2 { font-size: 19px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.note { margin: 10px 0 0; padding: 10px 12px; background: var(--fill); border-radius: 10px; white-space: pre-wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Buttons */
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 17px;
  background: var(--accent);
  color: #fff;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.btn:active { filter: brightness(0.92); }
.btn.secondary { background: var(--accent-weak); color: var(--accent); }
.btn.danger { background: var(--bad-weak); color: var(--bad); }
.btn.small { width: auto; padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.45; }
a.btn { color: #fff; }
a.btn.secondary { color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 8px; border-radius: 999px;
  background: var(--fill); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--ok-weak); color: var(--ok); }
.chip.warn { background: var(--warn-weak); color: var(--warn); }
.chip.bad { background: var(--bad-weak); color: var(--bad); }
.chip.accent { background: var(--accent-weak); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 16px; }
.chip-btn {
  border: 0; background: var(--card); color: var(--accent); font-size: 14px; font-weight: 600;
  padding: 8px 12px; border-radius: 999px;
}
.chip-btn.active { background: var(--accent); color: #fff; }

.segmented {
  display: flex; background: var(--fill); border-radius: 10px; padding: 2px; margin: 4px 16px 8px;
}
.segmented.pad-x { margin-left: 16px; margin-right: 16px; padding: 2px; }
.segmented.inline { margin: 4px 0 0; }
.segmented button {
  flex: 1; border: 0; background: none; padding: 7px 8px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text);
}
.segmented button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* ---------- Formulare */
.form { padding-bottom: 8px; }
.field { display: block; padding: 9px 16px; border-bottom: 0.5px solid var(--line); }
.list .field:last-child { border-bottom: 0; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1.4fr 1fr; border-bottom: 0.5px solid var(--line); }
.field-row .field { border-bottom: 0; }
.field-row .field + .field { border-left: 0.5px solid var(--line); }
input, select, textarea {
  font: 17px var(--font);
  color: var(--text);
  background: transparent;
  border: 0;
  width: 100%;
  padding: 4px 0;
  outline: none;
  border-radius: 0;
}
input[type="date"], input[type="time"] { min-height: 30px; -webkit-appearance: none; appearance: none; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
input:disabled { color: var(--faint); }
select { -webkit-appearance: none; appearance: none; background: transparent; }
textarea { resize: vertical; min-height: 60px; }
.card input[type="email"], .card input.code-input {
  background: var(--fill); border-radius: 10px; padding: 12px; margin: 4px 0 12px;
}
.code-input { font-size: 22px; letter-spacing: 0.12em; text-align: center; font-variant-numeric: tabular-nums; }
.inline-input { font-weight: 600; padding: 0; }
.num-input { width: 80px; text-align: right; background: var(--fill); border-radius: 8px; padding: 6px 8px; }
input[type="color"] { height: 34px; padding: 0; }
.switch {
  -webkit-appearance: none; appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--fill);
  position: relative; flex: none; transition: background 0.2s; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

/* ---------- Hinweise */
.notice { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.notice .icon { margin-top: 1px; color: var(--accent); }
.notice.warn { background: var(--warn-weak); }
.notice.warn .icon { color: var(--warn); }
.notice.bad { background: var(--bad-weak); }
.notice.bad .icon { color: var(--bad); }
.error-box { background: var(--bad-weak); color: var(--bad); }
.error-box p { margin: 0 0 8px; }
.error-box p:last-child { margin: 0; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 28px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Fahrzeugkarte */
.vehicle-card { padding: 16px; }
.vc-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.vc-left { min-width: 0; }
.vc-name { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.vc-status { margin-top: 4px; font-size: 15px; color: var(--muted); }
.status-free { color: var(--ok); font-weight: 700; }
.status-busy { color: var(--accent); font-weight: 700; }
.vc-soc { text-align: right; flex: none; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.battery { height: 10px; border-radius: 6px; background: var(--fill); overflow: hidden; margin-top: 12px; }
.battery span { display: block; height: 100%; border-radius: 6px; background: var(--ok); transition: width 0.4s; }
.battery span.warn { background: #ff9f0a; }
.battery span.bad { background: #ff3b30; }
.vc-foot { margin-top: 10px; }
.soc-change { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.soc-change b { color: var(--text); }
.soc-change b.text-bad { color: var(--bad); }

/* ---------- Kalender */
.cal { background: var(--card); border-radius: var(--radius); margin: 12px 16px; padding: 6px 4px 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 4px; }
.cal-head h2 { font-size: 17px; font-weight: 700; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; }
.cal-day {
  min-height: 62px; border: 0; background: none; padding: 2px 0; display: flex; flex-direction: column; align-items: stretch;
  border-radius: 10px; min-width: 0;
}
.cal-day:active { background: var(--fill); }
.cal-day .num {
  font-size: 15px; width: 28px; height: 28px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%;
  font-variant-numeric: tabular-nums;
}
.cal-day.today .num { background: var(--accent); color: #fff; font-weight: 700; }
.cal-day.other { opacity: 0.32; }
.cal-day.past:not(.today) .num { color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; min-height: 6px; }
.cal-bar { height: 5px; display: block; }
.cal-bar.start { margin-left: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; }
.cal-bar.end { margin-right: 4px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; }
.cal-usage { font-size: 10px; font-weight: 700; text-align: center; margin-top: auto; padding-top: 2px; white-space: nowrap; }
.cal-usage.moved { color: var(--ok); }
.cal-usage.unused { color: var(--bad); font-size: 12px; }
.cal-usage.still { color: var(--faint); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; padding: 8px 8px 0; }
.cal-legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-bar { width: 18px; height: 5px; border-radius: 3px; background: var(--accent); display: inline-block; }

/* ---------- Detail */
.detail-head { display: flex; align-items: center; gap: 10px; }
.big-range { font-size: 20px; font-weight: 700; margin-top: 12px; }
.lockline { display: flex; gap: 6px; align-items: center; margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---------- Schäden / Fotos */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.thumb {
  position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--fill); border: 0; padding: 0;
  display: grid; place-items: center; color: var(--accent);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.add { flex-direction: column; gap: 2px; display: flex; justify-content: center; align-items: center; cursor: pointer; }
.thumb-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 16px; line-height: 1;
}
.photo-full { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: #000; }

/* ---------- Statistik */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 16px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px; }
.tile.warn { background: var(--warn-weak); }
.tile-num { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 12px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; margin-top: 12px; }
.stat-grid div { display: flex; flex-direction: column; }
.stat-grid b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat-grid span { font-size: 12px; color: var(--muted); line-height: 1.2; }

/* ---------- Admin */
.tabs-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.tabs-scroll::-webkit-scrollbar { display: none; }
.tab-pill { flex: none; padding: 7px 14px; border-radius: 999px; background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; }
.tab-pill.active { background: var(--accent); color: #fff; }
.code-display {
  font-size: 34px; font-weight: 700; letter-spacing: 0.12em; text-align: center; padding: 16px; margin: 12px 0;
  background: var(--fill); border-radius: 12px; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all;
}
.raw { font-size: 11px; white-space: pre-wrap; word-break: break-all; background: var(--card); padding: 10px; border-radius: 10px; }

/* ---------- Login */
.login { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-t) + 48px) 0 40px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand h1 { font-size: 26px; margin-top: 12px; }
.login-logo {
  width: 72px; height: 72px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto;
}
.login .card { padding: 18px 16px; }
.login .field { padding: 0; border: 0; }
.login > p { padding: 0 24px; }
.code-input::placeholder { letter-spacing: 0.02em; font-size: 17px; }

/* ---------- Tab-Leiste */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
}
.tab {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; font-weight: 600; color: var(--faint);
}
.tab.active { color: var(--accent); }
.tab-plus {
  width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center;
  margin-top: -16px; box-shadow: 0 6px 16px rgba(28, 105, 212, 0.35);
}
.tab-book { color: var(--accent); }

/* ---------- Sheet & Toast */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.38); display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease-out;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; border-radius: 16px 16px 0 0;
  padding-bottom: calc(14px + var(--safe-b)); animation: up 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0 16px; }
.sheet-head h2 { font-size: 19px; }
@keyframes up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(28, 28, 30, 0.94); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 15px; font-weight: 500;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); animation: up 0.2s ease-out;
}
.toast.ok { background: rgba(31, 138, 59, 0.95); }
.toast.bad { background: rgba(215, 0, 21, 0.95); }

@media (min-width: 760px) {
  .app { padding-top: 8px; }
  .cal-day { min-height: 76px; }
}
