/* =====================================================
   Kisten-App – Mobile-First Stylesheet
   ===================================================== */

:root {
  --primary:       rgb(200, 16, 55);
  --primary-lt:    rgb(225, 60, 95);
  --primary-bg:    #fff0f3;
  --bg:            #f8f9fa;
  --surface:       #ffffff;
  --text:          #1e2329;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --success:       #15803d;
  --success-bg:    #f0fdf4;
  --danger:        #991b1b;
  --danger-bg:     #fef2f2;
  --warning:       #d97706;
  --ausgabe:       rgb(200, 16, 55);
  --ruecknahme:    #d97706;
  --shadow:        0 1px 4px rgba(0,0,0,.10);
  --shadow-md:     0 4px 12px rgba(0,0,0,.12);
  --radius:        12px;
  --radius-sm:     8px;
  --nav-h:         64px;
  --header-h:      56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* ── Header ─────────────────────────────────────────── */
#header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  box-shadow: var(--shadow-md);
}
#header h1 { flex: 1; font-size: 18px; font-weight: 700; }
#header .logo { height: 32px; width: auto; opacity: .95; flex-shrink: 0; }
#header .logo-sylbe { height: 20px; width: auto; opacity: 1; flex-shrink: 0; }
#btn-back, #btn-menu {
  width: 40px; height: 40px;
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
#btn-back:active, #btn-menu:active { background: rgba(255,255,255,.15); }
#header .online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; flex-shrink: 0;
}
#header .online-dot.offline { background: #f87171; }

/* ── Main content ────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 16px);
  padding-top: 0px;
}
.view { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Bottom Navigation ───────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
#bottom-nav.hidden { display: none; }
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; font-weight: 500; cursor: pointer;
  transition: color .15s;
}
.nav-btn .nav-icon { font-size: 22px; line-height: 1; }
.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-icon { transform: translateY(-1px); }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600; border: none; cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  min-height: 48px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: #1e40af; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-full { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 18px; min-height: 56px; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=datetime-local], input[type=password], textarea, select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 16px; color: var(--text);
  background: var(--surface); transition: border-color .15s;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
.checkbox-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg); border-radius: var(--radius-sm);
  margin-bottom: 8px; cursor: pointer;
}
.checkbox-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.checkbox-row span { font-size: 15px; }

/* ── Login View ──────────────────────────────────────── */
.login-sylbe {
  text-align: center; padding: 10px 16px 8px;
  background: var(--primary);
  margin: -16px -16px 0;
}
.login-sylbe img { height: 28px; width: auto; opacity: .85; }
.login-header {
  text-align: center;
  background: var(--primary);
  margin: 0 -16px 20px;
  padding: 18px 16px 24px;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 16px rgba(200,16,55,.25);
}
.login-header .app-logo { width: 220px; max-height: 100px; object-fit: contain; margin-bottom: 12px; }
.login-header h2 { font-size: 22px; color: #fff; font-weight: 700; }
.login-header p { color: rgba(255,255,255,.75); font-size: 14px; }
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
  border: 2px solid transparent; transition: border-color .15s;
}
.user-item:active { border-color: var(--primary); }
.user-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.user-info .user-name { font-size: 17px; font-weight: 600; }
.user-info .user-role { font-size: 13px; color: var(--text-muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-driver { background: #fef3c7; color: #92400e; }
.badge-shop { background: #f0fdf4; color: #15803d; }

/* ── Dashboard ───────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.stat-card .stat-val { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tour-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
  color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-md);
}
.tour-banner.aktiv {
  background: linear-gradient(135deg, #15803d 0%, #22c55e 100%);
}
.tour-banner h3 { font-size: 17px; margin-bottom: 4px; }
.tour-banner p { font-size: 13px; opacity: .85; }
.tour-banner .btn { margin-top: 12px; background: rgba(255,255,255,.2); color: #fff; border: 1.5px solid rgba(255,255,255,.4); }

/* ── Customer List ───────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.search-bar input { flex: 1; border: none; background: none; font-size: 16px; color: var(--text); }
.search-bar input:focus { outline: none; }
.search-bar .search-icon { color: var(--text-muted); font-size: 18px; }
.customer-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 10px; cursor: pointer; border: 2px solid transparent;
}
.customer-item:active { border-color: var(--primary-lt); }
.customer-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.customer-info { flex: 1; min-width: 0; }
.customer-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customer-dist { font-size: 12px; color: var(--text-muted); }
.customer-stocks { display: flex; gap: 8px; margin-top: 4px; }
.stock-chip { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--bg); color: var(--text-muted); font-weight: 600; }
.stock-chip.has-stock { background: var(--primary-bg); color: var(--primary); }

/* ── Booking View ────────────────────────────────────── */
.booking-header { margin-bottom: 18px; }
.booking-header h2 { font-size: 22px; font-weight: 700; }
.booking-header .current-stock { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* Dual-Stepper Grid */
.dual-booking {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.dual-booking-head {
  display: grid;
  grid-template-columns: 58px 1fr 1fr 44px;
  padding: 8px 10px 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 4px;
}
.dual-col-label {
  font-size: 12px; font-weight: 700; text-align: center; line-height: 1.3;
}
.dual-col-label small { font-weight: 400; color: var(--text-muted); }
.dual-net-label { font-size: 12px; font-weight: 700; text-align: center; color: var(--text-muted); }
.ausgabe-col { color: var(--ausgabe); }
.ruecknahme-col { color: var(--ruecknahme); }

.dual-row {
  display: grid;
  grid-template-columns: 58px 1fr 1fr 44px;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.dual-row:last-child { border-bottom: none; }
.dual-row-label { font-size: 15px; font-weight: 600; }

.dual-stepper {
  display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.dual-stepper.ausgabe-col { border-color: color-mix(in srgb, var(--ausgabe) 30%, var(--border)); }
.dual-stepper.ruecknahme-col { border-color: color-mix(in srgb, var(--ruecknahme) 30%, var(--border)); }
.ds-btn {
  width: 38px; height: 52px; font-size: 22px; font-weight: 300;
  border: none; background: var(--bg); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ds-btn:active { background: var(--border); }
.ds-val {
  flex: 1; min-width: 0; height: 52px; text-align: center;
  font-size: 20px; font-weight: 700;
  border: none;
  border-left: 1.5px solid var(--border); border-right: 1.5px solid var(--border);
  background: var(--surface); color: var(--text);
}
.ds-val:focus { outline: 2px solid var(--primary); }

.dual-net { text-align: center; font-size: 17px; font-weight: 700; }
.net-pos { color: var(--ausgabe); }
.net-neg { color: var(--ruecknahme); }
.net-zero { color: var(--text-muted); }

/* PWA Install Card */
.pwa-install-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pwa-install-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: contain;
  flex-shrink: 0;
}
.pwa-install-text { flex: 1; }

/* Adresssuche unter der Karte */
.addr-search-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px;
}
.addr-search-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
}
.addr-search-row input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Letzter Nutzer beim Login hervorheben */
.last-user-highlight .user-item {
  border: 2px solid var(--primary);
  background: var(--primary-bg);
}

@media (max-width: 480px) {
  .dual-booking-head { grid-template-columns: 58px 1fr 1fr; }
  .dual-row          { grid-template-columns: 58px 1fr 1fr; }
  .dual-net-label,
  .dual-net          { display: none; }
}

/* ── New Customer / Map ──────────────────────────────── */
#map { width: 100%; height: 260px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }
.map-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; margin-bottom: 14px; }

/* ── Tour View ───────────────────────────────────────── */
.tour-section { margin-bottom: 20px; }
.tour-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--primary); }
.km-input { font-size: 28px !important; font-weight: 700 !important; text-align: center; }

/* ── Journal View ────────────────────────────────────── */
.journal-entry {
  padding: 14px 16px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 10px; border-left: 4px solid var(--border);
}
.journal-entry.ausgabe { border-left-color: var(--ausgabe); }
.journal-entry.ruecknahme { border-left-color: var(--ruecknahme); }
.journal-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.journal-amounts { display: flex; gap: 12px; }
.journal-amount { font-size: 15px; font-weight: 700; }
.journal-amount.ausgabe { color: var(--ausgabe); }
.journal-amount.ruecknahme { color: var(--ruecknahme); }
.journal-customer { font-size: 14px; font-weight: 600; }

/* ── Inventory summary ───────────────────────────────── */
.inventory-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.inv-cell { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; }
.inv-cell .inv-val { font-size: 24px; font-weight: 700; color: var(--text); }
.inv-cell .inv-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Settings View ───────────────────────────────────── */
.settings-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px;
}
.settings-item .settings-info .title { font-size: 16px; font-weight: 600; }
.settings-item .settings-info .sub { font-size: 13px; color: var(--text-muted); }
.settings-item .btn { padding: 8px 14px; min-height: 36px; font-size: 14px; }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 200; display: flex; align-items: flex-end;
}
.modal-overlay.center { align-items: center; padding: 20px; }
.modal {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px; width: 100%; max-height: 85vh; overflow-y: auto;
}
.modal-overlay.center .modal { border-radius: var(--radius); max-width: 420px; margin: auto; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ── PIN entry ───────────────────────────────────────── */
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 16px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); background: transparent; }
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.pin-pad { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.pin-key { padding: 18px; font-size: 22px; font-weight: 600; background: var(--bg); border: none; border-radius: var(--radius-sm); cursor: pointer; }
.pin-key:active { background: var(--border); }

/* ── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-10 { gap: 10px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin: 20px 0 10px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 12px 20px; border-radius: 24px;
  font-size: 14px; font-weight: 500; z-index: 300; white-space: nowrap;
  box-shadow: var(--shadow-md); animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .6s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Leaflet map fix in modal */
.leaflet-container { font-family: inherit; }

/* ── Fahrerberichte ──────────────────────────────────── */
.bericht-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.bericht-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
}
.bericht-vehicle { font-size: 17px; font-weight: 700; }
.bericht-driver  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.bericht-date    { font-size: 13px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.bericht-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 1px; background: var(--border);
}
.bericht-cell {
  background: var(--surface); padding: 10px 8px; text-align: center;
}
.bericht-val { font-size: 18px; font-weight: 700; }
.bericht-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.bericht-checks {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.bericht-ok   { color: var(--success); font-weight: 700; }
.bericht-nein { color: var(--danger);  font-weight: 700; }
.bericht-schaden {
  padding: 10px 14px; background: var(--danger-bg);
  border-top: 1px solid var(--border); font-size: 13px; color: var(--danger);
}
.bericht-schaden-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.bericht-ok-bar {
  padding: 8px 14px; background: var(--success-bg);
  border-top: 1px solid var(--border); font-size: 13px; color: var(--success); font-weight: 600;
}
.bericht-laufend {
  padding: 8px 14px; background: #fef3c7;
  border-top: 1px solid var(--border); font-size: 13px; color: #92400e; font-weight: 600;
}

/* ── Schadens-Erfassung ──────────────────────────────── */
.schaden-card { border: 1.5px solid var(--danger); }
.schaden-toggle {
  display: flex; border-radius: var(--radius-sm); overflow: hidden;
  border: 1.5px solid var(--border);
}
.schaden-toggle-btn {
  flex: 1; padding: 10px 8px; font-size: 14px; font-weight: 600;
  border: none; background: var(--bg); color: var(--text-muted); cursor: pointer;
}
.schaden-toggle-btn.active { background: var(--danger); color: #fff; }
.schaden-typen { display: flex; flex-wrap: wrap; gap: 8px; }
.schaden-typ-btn {
  padding: 8px 14px; border-radius: 20px;
  border: 2px solid var(--border); background: var(--bg);
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.schaden-typ-btn.active {
  border-color: var(--danger); background: var(--danger-bg); color: var(--danger);
}
.schaden-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--danger-bg);
  border-radius: var(--radius-sm); border-left: 3px solid var(--danger);
  margin-bottom: 8px;
}
