:root {
  --bg: #0f1c2e;
  --bg-card: #182a42;
  --bg-input: #1f3349;
  --line: #2a4060;
  --ink: #eef3f9;
  --ink-dim: #8da3bf;
  --signal: #00d98b;
  --signal-deep: #00a86b;
  --amber: #ffb547;
  --red: #ff5a5a;
  --shadow: 0 8px 28px rgba(0,0,0,.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 24px; }

/* gemeinsame Buttons / Felder */
.btn { border: none; border-radius: 12px; padding: 15px 20px; font-size: 1rem; font-weight: 700; cursor: pointer; width: 100%; transition: transform .08s, opacity .2s; font-family: inherit; }
.btn:active { transform: scale(.98); }
.btn-go { background: var(--signal); color: #06241a; }
.btn-stop { background: var(--red); color: #fff; }
.btn-ghost { background: var(--bg-input); color: var(--ink); border: 1px solid var(--line); }
.btn-row { display: flex; gap: 10px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .76rem; color: var(--ink-dim); margin-bottom: 5px; letter-spacing: .04em; text-transform: uppercase; }
.field input, .field select { width: 100%; background: var(--bg-input); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px; font-size: 1rem; font-family: inherit; }
.field input:focus, .field select:focus { outline: 2px solid var(--signal); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ LOGIN ============ */
.login-view { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--bg-card); border-radius: 20px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-brand { font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; }
.login-brand b { color: var(--signal); }
.login-sub { color: var(--ink-dim); font-size: .9rem; margin: 6px 0 22px; }
.login-error { color: var(--red); font-size: .85rem; min-height: 1.2em; margin-bottom: 10px; }
.login-note { color: var(--ink-dim); font-size: .76rem; text-align: center; margin: 14px 0 0; }

/* ============ APP / Tabs ============ */
.app-view { min-height: 100dvh; padding-top: env(safe-area-inset-top); }
.tab-panel { padding-bottom: 86px; }   /* Platz für Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: rgba(18,30,48,.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn { flex: 1; background: none; border: none; color: var(--ink-dim); font-family: inherit; font-size: .72rem; padding: 10px 0 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tab-btn .tab-ico { font-size: 1.3rem; filter: grayscale(.4) opacity(.7); }
.tab-btn.active { color: var(--signal); }
.tab-btn.active .tab-ico { filter: none; }

header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { font-weight: 800; font-size: 1.05rem; letter-spacing: .03em; }
.brand b { color: var(--signal); }
.gear { background: var(--bg-input); border: 1px solid var(--line); color: var(--ink); width: 40px; height: 40px; border-radius: 11px; font-size: 1.2rem; cursor: pointer; line-height: 1; }
.gear:active { transform: scale(.95); }

/* Fortschritt */
.progress-card { background: var(--bg-card); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.prog-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.prog-km { font-size: 2.6rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.prog-km span { font-size: 1rem; font-weight: 600; color: var(--ink-dim); }
.prog-goal { text-align: right; font-size: .82rem; color: var(--ink-dim); }
.prog-goal b { display: block; color: var(--ink); font-size: 1.1rem; }
.bar { height: 12px; background: var(--bg-input); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--signal-deep), var(--signal)); border-radius: 99px; transition: width .5s ease; }
.prog-meta { display: flex; gap: 18px; margin-top: 14px; font-size: .8rem; color: var(--ink-dim); }
.prog-meta b { color: var(--ink); }

/* Vorab-Kilometerstand-Hinweis */
.prog-note { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--ink-dim); }

/* Überprüfungsfahrten */
#checkupBox:empty { display: none; }
.checkup { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.checkup-ic { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .95rem; }
.checkup-txt { flex: 1 1 auto; min-width: 0; font-size: .9rem; }
.checkup-txt b { display: block; }
.checkup-txt span { font-size: .8rem; color: var(--ink-dim); }
.checkup-due { border-color: var(--amber); background: rgba(255,181,71,.1); }
.checkup-due .checkup-ic { background: var(--amber); color: #2a1a00; }
.checkup-mark { flex: 0 0 auto; background: var(--amber); color: #2a1a00; border: none; border-radius: 9px; padding: 9px 14px; font-size: .82rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.checkup-done .checkup-ic { background: rgba(0,217,139,.18); color: var(--signal); }
.checkup-undo { flex: 0 0 auto; background: none; border: none; color: var(--ink-dim); font-size: 1.3rem; cursor: pointer; padding: 0 2px; line-height: 1; }
.checkup-next .checkup-ic { background: var(--bg-input); color: var(--ink-dim); }
.checkup-next { opacity: .85; }

/* Tracker */
.tracker { background: var(--bg-card); border-radius: 18px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); text-align: center; border: 1px solid var(--line); }
.gps-status { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 6px; }
.gps-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-dim); margin-right: 6px; vertical-align: middle; }
.gps-dot.live { background: var(--signal); animation: pulse 1.4s infinite; }
.gps-dot.warn { background: var(--red); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.live-km { font-size: 3.4rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; margin: 6px 0; font-variant-numeric: tabular-nums; }
.live-km span { font-size: 1.1rem; color: var(--ink-dim); font-weight: 600; }
.live-sub { font-size: .82rem; color: var(--ink-dim); margin-bottom: 16px; font-variant-numeric: tabular-nums; }

/* Manuell */
details.manual { background: var(--bg-card); border-radius: 18px; margin-bottom: 16px; box-shadow: var(--shadow); overflow: hidden; }
details.manual summary { padding: 18px 20px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.manual summary::-webkit-details-marker { display: none; }
details.manual summary .chev { color: var(--ink-dim); transition: transform .2s; }
details.manual[open] summary .chev { transform: rotate(90deg); }
.form-body { padding: 0 20px 20px; }

/* Fahrtenbuch */
.log-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 4px 14px; }
.log-head h2 { font-size: 1.2rem; margin: 0; letter-spacing: .02em; }
.log-head button { background: var(--bg-input); border: 1px solid var(--line); color: var(--ink); border-radius: 9px; padding: 9px 16px; font-size: .82rem; cursor: pointer; font-family: inherit; font-weight: 600; }
.entry { background: var(--bg-card); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.entry-main { min-width: 0; }
.entry-date { font-weight: 700; font-size: .92rem; }
.entry-tag { display: inline-block; font-size: .64rem; padding: 2px 7px; border-radius: 6px; margin-left: 8px; vertical-align: middle; letter-spacing: .06em; }
.tag-gps { background: rgba(0,217,139,.16); color: var(--signal); }
.tag-man { background: rgba(255,181,71,.16); color: var(--amber); }
.entry-detail { font-size: .8rem; color: var(--ink-dim); margin-top: 4px; }
.entry-km { font-size: 1.3rem; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.entry-km span { font-size: .7rem; color: var(--ink-dim); font-weight: 600; }
.entry-del { background: none; border: none; color: var(--ink-dim); font-size: 1.3rem; cursor: pointer; padding: 0 0 0 10px; line-height: 1; }
.empty { text-align: center; color: var(--ink-dim); padding: 40px 20px; font-size: .9rem; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.chip { background: var(--bg-input); border: 1px solid var(--line); color: var(--ink); border-radius: 99px; padding: 10px 16px; font-size: .92rem; cursor: pointer; font-family: inherit; }
.chip.active { background: var(--signal); color: #06241a; border-color: var(--signal); font-weight: 700; }

/* Verwaltung */
.admin { position: fixed; inset: 0; background: var(--bg); z-index: 70; display: none; flex-direction: column; padding-top: env(safe-area-inset-top); }
.admin.show { display: flex; }
.admin-bar { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.admin-bar button { background: var(--bg-input); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 9px 14px; font-size: .9rem; cursor: pointer; font-family: inherit; }
.admin-bar h2 { font-size: 1.05rem; margin: 0; flex: 1; }
.admin-bar .logout { color: var(--amber); }
.admin-body { overflow-y: auto; padding: 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.admin-section { margin-bottom: 28px; }
.admin-section h3 { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); margin: 0 0 12px; }
.admin-add { display: flex; gap: 8px; margin-bottom: 14px; }
.admin-add input { flex: 1; background: var(--bg-input); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px; font-size: 1rem; font-family: inherit; }
.admin-add button { background: var(--signal); color: #06241a; border: none; border-radius: 10px; padding: 0 18px; font-weight: 700; cursor: pointer; font-family: inherit; }
.admin-add-veh { flex-wrap: wrap; }
.admin-add-veh input { flex: 1 1 100%; }
.admin-add-veh button { flex: 1 1 100%; padding: 12px; }
@media (min-width: 440px) { .admin-add-veh input { flex: 1 1 0; } .admin-add-veh button { flex: 0 0 auto; } }
.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li { display: flex; justify-content: space-between; align-items: center; background: var(--bg-card); border-radius: 11px; padding: 13px 16px; margin-bottom: 8px; font-size: .98rem; }
.admin-list li button { background: none; border: none; color: var(--red); font-size: .85rem; cursor: pointer; font-family: inherit; padding: 6px 8px; }
.admin-empty { color: var(--ink-dim); font-size: .88rem; padding: 4px 2px; }
.admin-add-user { flex-wrap: wrap; }
.admin-add-user input { flex: 1 1 100%; }
.admin-add-user button { flex: 1 1 100%; padding: 12px; }
.admin-chk { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; color: var(--ink-dim); font-size: .9rem; cursor: pointer; }
.admin-chk input { flex: 0 0 auto; width: auto; }
.user-badge { display: inline-block; background: var(--signal); color: #06241a; font-size: .68rem; font-weight: 700; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.user-badge-me { background: var(--line); color: var(--ink-dim); }
.user-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.user-actions .user-pw { color: var(--ink-dim) !important; }
.admin-user { color: var(--ink-dim); font-size: .78rem; text-align: center; margin-top: 30px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(7,14,24,.7); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; z-index: 80; padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-bg.show { display: flex; }
.modal { background: var(--bg-card); border-radius: 18px; padding: 22px; width: 100%; max-width: 460px; box-shadow: var(--shadow); border: 1px solid var(--line); animation: rise .25s ease; margin: auto; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.modal-sub { font-size: .85rem; color: var(--ink-dim); margin-bottom: 18px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(80px); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 99px; font-weight: 600; font-size: .88rem; box-shadow: var(--shadow); transition: transform .3s; z-index: 90; max-width: 90vw; text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
