:root {
  --bg: #14181a;
  --panel: #1d2326;
  --panel2: #232b2e;
  --ink: #e8e6df;
  --ink-soft: #9aa49e;
  --rule: #2e383c;
  --pine: #4e7257;
  --pine-bright: #6fae7d;
  --rust: #c07a52;
  --red: #c75545;
  --amber: #d9a13f;
  --green: #5fa36d;
  --blue: #5c84a8;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 15px -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

header.app {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px calc(10px); padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--panel); border-bottom: 1px solid var(--rule);
}
header.app h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: 0.2px; }
header.app .ver { font-size: 10.5px; color: var(--ink-soft); margin-left: 6px; font-weight: 400; }
.hdr-right { display: flex; align-items: center; gap: 10px; }
.sync-pill { font-size: 11px; color: var(--ink-soft); padding: 4px 9px; border: 1px solid var(--rule); border-radius: 20px; }
.sync-pill.err { color: var(--red); border-color: var(--red); }
.who { font-size: 12px; color: var(--ink-soft); }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--panel); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
nav.tabs button {
  flex: 1; min-height: 52px; background: none; border: none; color: var(--ink-soft);
  font: 600 12px -apple-system, sans-serif; cursor: pointer; padding: 6px 0;
}
nav.tabs button .ico { display: block; font-size: 19px; margin-bottom: 2px; }
nav.tabs button.active { color: var(--pine-bright); }

main { max-width: 760px; margin: 0 auto; padding: 12px 10px 20px; }
@media (min-width: 900px) { main { max-width: 1100px; } }

.bldg { margin-bottom: 16px; }
.bldg-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 4px 6px; color: var(--pine-bright); font-weight: 700; font-size: 13.5px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.bldg-head .bt { color: var(--rust); font-size: 11.5px; font-weight: 600; text-transform: none; }
.cards { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .cards { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 10px;
  padding: 11px 12px; cursor: pointer;
}
.card:active { background: var(--panel2); }
.card-top { display: flex; align-items: center; gap: 8px; }
.occ-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rule); flex: 0 0 auto; }
.occ-dot.occ { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.occ-dot.exp { background: transparent; border: 2px solid var(--amber); width: 8px; height: 8px;
  animation: expPulse 2s ease-in-out infinite; }
@keyframes expPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.card-top .uname { font-weight: 700; font-size: 15px; flex: 1; }
.chip {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 14px; white-space: nowrap;
}
.chip.dirty { background: #3d2320; color: #ff9c8a; border: 1px solid var(--red); }
.chip.clean { background: #333019; color: #ffd98a; border: 1px solid var(--amber); }
.chip.inspected { background: #1d3324; color: #8fe0a2; border: 1px solid var(--green); }
.card-res { margin-top: 7px; font-size: 13px; color: var(--ink-soft); line-height: 1.45; }
.card-res .gname { color: var(--ink); font-weight: 600; }
.badge { font-size: 12px; margin-left: 5px; }
.card-foot { margin-top: 6px; display: flex; gap: 10px; font-size: 11.5px; color: var(--ink-soft); }
.card-foot .tasks-n { color: var(--rust); font-weight: 700; }

/* task list */
.task-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.task-filters select, .task-filters input[type=text] {
  background: var(--panel); color: var(--ink); border: 1px solid var(--rule);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.task {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start;
}
.task.p-urgent { border-left: 4px solid var(--red); }
.task.p-high { border-left: 4px solid var(--amber); }
.task.p-normal { border-left: 4px solid var(--pine); }
.task.p-low { border-left: 4px solid var(--rule); }
.task .tk-main { flex: 1; min-width: 0; }
.task .tk-label { font-weight: 600; font-size: 14.5px; }
.task .tk-where { font-size: 11.5px; color: var(--pine-bright); font-weight: 600; margin-top: 2px; }
.task .tk-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.task .tk-notes { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; white-space: pre-wrap; }
.tk-check {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--pine);
  background: none; cursor: pointer; font-size: 16px; color: var(--pine-bright);
}
.flag { color: var(--amber); }

button.btn {
  background: var(--pine); color: #fff; border: none; border-radius: 9px;
  font: 600 14px -apple-system, sans-serif; padding: 12px 16px; cursor: pointer; min-height: 44px;
}
button.btn.secondary { background: var(--panel2); color: var(--ink); border: 1px solid var(--rule); }
button.btn.danger { background: var(--red); }
button.btn:disabled { opacity: 0.5; }

/* overlay / sheets */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .overlay { align-items: center; } }
.sheet {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 700px; max-height: 88vh; overflow-y: auto; padding: 16px 16px 24px;
}
@media (min-width: 700px) { .sheet { border-radius: 16px; } }
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet .sub { color: var(--ink-soft); font-size: 12.5px; margin-bottom: 12px; }
.sheet-close { float: right; background: none; border: none; color: var(--ink-soft); font-size: 22px; cursor: pointer; padding: 2px 8px; }
.sheet section { margin-top: 16px; }
.sheet section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-soft); margin: 0 0 8px; }

.confirm-box {
  background: var(--panel2); border: 1px solid var(--rule); border-radius: 12px;
  padding: 14px; text-align: center;
}
.confirm-box .q { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.confirm-box .row { display: flex; gap: 10px; justify-content: center; }

.state-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.note-row { display: flex; gap: 8px; margin-top: 8px; }
.note-row textarea {
  flex: 1; background: var(--panel2); color: var(--ink); border: 1px solid var(--rule);
  border-radius: 8px; padding: 9px; font: 13.5px -apple-system, sans-serif; min-height: 44px; resize: vertical;
}
.note { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.note .nm { color: var(--pine-bright); font-weight: 600; font-size: 11.5px; }
.note .dt { color: var(--ink-soft); font-size: 11px; margin-left: 6px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--rule); }

.res-line { font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 8px; }
.res-line .rdates { color: var(--ink-soft); white-space: nowrap; font-size: 12.5px; }

form.auth { max-width: 360px; margin: 10vh auto; padding: 0 20px; }
form.auth h1 { font-size: 22px; }
form.auth label { display: block; font-size: 12px; color: var(--ink-soft); margin: 14px 0 5px; }
form.auth input {
  width: 100%; background: var(--panel); color: var(--ink); border: 1px solid var(--rule);
  border-radius: 9px; padding: 13px 12px; font-size: 16px;
}
form.auth button { width: 100%; margin-top: 18px; }
.auth-err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.trust-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13.5px; color: var(--ink-soft); }
.trust-row input { width: auto; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.admin-table th, .admin-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--rule); }
.admin-table th { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; }
.muted { color: var(--ink-soft); }
.empty { color: var(--ink-soft); font-style: italic; padding: 16px 4px; }
