:root {
  --bg: #fff7ee;
  --card: #fff;
  --field: #fffaf4;
  --ink: #33241a;
  --muted: #86705f;
  --line: #f0e1d1;
  --soft: #fdeedd;
  --accent: #e8590c;
  --on-accent: #fff;
  --danger: #c92a4a;
  --ok: #2f9e44;
  --warn: #e08a00;
  --info: #7b8794;
  --shadow: 0 1px 2px rgba(120, 60, 10, .07), 0 4px 16px rgba(120, 60, 10, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
  --tabh: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.4 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { border-radius: 8px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-transform: uppercase;
}
.pill {
  border: 1px solid var(--warn); background: #fff4dc; color: #8a5a00;
  border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600;
}
.pill.bad { border-color: var(--danger); background: #ffe3e8; color: var(--danger); }

#offline { margin: 0; padding: 6px 16px; background: #fff4dc; color: #8a5a00; font-size: 13px; text-align: center; }

main { padding: 12px 16px calc(var(--tabh) + var(--safe-b) + 90px); max-width: 900px; margin: 0 auto; }

/* ---- bottom tabs and the camera button ---- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; border: 0; background: none; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tabs button .ico { font-size: 20px; }
body[data-view="raeume"] .tabs [data-view="raeume"],
body[data-view="raum"] .tabs [data-view="raeume"],
body[data-view="plaene"] .tabs [data-view="plaene"],
body[data-view="maengel"] .tabs [data-view="maengel"],
body[data-view="suche"] .tabs [data-view="suche"] { color: var(--accent); font-weight: 700; }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabh) + var(--safe-b) + 14px); z-index: 11;
  width: 62px; height: 62px; border-radius: 50%; border: 0; font-size: 28px;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 22px rgba(232, 89, 12, .45);
}

/* ---- rooms ---- */
.summary { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.level { margin: 18px 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.room {
  text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--r);
  padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-height: 76px;
}
.room b { font-size: 15px; line-height: 1.2; }
.room .count { color: var(--muted); font-size: 13px; }
.room .open { color: var(--danger); font-weight: 600; }
.room.add { border-style: dashed; color: var(--muted); align-items: center; justify-content: center; box-shadow: none; background: none; }

.pagehead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pagehead h2 { flex: 1; font-size: 20px; }
.back, .iconbtn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 38px; height: 38px; font-size: 18px;
}

/* ---- filter chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.s-offen[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); }
.chip.s-gemeldet[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); }
.chip.s-behoben[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.chip.s-info[aria-pressed="true"] { background: var(--info); border-color: var(--info); }

/* ---- photo grid and list ---- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.tile {
  position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--soft);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .when {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 11px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.dot { position: absolute; top: 6px; right: 6px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; background: var(--info); }
.dot.s-offen { background: var(--danger); }
.dot.s-gemeldet { background: var(--warn); }
.dot.s-behoben { background: var(--ok); }
.wait { position: absolute; top: 4px; left: 4px; font-size: 16px; background: rgba(255, 255, 255, .85); border-radius: 8px; padding: 0 4px; }
.hasnote { position: absolute; bottom: 4px; right: 4px; font-size: 13px; }
.nr { position: absolute; top: 4px; left: 4px; font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .9); border-radius: 8px; padding: 0 5px; }
.defect-box { display: flex; flex-direction: column; gap: 6px; }
.defect-block { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); }
.defect-block .field input { font-size: 18px; font-weight: 700; }
.defect-block .actions .btn { padding: 8px 12px; font-size: 14px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row-card {
  display: flex; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--r); padding: 8px; box-shadow: var(--shadow); width: 100%;
}
.row-card img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; flex: none; background: var(--soft); }
.row-card .txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-card .room-name { font-weight: 700; }
.row-card .note { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-card .meta { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: 12px; color: #fff; background: var(--info); }
.badge.s-offen { background: var(--danger); }
.badge.s-gemeldet { background: var(--warn); }
.badge.s-behoben { background: var(--ok); }

/* ---- plans ---- */
.row-card .pdf { width: 52px; height: 64px; flex: none; border-radius: 8px; background: var(--soft); display: grid; place-items: center; font-size: 26px; }
.row-card .plan-title { font-weight: 700; overflow-wrap: anywhere; }
.badge.here { background: var(--ok); }
.badge.cloud { background: var(--info); }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.plans-actions { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
a.btn { text-decoration: none; color: inherit; text-align: center; display: inline-block; }
a.btn.primary { color: var(--on-accent); }

.search {
  width: 100%; font: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.empty { color: var(--muted); text-align: center; padding: 36px 8px; }

/* ---- sheet (dialog) ---- */
dialog#sheet {
  width: min(560px, 100%); max-height: 100%; margin: auto auto 0; padding: 0; border: 0; border-radius: 20px 20px 0 0;
  background: var(--card); color: var(--ink);
}
@media (min-width: 640px) { dialog#sheet { margin: auto; border-radius: 20px; } }
dialog#sheet::backdrop { background: rgba(40, 20, 5, .45); }
.sheet { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px calc(16px + var(--safe-b)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { font-size: 18px; }
.close { border: 0; background: var(--soft); border-radius: 50%; width: 34px; height: 34px; font-size: 16px; }
.shot { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 12px; background: #1c130d; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; color: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); width: 100%;
}
.field textarea { min-height: 84px; resize: vertical; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .grow { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 16px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.nav button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 4px 14px; font-size: 18px; }
.nav button:disabled { opacity: .35; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list a.btn { text-decoration: none; text-align: center; color: inherit; }
.qrow { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.qrow img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.qrow .txt { flex: 1; min-width: 0; font-size: 13px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 90px); transform: translateX(-50%); z-index: 30;
  background: #33241a; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; max-width: 90vw; text-align: center;
}

/* ---- login ---- */
body.login-page { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-card h1 { font-size: 28px; }
.login-card form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.login-logo { border-radius: 18px; }
.login-msg { min-height: 1.2em; color: var(--danger); font-size: 14px; }
