:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7688;
  --line: #e3e7ee;
  --brand: #1d5fd1;
  --brand-dark: #16489e;
  --brand-soft: #e8effc;
  --green: #1e9e5a;
  --green-soft: #e4f6ec;
  --orange: #e07c10;
  --orange-soft: #fdf1e0;
  --red: #d43d3d;
  --red-soft: #fbe9e9;
  --blue: #2673d6;
  --blue-soft: #e7f0fc;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 30, 60, .08);
  --nav-h: 62px;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(135deg, #16325e, #1d5fd1);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 26px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-sub { font-size: 12px; opacity: .75; }

.timer-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.3);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 46vw;
}
.timer-chip #timerLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6ef09a;
  animation: pulse 1.4s infinite;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Layout ---------- */
.main { max-width: 860px; margin: 0 auto; padding: 16px; }

.view-title {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.section-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 20px 0 8px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card.tappable { cursor: pointer; transition: transform .06s; }
.card.tappable:active { transform: scale(.985); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px 16px;
  font-size: 15px;
}
.empty .empty-ico { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  text-align: center;
  cursor: pointer;
}
.stat-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat.warn .stat-num { color: var(--red); }
.stat.open .stat-num { color: var(--orange); }
.stat.done .stat-num { color: var(--green); }

/* ---------- Auftrag rows ---------- */
.job-row { display: flex; gap: 12px; align-items: flex-start; }
.job-main { flex: 1; min-width: 0; }
.job-title { font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.job-meta { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.job-meta .overdue { color: var(--red); font-weight: 650; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.offen { background: var(--orange-soft); color: var(--orange); }
.badge.in_arbeit { background: var(--blue-soft); color: var(--blue); }
.badge.erledigt { background: var(--green-soft); color: var(--green); }
.badge.recur { background: var(--brand-soft); color: var(--brand); }

.prio-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.prio-hoch { background: var(--red); }
.prio-normal { background: #c3cad6; }
.prio-niedrig { background: #c3cad6; opacity: .4; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  font-family: inherit;
  background: var(--brand);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .85; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.green { background: var(--green); }
.btn.red-soft { background: var(--red-soft); color: var(--red); }
.btn.small { padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row .btn { flex: 1; }

.fab-wrap { position: sticky; bottom: calc(var(--nav-h) + 14px); display: flex; justify-content: flex-end; pointer-events: none; margin-top: 8px; }
.fab {
  pointer-events: auto;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 14px rgba(29, 95, 209, .45);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
}
.navbtn {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.navbtn .nav-ico { font-size: 21px; }
.navbtn.active { color: var(--brand); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: var(--card);
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-head h2 { font-size: 18px; }
.modal-close {
  border: none; background: var(--bg); color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 16px; cursor: pointer; flex-shrink: 0;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* ---------- Detail ---------- */
.detail-block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.detail-block h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.detail-desc { white-space: pre-wrap; font-size: 15px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; cursor: pointer; display: block;
  border: 1px solid var(--line);
}
.photo-view img { max-width: 100%; border-radius: 12px; }

.time-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14.5px;
}
.time-row:last-child { border-bottom: none; }
.time-row .t-min { font-weight: 700; }
.time-del { border: none; background: none; color: var(--red); cursor: pointer; font-size: 15px; padding: 4px 6px; }

.kv { display: flex; gap: 8px; font-size: 14.5px; margin-bottom: 5px; }
.kv .k { color: var(--muted); min-width: 110px; flex-shrink: 0; }
.kv a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* ---------- Zeiten report ---------- */
.report-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.report-table th, .report-table td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
.report-table th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.report-table td.num, .report-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tr.total td { font-weight: 800; border-top: 2px solid var(--text); border-bottom: none; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav .btn { flex: 0 0 auto; }
.month-nav .month-label { font-weight: 700; font-size: 16px; }

/* ---------- Mehr ---------- */
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  border: none;
  width: 100%;
  font-family: inherit;
  color: var(--text);
  text-align: left;
}
.menu-item .mi-ico { font-size: 20px; }
.menu-item .mi-sub { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 18px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2233;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  max-width: 88vw;
  text-align: center;
}

/* ---------- Desktop tweaks ---------- */
@media (min-width: 860px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .photo-grid { grid-template-columns: repeat(5, 1fr); }
}
