/* =========================================================================
   OX Service – Techniker-PWA · mobil-first Dark-Theme
   Design-Tokens aus dem ERP-Prototyp (prototype/assets/style.css) übernommen.
   ========================================================================= */
:root {
  --bg:            #0c0e13;
  --surface:       #181c25;
  --surface-2:     #1f242f;
  --border:        #242a36;
  --border-strong: #313847;
  --text:          #e8eaf1;
  --muted:         #9097a6;
  --faint:         #5d6473;
  --accent:        #6c6cf5;
  --accent-2:      #8a6cff;
  --accent-soft:   rgba(108, 108, 245, .16);
  --success:       #38d39f;
  --warning:       #f7b955;
  --danger:        #f46a6a;
  --info:          #45b6f5;
  --radius:   18px;
  --radius-m: 14px;
  --radius-s: 10px;
  --shadow:   0 2px 6px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.28);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
a { color: inherit; text-decoration: none; }

/* ---- App-Schale ------------------------------------------------------- */
.app {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  max-width: 560px; margin: 0 auto;
}

/* Kopfleiste (sticky) */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: rgba(12,14,19,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .back {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 20px; cursor: pointer;
}
.topbar .back:active { background: var(--surface-2); }
.topbar .ttl { font-weight: 750; font-size: 17px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .ttl .sub { display: block; color: var(--faint); font-size: 12px; font-weight: 500; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 16px rgba(108,108,245,.4);
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); color: var(--text); }

/* Inhalt */
.content { flex: 1; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }

/* ---- Untere Tab-Leiste ----------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; z-index: 30; display: none;
  background: rgba(12,14,19,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
body.tabbar-on .tabbar { display: flex; }
.tabbar { justify-content: space-around; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 9px 4px 10px;
  color: var(--faint); font-size: 10px; font-weight: 500; font-family: inherit;
  transition: color .12s;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent); font-weight: 700; }
.tab:active { opacity: .65; }
/* Platz für die Leiste schaffen + Chat-Button darüber heben */
body.tabbar-on .content { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
body.tabbar-on .ox-fab  { bottom: calc(82px + env(safe-area-inset-bottom)) !important; }
body.tabbar-on .ox-chat { bottom: calc(150px + env(safe-area-inset-bottom)) !important; }

/* ---- Zeiterfassung (Stempeln) ---------------------------------------- */
.zeit-card { text-align: center; padding: 32px 22px 26px; }
.zeit-state {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.zeit-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.zeit-state.on { background: rgba(56,211,159,.14); color: var(--success); }
.zeit-counter {
  font-size: 46px; font-weight: 800; letter-spacing: 1px; margin: 20px 0 6px;
  font-variant-numeric: tabular-nums; font-family: "SF Mono", "Roboto Mono", ui-monospace, monospace;
}
.zeit-since { color: var(--faint); font-size: 13px; margin-bottom: 22px; }
.zeit-btn { width: 100%; min-height: 56px; font-size: 16px; }
.zeit-out {
  background: rgba(244,106,106,.12); border: 1px solid rgba(244,106,106,.5); color: var(--danger);
}

/* Bildschirme umschalten */
.screen { display: none; }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- Karten ----------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }

.section-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  margin: 22px 2px 10px; text-transform: uppercase; letter-spacing: .6px;
}

/* ---- Tour-Liste ------------------------------------------------------- */
.tour-item {
  display: flex; align-items: stretch; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 14px; margin-bottom: 12px;
  cursor: pointer; transition: border-color .12s, transform .08s;
}
.tour-item:active { transform: scale(.99); border-color: var(--accent); }
/* Laufende Nummer der Tour (1, 2, 3 …) bzw. Haken bei erledigt */
.tour-no {
  align-self: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(108,108,245,.4);
}
.tour-item.done { border-color: rgba(56,211,159,.45); }
.tour-item.done .tour-no {
  background: linear-gradient(135deg, #3fd9a4, #1fa97f);
  box-shadow: 0 4px 12px rgba(56,211,159,.4);
}
.tour-item.done .tour-time .hh { color: var(--success); }
.tour-time {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: none; min-width: 58px; padding-right: 14px;
  border-right: 1px solid var(--border);
}
.tour-time .hh { font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.tour-time .dur { font-size: 11px; color: var(--faint); margin-top: 2px; }
.tour-main { flex: 1; min-width: 0; }
.tour-main .kd { font-weight: 700; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tour-main .geraet { color: var(--muted); font-size: 13px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tour-main .meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tour-chev { align-self: center; color: var(--faint); font-size: 20px; flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
}
/* Auftragsart-Symbol in der Tour (wie Web-Ansicht) */
.tour-type { width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; }
.tour-type svg { width: 16px; height: 16px; }
.badge.done { background: rgba(56,211,159,.15); color: var(--success); }
.badge.vnr  { background: var(--accent-soft); color: var(--accent); }

/* Datums-Navigation */
.date-nav {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.date-nav .lbl { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.date-nav .lbl span { display: block; color: var(--faint); font-size: 12px; font-weight: 500; }

/* ---- Detail: Infozeilen ---------------------------------------------- */
.info-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row .lbl { color: var(--muted); font-size: 13px; flex: none; }
.info-row .val { font-weight: 600; text-align: right; word-break: break-word; }
.fehler-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 12px 14px; margin-top: 4px;
  font-size: 14px; line-height: 1.5;
}

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 15px 18px; min-height: 52px;
  border-radius: var(--radius-m); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff; box-shadow: 0 8px 20px rgba(108,108,245,.35);
}
.btn-success {
  background: linear-gradient(135deg, #3fd9a4, #1fa97f);
  border: none; color: #06210f; box-shadow: 0 8px 20px rgba(56,211,159,.3);
}
.btn-ghost { background: var(--surface); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-sm { width: auto; min-height: 44px; padding: 11px 16px; font-size: 14px; }

/* ---- Formularfelder --------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 7px; font-weight: 600; }
.field input, .field textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 14px; color: var(--text);
  font-size: 16px; outline: none; font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 80px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- Ersatzteil-Liste ------------------------------------------------- */
.part-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.part-row:last-child { border-bottom: none; }
.part-row .pq {
  flex: none; min-width: 44px; text-align: center; font-weight: 800; font-size: 15px;
  color: var(--accent);
}
.part-row .pn { flex: 1; min-width: 0; }
.part-row .pn .nm { font-weight: 600; }
.part-row .pn .an { color: var(--faint); font-size: 12px; }
.part-row .pp { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.part-empty { color: var(--faint); text-align: center; padding: 18px; font-size: 14px; }

/* ---- Unterschrift ----------------------------------------------------- */
.sig-wrap {
  position: relative; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-m); background: #f7f8fc; overflow: hidden;
}
.sig-wrap canvas { display: block; width: 100%; height: 200px; touch-action: none; }
.sig-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #aab; font-size: 14px; pointer-events: none;
}
.sig-wrap.signed .sig-hint { display: none; }

/* ---- Login ------------------------------------------------------------ */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 12px; justify-content: center;
  margin-bottom: 24px; font-weight: 800; font-size: 22px; }
.login-brand .accent { color: var(--accent); }
.err {
  color: var(--danger); font-size: 13px; margin-top: 12px;
  background: rgba(244,106,106,.1); border: 1px solid rgba(244,106,106,.4);
  border-radius: var(--radius-s); padding: 11px 13px; display: none;
}
.err.show { display: block; }
.hint { color: var(--faint); font-size: 12px; margin-top: 16px; text-align: center; line-height: 1.6; }

/* ---- Zustände (leer / laden) ----------------------------------------- */
.state { text-align: center; padding: 48px 20px; color: var(--faint); }
.state .ico { font-size: 40px; margin-bottom: 12px; }
.state .big { color: var(--text); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid var(--surface-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast & Banner --------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  padding: 13px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }

.offline-banner {
  display: none; align-items: center; gap: 8px; justify-content: center;
  background: var(--warning); color: #2a1d00; font-weight: 700; font-size: 13px;
  padding: 8px 14px;
}
.offline-banner.show { display: flex; }

.locked-banner {
  display: flex; align-items: center; gap: 10px;
  background: rgba(56,211,159,.12); border: 1px solid rgba(56,211,159,.4);
  color: var(--success); border-radius: var(--radius-m);
  padding: 13px 15px; font-weight: 600; font-size: 14px; margin-bottom: 14px;
}

.install-btn { display: none; }
.install-btn.show { display: grid; }

/* ---- Reparatur-Wizard -------------------------------------------------- */
.wz-prog { display: flex; gap: 6px; margin: 2px 2px 10px; }
.wz-dot { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); transition: background .2s; }
.wz-dot.done { background: var(--success); }
.wz-dot.on { background: var(--accent); }
.wz-step-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 2px 14px; }
.wz-q { font-size: 16px; font-weight: 650; margin: 2px 0 14px; }
.wz-nav { display: flex; gap: 10px; margin-top: 18px; }
.wz-nav .btn { flex: 1; }
.wz-nav #wzPrev { flex: 0 0 38%; }

.wz-radio, .wz-check {
  display: flex; align-items: center; gap: 11px; padding: 12px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: 15px;
}
.wz-radio:last-of-type { border-bottom: none; }
.wz-radio input, .wz-check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.wz-check { border: none; padding: 10px 0; }

.wz-part { padding: 12px 0; border-bottom: 1px solid var(--border); }
.wz-part:last-child { border-bottom: none; }
.wz-part .an { color: var(--faint); font-size: 12px; font-weight: 500; }
.wz-part-photo {
  margin: 10px 0 2px 31px; padding: 12px; border-radius: var(--radius-s);
  background: var(--surface-2); border: 1px solid var(--border);
}
.wz-badge-cam {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  color: var(--warning); margin-bottom: 8px;
}
.wz-part-photo .field { margin-bottom: 10px; }
.field select {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 13px; color: var(--text); font-size: 16px;
  outline: none; font-family: inherit;
}
.field select:focus { border-color: var(--accent); }

.wz-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.wz-chip {
  padding: 11px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600;
  cursor: pointer; user-select: none;
}
.wz-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.wz-doc { padding: 12px 0; border-bottom: 1px solid var(--border); }
.wz-doc:last-of-type { border-bottom: none; }
.wz-doc-h { font-weight: 650; margin-bottom: 10px; }
.wz-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 4px; }
.wz-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border-strong); }
.wz-thumb.ok { display: grid; place-items: center; background: rgba(56,211,159,.15); color: var(--success); font-weight: 800; }
.wz-thumb-empty { color: var(--faint); font-size: 13px; }

.sum-sig { margin-top: 12px; }
.sum-sig:first-child { margin-top: 0; }
.sum-sig-lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.sum-sig img { width: 100%; max-height: 120px; object-fit: contain; background: #f7f8fc; border-radius: 10px; }

/* ---- Kartendienst-Auswahl (Bottom-Sheet) ----------------------------- */
.nav-pref { font-size: 12px; color: var(--faint); text-align: center; margin: 10px 0 0; }
.nav-pref b { color: var(--muted); }
.nav-pref .chg { color: var(--accent); cursor: pointer; font-weight: 600; }

.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 560px;
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .24s ease;
  display: flex; flex-direction: column; gap: 10px;
}
.sheet-overlay.open .sheet { transform: none; }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 2px auto 6px; }
.sheet-title { font-weight: 750; font-size: 16px; text-align: center; }
.sheet-sub { font-size: 12px; color: var(--faint); text-align: center; margin: -4px 0 6px; word-break: break-word; }
.sheet .btn { justify-content: center; }
.sheet-remember { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 13px; padding: 4px 0; cursor: pointer; user-select: none; }
.sheet-remember input { width: 18px; height: 18px; accent-color: var(--accent); }
