:root {
  /* About the Stay — warm brand palette: linen · sand · espresso, sage accent */
  --brand: #6b5138;        /* espresso — app bar & primary buttons */
  --brand-dark: #513c28;   /* darker espresso — section headers */
  --brand-tint: #efe4d5;   /* light sand */
  --pass: #7a9470;         /* sage green — "pass / guest ready" */
  --pass-tint: #e7eee1;    /* light sage */
  --issue: #b1442f;        /* warm brick red — issues */
  --issue-tint: #f5e2dc;
  --na: #a2917b;           /* taupe */
  --na-tint: #ece2d3;
  --bg: #faf0e6;           /* linen base */
  --card: #ffffff;
  --ink: #43341f;          /* espresso text */
  --muted: #8a7967;        /* muted taupe-brown */
  --line: #e8dcc9;         /* soft sand line */
  --shadow: 0 1px 3px rgba(74, 58, 43, .10), 0 1px 2px rgba(74, 58, 43, .06);
  --radius: 14px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}
.appbar__back[hidden] { display: none; }
.appbar__back {
  border: 0;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.appbar__title { font-weight: 700; font-size: 17px; flex: 1; }
.appbar__brand { font-size: 12px; opacity: .85; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- Layout ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
}

.stack > * + * { margin-top: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

h1 { font-size: 22px; margin: 2px 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: transform .04s ease, filter .15s ease;
}
.btn:active { transform: scale(.985); }
.btn--lg { padding: 18px; font-size: 17px; }
.btn--ghost { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn--subtle { background: var(--na-tint); color: var(--ink); }
.btn--danger { background: var(--issue); }
.btn--sm { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], textarea, select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 13px 12px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; min-height: 64px; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 20px 8px 6px; }
.hero h1 { font-family: var(--serif); font-weight: 700; letter-spacing: .2px; }
.hero .logo {
  width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 12px;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: 30px; box-shadow: var(--shadow);
}

/* ---------- Inspection progress ---------- */
.progress-wrap { position: sticky; top: 54px; z-index: 40; padding: 10px 0 4px; background: var(--bg); }
.progress-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Section ---------- */
.section { margin-top: 14px; }
.section__head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: var(--brand-dark); color: #fff;
  border-radius: 12px 12px 0 0; font-weight: 700; font-size: 15px;
}
.section__count { margin-left: auto; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.2); padding: 2px 8px; border-radius: 99px; }
.section__body { background: #fff; border-radius: 0 0 12px 12px; box-shadow: var(--shadow); overflow: hidden; }

/* ---------- Item ---------- */
.item { padding: 13px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item__label { font-size: 15px; margin-bottom: 10px; }
.choices { display: flex; gap: 8px; }
.choice {
  flex: 1; border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 10px; padding: 10px 6px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.choice[data-active="pass"]  { background: var(--pass-tint);  border-color: var(--pass);  color: var(--pass); }
.choice[data-active="yes"]   { background: var(--pass-tint);  border-color: var(--pass);  color: var(--pass); }
.choice[data-active="issue"] { background: var(--issue-tint); border-color: var(--issue); color: var(--issue); }
.choice[data-active="no"]    { background: var(--issue-tint); border-color: var(--issue); color: var(--issue); }
.choice[data-active="na"]    { background: var(--na-tint);    border-color: var(--na);    color: var(--na); }

.media-prompt { font-size: 14px; color: var(--brand-dark); background: var(--brand-tint); border-radius: 10px; padding: 9px 12px; }
.opt-badge { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--na-tint); border-radius: 6px; padding: 1px 6px; vertical-align: middle; }

.item.item--needs { background: #f8ece1; box-shadow: inset 4px 0 0 var(--issue); }
.need-evidence { color: var(--issue); font-size: 13px; font-weight: 600; margin-top: 8px; }
.need-evidence[hidden] { display: none; }

.item__extra { margin-top: 10px; display: none; }
.item__extra.show { display: block; }
.item__tools { display: flex; gap: 8px; margin-top: 10px; }
.item__tools .btn--sm { flex: 0 0 auto; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
}
.hidden-file { display: none; }
.thumb--up { display: grid; place-items: center; color: var(--muted); font-size: 22px; background: var(--na-tint); }

/* ---------- Video chips (checklist) ---------- */
.vids { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.vids:empty { margin-top: 0; }
.vidchip {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--na-tint); border-radius: 10px; font-size: 14px;
}
.vidchip__ic { font-size: 16px; }
.vidchip__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vidchip__x { border: 0; background: rgba(0,0,0,.15); color: #fff; width: 22px; height: 22px; border-radius: 50%; font-size: 14px; line-height: 1; cursor: pointer; flex: 0 0 auto; }
.vidchip--up { color: var(--muted); font-style: italic; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Records list ---------- */
.record {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer;
}
.record__badge { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.badge-ready { background: var(--pass); }
.badge-issues { background: var(--issue); }
.record__main { flex: 1; min-width: 0; }
.record__title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record__sub { font-size: 13px; color: var(--muted); }
.record__chev { color: var(--muted); font-size: 22px; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.pill-ready { background: var(--pass-tint); color: var(--pass); }
.pill-issues { background: var(--issue-tint); color: var(--issue); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Manager rows (templates / properties) ---------- */
.mrow { display: flex; align-items: center; gap: 12px; }
.mrow__main { flex: 1; min-width: 0; }
.mrow__title { font-weight: 700; font-size: 15px; }
.mrow__sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.mrow__actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }

/* ---------- Template editor ---------- */
.ed-sec { padding: 12px; }
.ed-sec__head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.ed-sec__title { flex: 1; font-weight: 700; }
.ed-mini {
  flex: 0 0 auto; width: 34px; height: 38px; border: 1.5px solid var(--line);
  background: #fff; border-radius: 8px; font-size: 15px; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; padding: 0;
}
.ed-mini:active { background: var(--na-tint); }
.ed-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }
.ed-item { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.ed-item__main { display: flex; align-items: center; gap: 6px; }
.ed-item__label { flex: 1; }
.ed-item__opts { display: flex; align-items: center; gap: 10px; padding-left: 2px; }
.ed-item__type { flex: 0 1 auto; max-width: 220px; padding: 8px 10px; font-size: 14px; }
.ed-item__req { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ed-item__req input { width: 16px; height: 16px; }
.ed-item .ed-mini { width: 30px; height: 42px; }

/* ---------- Report view ---------- */
.report { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.report__header { padding: 18px; border-bottom: 3px solid var(--brand); }
.report__brand { color: var(--brand); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; }
.report__title { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 4px 0 12px; }
.report__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 14px; }
.report__meta div span { color: var(--muted); }
.report__summary { display: flex; gap: 8px; padding: 14px 18px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 70px; text-align: center; background: var(--bg); border-radius: 10px; padding: 10px 6px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

.rsection { padding: 6px 18px 4px; }
.rsection h3 { font-size: 15px; margin: 14px 0 6px; color: var(--brand-dark); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.ritem { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ritem:last-child { border-bottom: 0; }
.ritem__top { display: flex; gap: 10px; align-items: baseline; }
.ritem__tag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; flex: 0 0 auto; }
.tag-pass { background: var(--pass-tint); color: var(--pass); }
.tag-issue { background: var(--issue-tint); color: var(--issue); }
.tag-na { background: var(--na-tint); color: var(--na); }
.tag-blank { background: var(--na-tint); color: var(--na); }
.tag-media { background: var(--brand-tint); color: var(--brand-dark); }
.ritem__label { font-size: 14px; }
.ritem__note { font-size: 13px; color: var(--issue); margin: 4px 0 0 0; }
.rphotos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rphotos img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

/* ---------- Photo lightbox (zoomable) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.93);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
.lightbox__img {
  max-width: 100%; max-height: 100%; transform-origin: center center;
  will-change: transform; user-select: none; -webkit-user-drag: none;
  cursor: zoom-in;
}
.lightbox__close {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 14px;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.16); color: #fff; font-size: 24px; line-height: 1;
  cursor: pointer; z-index: 210; display: grid; place-items: center;
}
.lightbox__nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.14); color: #fff; font-size: 26px; line-height: 1;
  cursor: pointer; z-index: 210; display: grid; place-items: center;
}
.lightbox__nav--prev { left: 10px; }
.lightbox__nav--next { right: 10px; }
.lightbox__meta {
  position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center; color: rgba(255,255,255,.75); font-size: 13px; pointer-events: none;
}
.rvideos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rvideo-wrap { display: flex; flex-direction: column; }
.rvideo { width: 260px; max-width: 100%; border-radius: 8px; background: #000; }
.rvideo-cap { display: none; font-size: 12px; color: var(--muted); margin-top: 4px; }

.report__notes { padding: 14px 18px; background: var(--bg); }
.report__notes h3 { margin: 0 0 4px; font-size: 14px; }

/* ---------- In-app camera ---------- */
.camera { position: fixed; inset: 0; z-index: 300; background: #000; display: flex; flex-direction: column; }
.camera__video { flex: 1; width: 100%; min-height: 0; object-fit: cover; background: #000; }
.camera__flash { position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity .1s ease; pointer-events: none; z-index: 3; }
.camera__top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
.camera__btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.5); color: #fff; font-size: 20px; cursor: pointer;
}
.camera__hint {
  position: absolute; top: calc(64px + env(safe-area-inset-top)); left: 0; right: 0;
  text-align: center; color: rgba(255,255,255,.85); font-size: 13px; padding: 0 20px; z-index: 2; pointer-events: none;
}
.camera__strip { position: relative; z-index: 5; display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: rgba(0,0,0,.6); }
.camera__strip:empty { display: none; }
.camera__shot { position: relative; flex: 0 0 auto; width: 58px; height: 58px; border-radius: 8px; overflow: hidden; }
.camera__shot img { width: 100%; height: 100%; object-fit: cover; }
.camera__shot button {
  position: absolute; top: 1px; right: 1px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
}
.camera__bar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px calc(16px + env(safe-area-inset-bottom)); background: #000;
}
.camera__shutter {
  width: 68px; height: 68px; border-radius: 50%; background: #fff;
  border: 4px solid rgba(255,255,255,.45); cursor: pointer; flex: 0 0 auto;
}
.camera__shutter:active { transform: scale(.94); }
.camera__lib { width: 48px; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
.camera__done {
  min-width: 84px; padding: 10px 14px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90%;
}

/* ---------- Sticky submit bar ---------- */
.submitbar {
  position: sticky; bottom: 0; margin: 16px -14px 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(241,245,249,0));
}

/* ---------- Print / PDF ---------- */
@media print {
  @page { margin: 14mm; }
  .appbar, .toast, .no-print, .submitbar { display: none !important; }
  body, html { background: #fff; }
  main { max-width: none; padding: 0; }
  .report { box-shadow: none; border-radius: 0; }
  .report__header { border-bottom: 3px solid #6b5138; }
  .rsection h3 { break-after: avoid; }
  .ritem, .rphotos img, .report__notes { break-inside: avoid; }
  .rphotos img { width: 30%; height: auto; max-height: 200px; }
  .rvideo { display: none; }
  .rvideo-cap { display: block; }
}
