:root {
  --bg: #f4f6f2;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #66736b;
  --line: #e2e7e0;
  --brand: #2f6f4f;
  --brand-dark: #234f39;
  --brand-soft: #e3f0e8;
  --accent: #e08a2e;
  --danger: #c8372d;
  --danger-soft: #fdecea;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --ok: #2e7d4f;
  --ok-soft: #e5f5ea;
  --blue: #2b6cb0;
  --blue-soft: #e6f0fa;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(31,42,36,.06);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244,246,242,.92); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  padding: calc(10px + var(--safe-t)) 16px 10px; display: flex; align-items: center; gap: 10px; min-height: 56px;
  border-bottom: 1px solid transparent;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 22px; }
.topbar .title .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 22px; color: var(--ink); cursor: pointer; flex: none;
}
main { padding: 8px 16px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 760px; margin: 0 auto; }
.nonav main { padding-bottom: 40px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); display: flex; padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #7c8a81; text-decoration: none; font-size: 11.5px; font-weight: 600; position: relative;
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a.active { color: var(--brand); }
.tabbar .dot { position: absolute; top: 8px; left: calc(50% + 8px); background: var(--danger); color: #fff; font-size: 10.5px; border-radius: 9px; padding: 0 5px; min-width: 17px; line-height: 17px; text-align: center; }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
.card.tight { padding: 12px 14px; }
.card h2 + *, .card h3 + * { margin-top: 8px; }
.list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.row {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; display: flex; gap: 12px; align-items: center;
  text-decoration: none; color: inherit; min-height: 64px; border-left: 5px solid transparent; cursor: pointer;
}
.row.urgent { border-left-color: var(--danger); }
.row.done { opacity: .62; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 700; font-size: 16.5px; }
.row .s { color: var(--muted); font-size: 14px; margin-top: 2px; }
.row .chev { color: #b4beb7; font-size: 22px; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #e9ece8; flex: none; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 6px; }
.section-title h2 { font-size: 18px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; background: var(--card); border-radius: var(--radius); border: 2px dashed var(--line); }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eef1ed; color: #46534b; white-space: nowrap; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 9px 15px; font-size: 15px; font-weight: 600; cursor: pointer; min-height: 42px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.flag { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-soft); color: #7a4a00; border-radius: 12px; padding: 10px 12px; font-size: 15px; font-weight: 600; margin: 8px 0; }
.flag.ok { background: var(--ok-soft); color: var(--ok); }
.flag.red { background: var(--danger-soft); color: var(--danger); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 700; font-size: 17px;
  min-height: 52px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  text-decoration: none; font-family: inherit; transition: transform .06s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 20px; border-radius: 18px; }
.btn.huge { min-height: 88px; font-size: 26px; border-radius: 22px; letter-spacing: .04em; }
.btn.secondary { background: var(--brand-soft); color: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: var(--danger); }
.btn.danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn.orange { background: var(--accent); }
.btn.small { min-height: 42px; font-size: 15px; padding: 0 14px; border-radius: 12px; }
.btn[disabled] { background: #c9d1cb; color: #fff; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin: 12px 0; }
.btn-row > * { flex: 1; min-width: 0; }
input[type=date] { min-width: 0; display: block; }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25;
  border-radius: 999px; min-height: 56px; padding: 0 20px; box-shadow: 0 6px 20px rgba(200,55,45,.35);
}

/* ---------- forms ---------- */
label.f { display: block; margin: 14px 0 0; font-weight: 650; font-size: 15px; }
label.f > span.hint { font-weight: 400; color: var(--muted); font-size: 13.5px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=date], input:not([type]), select, textarea {
  width: 100%; font-size: 17px; font-family: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 14px; margin-top: 6px; min-height: 50px; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #7c8a81 50%), linear-gradient(135deg, #7c8a81 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,79,.15); }
.seg { display: flex; background: #e7ebe6; border-radius: 14px; padding: 4px; gap: 4px; margin-top: 6px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 11px; min-height: 46px; font-size: 16px; font-weight: 700; color: #4d5a52; cursor: pointer; font-family: inherit; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg button.on.red { color: var(--danger); }
.checkrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 16px; cursor: pointer; }
.checkrow input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
.err { color: var(--danger); font-weight: 600; margin-top: 10px; font-size: 15px; }

/* ---------- checklist ---------- */
.progress { height: 10px; background: #e3e8e2; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, #3d8b63, #2f6f4f); border-radius: 99px; transition: width .25s; }
.sec { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 14px 0; overflow: hidden; }
.sec-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; }
.sec-h h3 { flex: 1; }
.sec-h .count { font-weight: 700; font-size: 14px; color: var(--muted); }
.sec.complete .sec-h { background: var(--ok-soft); }
.sec.complete .sec-h .count { color: var(--ok); }
.sec-b { padding: 0 8px 12px; }
.sec.collapsed .sec-b { display: none; }
.item { display: flex; gap: 14px; align-items: flex-start; padding: 13px 10px; border-radius: 12px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.item + .item { border-top: 1px solid #f0f2ef; }
.item .box { width: 30px; height: 30px; border-radius: 9px; border: 2px solid #b9c3bc; flex: none; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 18px; margin-top: -2px; transition: background .12s; }
.item.on .box { background: var(--brand); border-color: var(--brand); }
.item.on .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.item .txt { font-size: 16.5px; }
.item.ro { cursor: default; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 10px 8px 4px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #e9ece8; cursor: zoom-in; display: block; }
.photo-tile { position: relative; }
.photo-tile .x { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; font-size: 15px; cursor: pointer; }
.addphoto { border: 2px dashed #b9c3bc; border-radius: 12px; background: #fafbf9; color: var(--brand); font-weight: 700; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; margin: 10px 8px 0; font-size: 16px; position: relative; }
.addphoto.need { border-color: var(--accent); color: var(--warn); background: var(--warn-soft); }
.addphoto input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-hint { margin: 6px 10px 0; font-size: 13.5px; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 440px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo img { width: 58px; height: 58px; border-radius: 15px; box-shadow: var(--shadow); }
.logo .name { font-size: 26px; font-weight: 850; letter-spacing: -.02em; }
.logo .tag { color: var(--muted); font-size: 14px; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 30px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 84px); background: #1f2a24; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; z-index: 100; max-width: 90vw; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: pop .2s; }
.toast.error { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }
.modal-bg { position: fixed; inset: 0; background: rgba(20,28,24,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 18px calc(22px + var(--safe-b)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); } }
.modal .mh { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.modal .close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #e3e8e2; font-size: 20px; cursor: pointer; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 22px; } }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 90; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: #fff; font-size: 22px; }
.house-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.house-btn { background: var(--card); border: 0; border-radius: 16px; box-shadow: var(--shadow); padding: 16px 14px; text-align: left; min-height: 92px; cursor: pointer; font-family: inherit; color: var(--ink); text-decoration: none; display: block; }
.house-btn .n { font-size: 19px; font-weight: 800; }
.house-btn .a { font-size: 13px; color: var(--muted); margin-top: 3px; }
.feat { display: inline-flex; align-items: center; gap: 4px; }
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment .who { font-weight: 700; font-size: 14.5px; }
.statusline { font-size: 14px; color: var(--muted); font-style: italic; }
.spinner { width: 28px; height: 28px; border: 3px solid #d5ddd7; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table td, .table th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mini { border: 0; background: #eef1ed; border-radius: 10px; min-height: 38px; min-width: 38px; padding: 0 10px; font-size: 15px; font-weight: 650; cursor: pointer; color: var(--ink); font-family: inherit; }
.mini.red { color: var(--danger); background: var(--danger-soft); }
.admin-item { display: flex; gap: 8px; align-items: flex-start; padding: 10px 4px; border-top: 1px solid #f0f2ef; }
.admin-item .txt { flex: 1; font-size: 15.5px; }
.admin-item.hiddenitem .txt { text-decoration: line-through; color: var(--muted); }
.offline { background: var(--warn-soft); color: #7a4a00; text-align: center; font-size: 14px; font-weight: 600; padding: 6px; }
.tabbar .dot.blue { background: var(--blue); }
.okissue { display: flex; gap: 8px; margin: 4px 8px 0; }
.okissue button { flex: 1; min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-size: 18px; font-weight: 800; cursor: pointer; font-family: inherit; color: var(--ink); }
.okissue button.ok.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.okissue button.issue.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.issuebox { margin: 10px 8px 0; padding: 12px; border-radius: 14px; background: var(--danger-soft); }
.issuebox .seg { background: #f6d6d2; }
.sec.qc-ok .sec-h { background: var(--ok-soft); }
.sec.qc-issue .sec-h { background: var(--danger-soft); }
.score { display: flex; gap: 8px; margin-top: 8px; }
.score button { flex: 1; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 20px; font-weight: 800; cursor: pointer; font-family: inherit; }
.score button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.qc-issue-card { border-left: 5px solid var(--danger); padding: 10px 12px; background: #fff; border-radius: 12px; margin-top: 10px; box-shadow: var(--shadow); }
.tally td.num, .tally th.num { text-align: right; }

/* ---------- users & passwords ---------- */
.linkbtn { border: 0; background: none; color: var(--brand); font-weight: 700; font-size: 16px; padding: 12px; cursor: pointer; font-family: inherit; text-decoration: underline; }
.user-row { align-items: flex-start; cursor: pointer; }
.user-row .mini { flex: none; align-self: center; }
.reset-req { border-left: 5px solid var(--danger); }
.req-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.req-row:first-of-type { border-top: 0; }
.req-row .grow { flex: 1; min-width: 0; }

/* ---------- tab bar with 7 tabs (admin) ---------- */
.tabbar.many a { font-size: 10.5px; letter-spacing: -.01em; }
.tabbar.many a svg { width: 24px; height: 24px; }

/* ---------- reports ---------- */
.rpt-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.rpt-actions .btn { flex: 1; min-width: 0; padding: 0 10px; }
.rpt-card { padding: 14px 12px; }
.codeline { display: block; background: #eef1ed; border-radius: 8px; padding: 8px 10px; font-size: 13px; word-break: break-all; margin: 6px 0; }

.rpt{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;color:#1f2a24;max-width:820px;margin:0 auto}
.rpt-title{font-size:24px;font-weight:800}.rpt-range{font-size:17px;font-weight:650;margin-top:2px}
.rpt-muted{color:#66736b}.rpt-small{font-size:14px}.rpt-tiny{font-size:12px;margin-top:18px}
.rpt-kpis{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin:14px 0}
.rpt-kpi{border:1px solid #e2e7e0;border-radius:12px;padding:10px 12px;background:#fff;break-inside:avoid}
.rpt-kpi .v{font-size:24px;font-weight:800}.rpt-kpi .l{font-size:13px;font-weight:700}.rpt-kpi .s{font-size:12px;color:#66736b}
.rpt-kpi.warn{background:#fff4e0;border-color:#f3dcb3}.rpt-kpi.bad{background:#fdecea;border-color:#f3c5c0}
.rpt-h{font-size:17px;margin:22px 0 6px;break-after:avoid}.rpt-h4{font-size:15px;margin:12px 0 4px}
.rpt-scroll{overflow-x:auto;margin:6px 0 10px}
.rpt-table{width:100%;border-collapse:collapse;font-size:13.5px;background:#fff}
.rpt-table th,.rpt-table td{padding:6px 7px;border-bottom:1px solid #e2e7e0;text-align:left;vertical-align:top;white-space:nowrap}
.rpt-table td:last-child{white-space:normal}.rpt-table th{font-size:12px;color:#66736b;text-transform:uppercase;letter-spacing:.03em}
.rpt-table .num{text-align:right}.rpt-table tr{break-inside:avoid}
.rpt-red{color:#c8372d}.rpt-warn{color:#b26a00}.rpt-empty{color:#66736b;font-size:14px;margin:4px 0 10px}
@media print{.rpt-kpi,.rpt-table{background:#fff}.rpt-scroll{overflow:visible}.rpt-table th,.rpt-table td{white-space:normal}a{color:inherit;text-decoration:none}}
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .tabbar, .no-print, .toast, .offline { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; margin: 0; padding: 0; }
}
.addphoto.off { border-style: dashed; border-color: #d5ddd7; background: #f3f5f2; color: var(--muted); cursor: default; }
