:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #24211E;
  --ink-2: #6b6b6b;
  --ink-3: #a0a0a0;
  --line: #e6e9ec;
  --brand: #1E98CB;
  --brand-dark: #14688C;
  --brand-soft: #E1F1FA;
  --ok: #2f7a4d;
  --ok-soft: #e3f1e9;
  --warn: #b6851a;
  --nav-h: calc(64px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink); min-height: 100vh; -webkit-font-smoothing: antialiased;
}

/* ============ LOGIN =============================================== */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-shell { width: 100%; max-width: 380px; }
.login-card { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; }
.login-logo { display: block; width: 200px; margin: 0 auto 14px; }
.login-card h1 { font-size: 22px; font-weight: 500; text-align: center; margin: 0 0 4px; }
.login-card p.muted { text-align: center; color: var(--ink-2); font-size: 14px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; margin: 10px 0 6px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 15px; background: white; font-family: inherit; color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--brand); }
.form-error { background: #fdecea; color: #a4342e; padding: 10px 14px; border-radius: 12px; font-size: 13px; margin-top: 12px; }

/* ============ BUTTONS ============================================= */
.btn {
  border: none; border-radius: 12px; padding: 10px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--brand); color: white; }
.btn.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn.success { background: var(--ok); color: white; }
.btn.full { width: 100%; }
.btn.big { padding: 14px 20px; font-size: 15px; border-radius: 14px; }

/* ============ APP-SHELL =========================================== */
body.app { padding-bottom: env(safe-area-inset-bottom); }
.app-shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 640px; margin: 0 auto; background: var(--bg); position: relative; }
.app-topbar {
  padding: 14px 16px 10px; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); position: sticky; top: 0; z-index: 5;
}
.app-title-main { font-size: 22px; font-weight: 500; line-height: 1.1; display: block; }
.app-title-sub { font-size: 13px; color: var(--ink-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px;
  border: none; padding: 0; cursor: pointer; font-family: inherit;
}
.avatar:active { transform: scale(0.94); }
.app-body { flex: 1; padding: 0 16px calc(var(--nav-h) + 24px); }
.loading { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 14px; }

/* ============ CARDS =============================================== */
.section-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 4px 8px; font-weight: 500; }
.job-card {
  background: var(--surface); border-radius: 16px; padding: 14px 16px;
  margin-bottom: 12px; cursor: pointer; border: 1px solid var(--line);
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.job-card:active { transform: scale(0.99); }
.job-time-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.job-time { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.status-dot.geplant { background: var(--ink-3); }
.status-dot.unterwegs { background: var(--brand); }
.status-dot.vor_ort { background: var(--brand-dark); }
.status-dot.erledigt { background: var(--ok); }
.status-chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: #eeeeeb; color: var(--ink-2); font-weight: 500;
}
.status-chip.geplant { background: #eeeeeb; color: var(--ink-2); }
.status-chip.unterwegs { background: var(--brand-soft); color: var(--brand-dark); }
.status-chip.vor_ort { background: var(--brand-soft); color: var(--brand-dark); }
.status-chip.erledigt { background: var(--ok-soft); color: var(--ok); }
.job-customer { font-size: 16px; font-weight: 500; line-height: 1.3; margin-bottom: 2px; }
.job-meta { font-size: 13px; color: var(--ink-2); line-height: 1.4; margin-bottom: 8px; }

/* ============ FAB ================================================= */
.fab {
  position: fixed; right: 20px; bottom: calc(var(--nav-h) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: white; border: none;
  font-size: 28px; font-weight: 300;
  box-shadow: 0 8px 22px rgba(30, 152, 203, 0.4);
  cursor: pointer; z-index: 8; font-family: inherit; line-height: 1;
}
.fab:active { transform: scale(0.94); }

/* ============ NAV ================================================= */
.app-nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h);
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; padding: 8px 0 env(safe-area-inset-bottom);
  z-index: 10;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; color: var(--ink-3);
  font-family: inherit; font-size: 11px; cursor: pointer; padding: 4px 0;
}
.nav-item.active { color: var(--brand); }

/* ============ DETAIL / FORMS ====================================== */
.detail-head { padding: 6px 0 12px; display: flex; align-items: center; gap: 12px; }
.back-btn {
  width: 36px; height: 36px; border-radius: 50%; background: white;
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; color: var(--ink); font-family: inherit;
}
.detail-title { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.detail-block { background: var(--surface); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.detail-block h3 { font-size: 18px; font-weight: 500; margin: 0 0 4px; line-height: 1.2; }
.detail-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.detail-row:first-of-type { border-top: none; padding-top: 4px; }
.detail-text { flex: 1; font-size: 14px; line-height: 1.45; }
.detail-text .label { font-size: 12px; color: var(--ink-3); margin-bottom: 1px; }
.detail-text a { color: var(--brand); text-decoration: none; font-weight: 500; }

.status-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 4px; }
.status-option {
  background: white; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; text-align: center; font-size: 12px; font-weight: 500;
  color: var(--ink-2); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.status-option.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.action-strip {
  padding: 12px 16px; background: rgba(244,246,248,0.96);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  position: fixed; left: 0; right: 0; bottom: var(--nav-h);
  display: flex; gap: 8px; z-index: 6;
}

.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; margin-bottom: 6px; }
.form-input, .form-select, .textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 15px; background: white; font-family: inherit; color: var(--ink);
}
.textarea { resize: none; min-height: 80px; font-size: 14px; }
.form-input:focus, .form-select:focus, .textarea:focus { outline: none; border-color: var(--brand); }
.time-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.time-pair .to { color: var(--ink-3); font-size: 13px; text-align: center; }
.form-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.chip-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-option {
  background: white; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; font-weight: 500; color: var(--ink);
}
.chip-option.active { background: var(--brand); color: white; border-color: var(--brand); }

.day-block { background: white; border-radius: 16px; margin-bottom: 12px; border: 1px solid var(--line); overflow: hidden; }
.day-head { padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.day-head .name { font-size: 13px; font-weight: 500; }
.day-head .count { font-size: 12px; color: var(--ink-3); }
.day-item { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); cursor: pointer; }
.day-item:first-of-type { border-top: none; }
.day-item .li-time { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 1px; }
.day-item .li-name { font-size: 14px; font-weight: 500; }

.empty { text-align: center; color: var(--ink-3); font-size: 14px; padding: 40px 0; }
.day-empty { padding: 12px 14px; color: var(--ink-3); font-size: 13px; text-align: center; }
.hint-note { text-align: center; color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.current-slot { padding: 12px 14px; background: #fafbfc; border-radius: 12px; font-size: 14px; line-height: 1.4; }

/* Week navigation */
.week-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 4px 4px 8px;
}
.week-btn { min-width: 44px; padding: 10px 14px !important; font-size: 18px !important; }
.week-label { flex: 1; text-align: center; font-size: 14px; font-weight: 500; color: var(--ink); }
.week-jump-row { text-align: center; margin-bottom: 14px; }
.week-jump { background: transparent; color: var(--brand); font-size: 12px; padding: 4px 12px; border: 1px solid transparent; }

/* Bottom sheet */
.sheet-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 30, 50, 0.4);
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  animation: sheetFade 0.15s ease-out;
}
@keyframes sheetFade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: white;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 8px 20px 32px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: sheetUp 0.2s ease-out;
}
@keyframes sheetUp { from { transform: translateY(30px); } to { transform: translateY(0); } }
.sheet-handle {
  width: 40px; height: 4px; background: #d5d9de;
  border-radius: 2px; margin: 8px auto 14px;
}
.sheet-title { font-size: 18px; font-weight: 500; margin: 0 0 12px; }

.btn.ghost { background: transparent; color: var(--ink-2); }

/* Plan / Ist Delta */
.delta-plus  { color: var(--warn); font-weight: 500; }
.delta-minus { color: var(--ok);   font-weight: 500; }

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; z-index: 20;
  top: 100%; left: 0; right: 0;
  background: white; border: 1px solid var(--line);
  border-radius: 12px; margin-top: 4px;
  max-height: 260px; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,0.10);
}
.ac-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--brand-soft); }
.ac-name { font-size: 14px; font-weight: 500; color: var(--ink); }
.ac-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.ac-empty { padding: 12px 14px; color: var(--ink-3); font-size: 13px; text-align: center; }

.opt { color: var(--ink-3); font-weight: 400; font-size: 11px; }

.detail-block.time-running { border-color: var(--brand); background: var(--brand-soft); }
.detail-block.time-running .time-hero { background: transparent; border: none; padding: 8px 0; }
.detail-block.time-running .time-hero .big { color: var(--brand-dark); }
