/* Wo ist der Bagger? – große Schaltflächen, hoher Kontrast, gut bedienbar mit Handschuhen und in der Sonne. */

:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --line: #deded8;
  --accent: #f5b301;
  --accent-text: #1c1c1a;
  --ok: #1f8a3b;
  --warn: #b86e00;
  --bad: #c62828;
  --info: #1565c0;
  --radius: 14px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #222220;
    --text: #f1f1ec;
    --muted: #a3a39c;
    --line: #3a3a36;
    --ok: #4cc26a;
    --warn: #f0a33a;
    --bad: #ff6b60;
    --info: #64a8ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}
a { color: var(--info); }
h1 { font-size: 1.5rem; margin: 0.2em 0; }
h2 { font-size: 1.1rem; margin: 1.4em 0 0.5em; }
h3 { font-size: 1rem; margin: 1em 0 0.4em; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.center { text-align: center; }
.prewrap { white-space: pre-wrap; }
.overdue, .bad-text { color: var(--bad); font-weight: 600; }
[hidden] { display: none !important; }

/* Kopfzeile */
header#top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: env(safe-area-inset-top, 0) 12px 0;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
#title { flex: 1; font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; font-size: 2.2rem; line-height: 1; padding: 0 8px 4px 0; color: inherit; cursor: pointer; }
.sync-badge {
  text-decoration: none; color: var(--accent-text); background: rgba(255,255,255,.55);
  padding: 4px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
}
.sync-badge.warn { background: #fff3cd; }
.sync-badge.bad { background: #ffd6d2; }
.sync-badge.off { background: #333; color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px; overflow-x: clip; }

/* Untere Navigation */
nav#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
nav#nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.75rem; color: var(--muted); text-decoration: none; gap: 2px;
}
nav#nav a b { font-size: 1.4rem; line-height: 1; filter: grayscale(0.6); }
nav#nav a.active { color: var(--text); font-weight: 700; }
nav#nav a.active b { filter: none; }
nav#nav a.nav-new b {
  background: var(--accent); border-radius: 50%; width: 44px; height: 44px;
  display: grid; place-items: center; filter: none; margin-top: -14px; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
body.login-mode nav#nav { display: none; }

/* Schaltflächen */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 16px; border-radius: var(--radius);
  border: 2px solid transparent; background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
}
.btn.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.warn { background: #ffe1b3; color: #5a3500; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.link { background: none; border: 0; color: var(--info); min-height: 36px; padding: 4px 8px; font-weight: 500; }
.btn.link.danger { color: var(--bad); background: none; }
.btn.big { min-height: 56px; font-size: 1.1rem; }
.btn.block { display: flex; width: 100%; margin: 8px 0; }
.btn:disabled { opacity: 0.5; }
.btn:active { transform: scale(0.98); }

.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.big-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 92px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line);
  color: var(--text); text-decoration: none; font-weight: 700;
}
.big-btn b { font-size: 2rem; line-height: 1; }
.big-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }

/* Suche und Chips */
.search-bar input, input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-height: 50px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.search-bar input { font-size: 1.1rem; }
.search-bar.sticky { position: sticky; top: 56px; z-index: 10; background: var(--bg); padding: 6px 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; font: inherit; font-size: 0.92rem; padding: 8px 14px; min-height: 40px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Karten und Listen */
.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.card-pad { padding: 20px; background: var(--surface); border-radius: var(--radius); }
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 700; overflow-wrap: anywhere; }
.card-sub, .card-where { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.card-where { color: var(--text); }
.thumb {
  flex: none; width: 64px; height: 64px; border-radius: 10px; overflow: hidden;
  background: var(--bg); display: grid; place-items: center; font-size: 2rem;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.count { min-width: 36px; text-align: center; font-weight: 700; background: var(--bg); border-radius: 999px; padding: 4px 8px; }
.add-card { justify-content: center; color: var(--info); border-style: dashed; min-height: 56px; }
.pending { font-size: 0.85rem; }

.badge {
  flex: none; display: inline-block; font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok { background: var(--ok); color: #fff; border-color: transparent; }
.badge.warn { background: var(--warn); color: #fff; border-color: transparent; }
.badge.bad { background: var(--bad); color: #fff; border-color: transparent; }
.badge.info { background: var(--info); color: #fff; border-color: transparent; }

.event-row {
  display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 10px 12px;
  background: var(--surface); border-radius: 10px; text-decoration: none; color: var(--text); font-size: 0.93rem;
}
.event-row span { grid-column: 1; color: var(--muted); }
.event-row small { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); }
.list.compact { gap: 4px; }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.notice { background: #fff3cd; color: #5a4300; padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.notice a { color: inherit; font-weight: 700; }

/* Detail */
.detail-photo {
  margin: -12px -16px 12px; background: #000; max-height: 46vh; display: grid; place-items: center; overflow: hidden;
}
.detail-photo img { width: 100%; max-height: 46vh; object-fit: contain; cursor: zoom-in; }
.detail-photo.empty { background: var(--surface); font-size: 5rem; min-height: 140px; }
.detail-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.where-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; margin: 10px 0;
}
.where-main { font-size: 1.2rem; font-weight: 700; }
.where-box .btn { align-self: flex-start; }

.history { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: flex; gap: 10px; background: var(--surface); padding: 10px 12px; border-radius: 10px; }
.history-text { flex: 1; min-width: 0; }
.history-text small { display: block; color: var(--muted); margin-top: 2px; }
.history-photo { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.95rem; }
.form label input, .form label select, .form label textarea { font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 700; margin-bottom: 6px; }
details { background: var(--surface); border-radius: var(--radius); padding: 4px 14px; border: 1px solid var(--line); }
details[open] { padding-bottom: 14px; }
details > summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details .form, details > label { margin-top: 10px; }
details > label { display: flex; flex-direction: column; gap: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; flex-direction: column; gap: 10px; }
.sticky-bottom {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px); z-index: 5;
}
.sticky-bottom .btn { box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.geo { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.status-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip-radio { position: relative; }
.chip-radio input, .choice input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; min-height: 0; padding: 0; }
.chip-radio span {
  display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 8px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; cursor: pointer;
}
.chip-radio input:checked + span { border-color: var(--text); background: var(--text); color: var(--bg); }
.chip-radio.ok input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip-radio.warn input:checked + span { background: var(--warn); border-color: var(--warn); color: #fff; }
.chip-radio.bad input:checked + span { background: var(--bad); border-color: var(--bad); color: #fff; }
.chip-radio.info input:checked + span { background: var(--info); border-color: var(--info); color: #fff; }
.chip-radio input:focus-visible + span { outline: 3px solid var(--accent); }

.loc-choice { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; }
.choice { position: relative; display: block; cursor: pointer; }

.choice span, .choice.add {
  display: flex; flex-direction: column; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: var(--radius); background: var(--surface); font-weight: 400;
}
.choice span small { color: var(--muted); }
.choice input:checked + span { border-color: var(--accent); background: #fff6d6; color: #1c1c1a; }
.choice input:disabled + span { opacity: 0.5; }
.choice.add { text-decoration: none; color: var(--info); border-style: dashed; }

.photo-picker { display: flex; flex-direction: column; gap: 8px; }
.photo-preview {
  height: 200px; border-radius: var(--radius); background: var(--surface); border: 2px dashed var(--line);
  display: grid; place-items: center; overflow: hidden; font-size: 3rem;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-buttons .btn { font-size: 0.95rem; }

/* Login */
.login { max-width: 420px; margin: 24px auto; display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.login-logo { text-align: center; }
.login-logo img { width: 96px; height: 96px; border-radius: 22px; }
.login h1 { text-align: center; }

/* Verwaltung */
details.card { display: block; padding: 0 14px; }
details.card[open] { padding-bottom: 14px; }
.user-card summary { display: flex; list-style: none; padding: 12px 0; }
.user-card.inactive { opacity: 0.65; }
.session-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.session-row small { color: var(--muted); }
.op-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.op-list small { color: var(--muted); }
.handover { line-height: 1.7; }

/* Mandanten */
#logo { height: 36px; max-width: 96px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.acting-bar {
  position: sticky; top: 56px; z-index: 19; background: #1565c0; color: #fff;
  padding: 8px 16px; font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center;
}
.acting-bar a { color: #fff; font-weight: 700; }
.login-logo img.tenant-logo { width: auto; height: auto; max-width: 220px; max-height: 110px; border-radius: 0; object-fit: contain; }
.tenant-card summary { display: flex; align-items: center; gap: 12px; list-style: none; padding: 10px 0; }
.tenant-card.inactive { opacity: 0.65; }
.tenant-card .thumb img, .logo-preview img { object-fit: contain; background: #fff; }
.logo-picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-preview {
  width: 120px; height: 72px; border: 2px dashed var(--line); border-radius: 10px;
  display: grid; place-items: center; overflow: hidden; background: #fff;
}
.logo-preview img { max-width: 100%; max-height: 100%; }
label.inline { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 400 !important; }
label.inline input { width: auto; min-height: 0; }
.label-logo { max-height: 22px; max-width: 110px; margin-top: 4px; }

/* Karte */
body.map-open { overflow: hidden; }
.map-picker {
  position: fixed; inset: 0; z-index: 90; background: var(--bg);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
.map-top { position: relative; padding: 8px 12px; background: var(--accent); }
.map-search { display: flex; gap: 8px; }
.map-search input { flex: 1; }
.map-search .btn { background: var(--surface); color: var(--text); }
.map-results {
  position: absolute; left: 12px; right: 12px; top: 100%; z-index: 1000; max-height: 50vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.map-results button {
  display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--text); font: inherit; font-size: 0.93rem; cursor: pointer;
}
.map-results p { padding: 12px 14px; margin: 0; }
.map-canvas { flex: 1; min-height: 200px; }
.map-hint { text-align: center; font-size: 0.85rem; color: var(--muted); padding: 6px; }
.map-actions { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; padding: 0 12px 12px; }
.map-actions .btn { padding: 8px; font-size: 0.95rem; }
.mini-map { height: 180px; border-radius: 10px; overflow: hidden; z-index: 0; }
.leaflet-container { font: inherit; }

/* Etiketten */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.label {
  display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px dashed #999;
  background: #fff; color: #000; border-radius: 6px; break-inside: avoid;
}
.label img { width: 96px; height: 96px; flex: none; }

/* Meldungen */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); transform: translate(-50%, 20px);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; font-weight: 600; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--bad); }
.update-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60; background: #222; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px;
}
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 70; display: grid; place-items: center; }
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

.spinner {
  display: inline-block; width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle;
}
.spinner.small { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Breiter Bildschirm (Büro-PC, Tablet) */
@media (min-width: 720px) {
  .big-actions { grid-template-columns: repeat(4, 1fr); }
  .action-grid { grid-template-columns: repeat(4, 1fr); }
  .status-choice { grid-template-columns: repeat(4, 1fr); }
}

@media print {
  header#top, nav#nav, .no-print, .toast { display: none !important; }
  body { background: #fff; padding: 0; }
  main { max-width: none; padding: 0; }
  .labels { grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .label { border: 1px solid #000; }
}
