:root {
  --brand:    #1f6b43;
  --brand-dk: #164f30;
  --good:     #27ae60;
  --danger:   #c0392b;
  --muted:    #5d6a60;
  --card:     #ffffff;
  --topbar-h: 52px;
  --bottom-h: 88px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 14px;
  color: #162018;
  background: #1a1a1a;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── TOPBAR ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
  transition: background .3s;
}
.topbar.tracking { background: #0c5c30; }

.topbar-left  { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.brand       { font-weight: 700; font-size: 18px; white-space: nowrap; }
.field-label { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.icon-btn {
  background: none; border: none; color: #fff;
  font-size: 20px; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; line-height: 1;
  touch-action: manipulation;
}
.icon-btn:active { background: rgba(255,255,255,.2); }

.gps-pill, .net-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: rgba(0,0,0,.3); white-space: nowrap;
  transition: background .5s;
}
.net-pill.online  { background: rgba(39,174,96,.7); }
.net-pill.offline { background: rgba(192,57,43,.6); }

/* ── SIDEBAR ── */
.settings-panel {
  position: fixed;
  top: var(--topbar-h); left: 0; bottom: 0;
  width: 300px;
  max-width: 88vw;
  background: var(--card);
  border-right: 1px solid #cde0d4;
  z-index: 900;
  padding: 0;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; overflow-x: hidden;
  box-shadow: 4px 0 24px rgba(0,0,0,.28);
  display: flex; flex-direction: column;
}
.settings-panel.open { transform: translateX(0); }
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.38);
  z-index: 850; display: none;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
.sidebar-backdrop.show { display: block; }

.settings-tabs {
  display: flex;
  background: #f0f7f2;
  border-bottom: 2px solid #cde0d4;
  margin: 0;
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 11px 6px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: #7a9a80;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  touch-action: manipulation;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: rgba(31,107,67,.05);
}
.tab-btn:active { background: #ddf0e4; }
.tab-panel        { display: none; }
.tab-panel.active { display: flex; flex-direction: column; padding: 12px 14px; }


.settings-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 5px 8px;
  align-items: center;
  margin-bottom: 6px;
}
.settings-grid label  { font-size: 12px; color: #4a6050; font-weight: 600; }
.settings-grid select,
.settings-grid input[type="number"] {
  border: 1px solid #c8d4cb; border-radius: 6px;
  padding: 6px 8px; font-size: 14px; width: 100%; background: #f8faf8;
}

.settings-actions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.sm-btn {
  background: #eaf2ec; border: 1px solid #c5dac9;
  border-radius: 7px; padding: 7px 12px; font-size: 13px;
  cursor: pointer; white-space: nowrap; touch-action: manipulation;
  color: #2a5a35; font-weight: 500;
}
.sm-btn:active { background: #d2ead7; }

.sync-row {
  display: flex; gap: 6px; margin-bottom: 6px;
}
.sync-row input {
  flex: 1; min-width: 0; border: 1px solid #c8d4cb;
  border-radius: 6px; padding: 5px 8px; font-size: 12px; background: #f8faf8;
}

.status-line { font-size: 12px; color: var(--muted); min-height: 18px; margin-top: 2px; }
.status-line.err { color: var(--danger); }
.settings-panel > .status-line {
  padding: 6px 14px 12px;
  border-top: 1px solid #e5ede8;
  flex-shrink: 0; margin-top: auto;
}

/* ── MAP ── */
#map {
  position: fixed;
  top: var(--topbar-h); left: 0; right: 0; bottom: var(--bottom-h);
  z-index: 1;
}

/* MapLibre compass / attribution */
.maplibregl-ctrl-attrib { font-size: 9px !important; }
.maplibregl-ctrl-bottom-right { bottom: 4px !important; right: 4px !important; }

/* ── MAP OVERLAY BUTTONS (floating on map) ── */
.map-overlay-btns {
  position: fixed;
  left: 10px;
  bottom: calc(var(--bottom-h) + 12px);
  z-index: 500;
  display: flex;
  gap: 6px;
  flex-direction: column;
}
.map-btn {
  background: rgba(0,0,0,.65);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  touch-action: manipulation;
}
.map-btn:active { background: rgba(0,0,0,.85); }
.map-btn.active { background: rgba(31,107,67,.85); border-color: rgba(255,255,255,.4); }

/* ── VEHICLE MARKER ── */
.vehicle-marker {
  width: 36px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.7));
}
.vehicle-marker svg { overflow: visible; }

/* accuracy ring drawn by MapLibre circle layer — no extra CSS needed */

/* ── BOTTOM BAR ── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  background: rgba(15,20,16,.92);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 1000;
  display: flex; flex-direction: column;
  padding: 6px 10px 8px; gap: 4px;
  backdrop-filter: blur(8px);
}

.stats-strip {
  display: flex; justify-content: space-around;
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding-bottom: 5px;
}
.stat { display: flex; flex-direction: column; align-items: center; min-width: 60px; }
.stat-val { font-size: 15px; font-weight: 700; color: #e8f5ec; }
.stat-lbl { font-size: 10px; color: #6a8a70; text-transform: uppercase; letter-spacing: .4px; }

.bottom-actions { display: flex; gap: 10px; justify-content: center; }

.btn-start, .btn-pause, .btn-stop {
  flex: 1; max-width: 140px; padding: 10px;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  letter-spacing: .4px; touch-action: manipulation;
}
.btn-start          { background: var(--good);   color: #fff; }
.btn-start:active   { background: #1e8f4f; }
.btn-start:disabled { background: #2a5c35; color: #6a9a70; cursor: not-allowed; }
.btn-pause          { background: #e67e22; color: #fff; }
.btn-pause:active   { background: #ca6f1e; }
.btn-pause.resumed  { background: var(--good); }
.btn-pause.resumed:active { background: #1e8f4f; }
.btn-pause:disabled { background: #4a3010; color: #8a6a50; cursor: not-allowed; }
.btn-stop           { background: var(--danger); color: #fff; }
.btn-stop:active    { background: #a93226; }
.btn-stop:disabled  { background: #5c2020; color: #9a6a6a; cursor: not-allowed; }

.topbar.paused { background: #7a5500; }

/* ── TRACK PANELS ── */
.track-panel {
  position: fixed;
  bottom: var(--bottom-h); left: 0; right: 0;
  background: var(--card);
  border-top: 2px solid #c8d8cb;
  z-index: 950;
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
}
.track-panel.open { max-height: 58vh; overflow-y: auto; }

.track-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: #f0f7f2;
  border-bottom: 1px solid #ddeae0;
  position: sticky; top: 0; z-index: 1;
}
.track-panel-header h2 { font-size: 13px; font-weight: 700; }
.icon-btn-dark { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px 8px; }

#trackList, #srvTrackList { list-style: none; }

.track-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; padding: 8px 12px;
  border-top: 1px solid #ecf0ed; font-size: 12px;
}
.track-item-info strong { display: block; font-size: 13px; margin-bottom: 2px; }
.track-item-info span   { color: var(--muted); }
.track-item-btns { display: flex; gap: 4px; flex-shrink: 0; }
.tbtn {
  background: #f0f4f1; border: 1px solid #d0dfd5;
  border-radius: 4px; padding: 4px 8px; font-size: 11px;
  cursor: pointer; white-space: nowrap; touch-action: manipulation;
}
.tbtn.del  { background: #fdecea; border-color: #f5c2bb; }
.tbtn.sync { background: #e8f0ff; border-color: #aac4f5; }
.tbtn:active { opacity: .7; }

/* ── LOGIN OVERLAY ── */
.login-overlay {
  position: fixed; inset: 0;
  background: rgba(10,20,12,.92);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.login-overlay.hidden { display: none; }

.login-card {
  background: #fff; border-radius: 16px;
  padding: 36px 28px 28px; width: 320px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.login-logo { font-size: 40px; text-align: center; }
.login-card h1 { color: var(--brand); font-size: 22px; text-align: center; margin: 0; }

.login-card input {
  border: 1px solid #c8d4cb; border-radius: 8px;
  padding: 11px 14px; font-size: 16px; width: 100%;
  background: #f8faf8;
}
.login-card input:focus { outline: 2px solid var(--brand); border-color: transparent; }

.login-card button {
  background: var(--brand); color: #fff;
  border: none; border-radius: 8px; padding: 13px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  letter-spacing: .4px; touch-action: manipulation;
  margin-top: 4px;
}
.login-card button:active   { background: var(--brand-dk); }
.login-card button:disabled { opacity: .6; cursor: not-allowed; }
.login-err { color: var(--danger); font-size: 13px; min-height: 16px; text-align: center; }




/* ── PWA INSTALL BANNER ── */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.18);
  padding: 20px 20px 32px;
  z-index: 800;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; gap: 12px;
}
.install-banner.show { transform: translateY(0); }
.install-banner-top {
  display: flex; align-items: center; gap: 14px;
}
.install-banner-icon {
  font-size: 42px; line-height: 1; flex-shrink: 0;
}
.install-banner-text h3 {
  font-size: 17px; font-weight: 700; margin: 0 0 3px;
}
.install-banner-text p {
  font-size: 13px; color: #607060; margin: 0; line-height: 1.4;
}
.install-banner-ios {
  background: #f2f5f3; border-radius: 10px;
  padding: 10px 12px; font-size: 13px; color: #333; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 8px;
}
.install-banner-ios .ios-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.install-banner-actions { display: flex; gap: 10px; }
.install-banner-actions button {
  flex: 1; padding: 12px; border-radius: 10px;
  font-size: 15px; font-weight: 600; border: none; cursor: pointer;
}
.btn-install-confirm { background: #1f6b43; color: #fff; }
.btn-install-later   { background: #f0f4f2; color: #607060; }

.ab-cfg {
  grid-column: 1 / -1;
  background: #edf5ef;
  border-radius: 8px;
  border-left: 3px solid var(--brand);
  padding: 8px 10px 6px;
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 5px 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
}
.ab-cfg.hidden { display: none; }
.ab-cfg input[type="number"] {
  border: 1px solid #c8d4cb; border-radius: 6px;
  padding: 5px 8px; font-size: 13px; width: 100%; background: #f8faf8;
  font-weight: 400;
}
.settings-divider {
  grid-column: 1 / -1;
  height: 1px;
  background: linear-gradient(to right, #d5e5da 60%, transparent);
  margin: 4px 0 2px;
}
.sync-details {
  margin-top: 4px;
}
.sync-details > summary {
  font-size: 11px; color: var(--muted); cursor: pointer;
  padding: 2px 0; list-style: none; user-select: none; outline: none;
}
.sync-details > summary::before { content: '\25B6  '; font-size: 9px; }
.sync-details[open] > summary::before { content: '\25BC  '; font-size: 9px; }
.sync-details .sync-row { margin-top: 6px; }

/* ── Parallelfahrt-Assistent ─────────────────────────────────────── */
/* ── XTE Lenk-Indikator (volle Breite über Bottom-Bar) ── */
.ab-guidance {
  position: fixed;
  bottom: var(--bottom-h);
  left: 0; right: 0;
  background: rgba(8,18,10,.88);
  padding: 8px 18px 10px;
  z-index: 210;
  pointer-events: none;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.ab-bar {
  position: relative;
  height: 16px;
  background: linear-gradient(to right,
    #c0392b 0%, #e74c3c 12%,
    #e67e22 28%,
    #27ae60 42%, #27ae60 58%,
    #e67e22 72%,
    #e74c3c 88%, #c0392b 100%);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: visible;
}
.ab-bar::before {
  content: '';
  position: absolute;
  left: 50%; top: -5px; bottom: -5px;
  width: 3px;
  background: rgba(255,255,255,.9);
  transform: translateX(-50%);
  z-index: 1; border-radius: 2px;
}
.ab-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,.45);
  box-shadow: 0 2px 10px rgba(0,0,0,.6);
  transition: left .2s ease, background-color .25s;
  z-index: 2;
}
.ab-xte {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .8px;
}
.map-btn.ab-sub {
  background: rgba(255,136,0,.85);
  font-weight: bold;
}
.map-btn.ab-sub:disabled {
  opacity: .45;
}


/* ── AB Anlege-Assistent ──────────────────────────────────────────── */
.ab-wizard {
  position: fixed;
  bottom: calc(var(--bottom-h) + 62px);
  left: 10px; right: 10px;
  z-index: 700;
  pointer-events: none;
}
.ab-wizard-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 40px rgba(0,0,0,.35);
  overflow: hidden;
  pointer-events: auto;
  animation: wiz-in .22s ease;
}
@keyframes wiz-in {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.ab-wizard-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 10px;
  background: var(--brand); color: #fff;
}
.ab-wizard-title   { font-weight: 700; font-size: 15px; flex: 1; }
.ab-wizard-step-lbl{ font-size: 12px; opacity: .8; }
.ab-wizard-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; padding: 2px 6px;
  line-height: 1; opacity: .85; touch-action: manipulation;
}
.ab-wizard-body { padding: 16px; }
.ab-choice-row  { display: flex; gap: 10px; margin-top: 12px; }
.ab-choice {
  flex: 1; border: 2px solid #d0e5d8; border-radius: 14px;
  padding: 14px 8px; background: #f8fdf9;
  cursor: pointer; text-align: center;
  font-size: 14px; font-weight: 600;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  touch-action: manipulation;
  transition: border-color .15s, background .15s;
}
.ab-choice:active { border-color: var(--brand); background: #edf7f1; }
.ab-choice-icon { font-size: 22px; font-family: monospace; color: var(--brand); letter-spacing: 2px; }
.ab-choice small { font-size: 11px; color: var(--muted); font-weight: 400; }
.ab-wiz-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.ab-wiz-badge {
  background: var(--brand); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.ab-wiz-badge.done { background: var(--good); }
.ab-wiz-row p { font-size: 14px; line-height: 1.5; margin: 0; padding-top: 3px; }
.ab-wiz-action {
  width: 100%; padding: 15px;
  background: var(--brand); color: #fff;
  border: none; border-radius: 12px;
  font-size: 17px; font-weight: 700;
  cursor: pointer; touch-action: manipulation; letter-spacing: .3px;
}
.ab-wiz-action:active  { background: var(--brand-dk); }
.ab-wiz-action.stop    { background: #e67e22; }
.ab-wiz-action.stop:active { background: #ca6f1e; }
.ab-wiz-gps {
  font-size: 11px; color: var(--muted);
  text-align: center; margin-top: 8px; font-family: monospace;
}
.ab-wiz-done { text-align: center; padding: 4px 0; }
.ab-wiz-done-icon { font-size: 44px; color: var(--good); margin-bottom: 6px; }
.ab-wiz-done p    { font-size: 16px; font-weight: 600; margin-bottom: 14px; }


/* ── Settings: volle Breite Zeile (für lange Labels) ── */
.settings-full-row {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: #3a4a3c;
  padding: 3px 0;
}
.settings-full-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 400; cursor: pointer;
}

/* ── Help Overlay ─────────────────────────────────────────────────────── */
.help-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.52);
  z-index: 1100;
  display: flex; align-items: flex-end;
}
.help-panel {
  width: 100%; max-height: 90vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: help-up .25s cubic-bezier(.4,0,.2,1);
}
@keyframes help-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.help-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 0; flex-shrink: 0;
}
.help-header h2 {
  flex: 1; font-size: 17px; font-weight: 700;
  color: var(--brand); margin: 0;
}
.help-close {
  background: #f0f5f2; border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--brand); flex-shrink: 0;
}
.help-tabs {
  display: flex; gap: 6px;
  padding: 12px 16px 10px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; flex-shrink: 0;
  border-bottom: 2px solid #e8f0ea;
}
.help-tabs::-webkit-scrollbar { display: none; }
.help-tab {
  flex-shrink: 0; padding: 7px 14px;
  border-radius: 20px; border: 1.5px solid #d0e5d8;
  background: #fff; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  touch-action: manipulation;
}
.help-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.help-content {
  flex: 1; overflow-y: auto; padding: 16px 16px 24px;
  -webkit-overflow-scrolling: touch;
}
.help-section-title {
  font-size: 15px; font-weight: 700; color: var(--brand);
  margin: 0 0 16px; display: flex; align-items: center; gap: 8px;
}
.help-block { margin-bottom: 18px; }
.help-block-h {
  font-size: 11px; font-weight: 700; color: #4a7a55;
  text-transform: uppercase; letter-spacing: .6px; margin: 0 0 7px;
}
.help-block-p {
  font-size: 14px; line-height: 1.55; color: #2a3a2c; margin: 0;
}
.help-steps {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 5px;
}
.help-steps li {
  font-size: 14px; line-height: 1.45; color: #2a3a2c;
  padding: 6px 10px 6px 12px;
  background: #f5fbf7; border-left: 3px solid #c0dfc8;
  border-radius: 0 6px 6px 0;
}
.help-tip {
  background: #fff9e6; border-left: 3px solid #f1c40f;
  border-radius: 0 8px 8px 0; padding: 10px 12px;
  font-size: 13px; line-height: 1.5; color: #5a4a10;
}
#btnHelp {
  font-size: 17px; font-weight: 700; color: var(--brand);
}
