@font-face {
  font-family: 'Saira Condensed';
  font-weight: 800;
  font-display: swap;
  src: url('saira-condensed-800.woff2') format('woff2');
}

:root {
  --orange: #F3990F;
  --orange-ink: #8a5300;
  --orange-soft: #fff3df;
  --grey: #9D9EA0;
  --ink: #1E140A;
  --ink-2: #4a4440;
  --muted: #6f6c69;
  --bg: #f6f5f3;
  --card: #ffffff;
  --line: #e2e0dd;
  --ok: #217E60;
  --ok-soft: #e3f2ec;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --bad: #8C2326;
  --bad-soft: #f8e4e4;
  --blue: #002F55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30,20,10,.06), 0 2px 8px rgba(30,20,10,.05);
  --head: 'Saira Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --orange-ink: #ffc061; --orange-soft: #3a2a12; --ink: #f3efea; --ink-2: #d6d0ca; --muted: #a39d97;
    --bg: #161412; --card: #221f1c; --line: #38332f; --ok: #5cc9a2; --ok-soft: #173229;
    --warn: #ffc061; --warn-soft: #3a2a12; --bad: #ff8d8d; --bad-soft: #3a1c1c; --blue: #8ab8e6;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --orange-ink: #ffc061; --orange-soft: #3a2a12; --ink: #f3efea; --ink-2: #d6d0ca; --muted: #a39d97;
  --bg: #161412; --card: #221f1c; --line: #38332f; --ok: #5cc9a2; --ok-soft: #173229;
  --warn: #ffc061; --warn-soft: #3a2a12; --bad: #ff8d8d; --bad-soft: #3a1c1c; --blue: #8ab8e6;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { font-family: var(--head); font-weight: 800; letter-spacing: .01em; margin: 0; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--card);
  border-bottom: 3px solid var(--orange);
}
.brand { display: flex; align-items: center; flex: 1; min-width: 0; }
.logo { height: 24px; width: auto; display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo { background: #fff; padding: 4px 6px; border-radius: 6px; height: 30px; } }
:root[data-theme="dark"] .logo { background: #fff; padding: 4px 6px; border-radius: 6px; height: 30px; }
.back { border: 0; background: none; padding: 6px; margin-left: -8px; color: var(--ink); display: flex; }
.back[hidden] { display: none; }
.syncpill {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.syncpill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--grey); }
.syncpill.ok::before { background: var(--ok); }
.syncpill.pending::before { background: var(--orange); }
.syncpill.err::before { background: var(--bad); }
.syncpill.busy::before { animation: pulse 1s infinite; background: var(--orange); }
@keyframes pulse { 50% { opacity: .2; } }

.banner { background: var(--orange-soft); color: var(--orange-ink); padding: 10px 16px; font-size: 14px; font-weight: 600; }
.app { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.pagehead p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-decoration: none; box-shadow: var(--shadow); min-height: 64px;
}
.item:active { background: var(--orange-soft); }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--muted); }
.thumb { width: 52px; height: 52px; border-radius: 10px; background: var(--bg) center/cover; flex: none; border: 1px solid var(--line); display: grid; place-items: center; color: var(--grey); font-size: 11px; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.complete { background: var(--ok-soft); color: var(--ok); }
.badge.amend { background: #e5edf6; color: var(--blue); }
.badge.flag { background: var(--bad-soft); color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); display: inline-block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 700; font-size: 16px;
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1E140A; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--card); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }

.fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 15; min-height: 58px;
  border-radius: 999px; padding: 0 22px; box-shadow: 0 6px 20px rgba(30,20,10,.25); font-size: 17px;
}

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1 1 180px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 14px;
  font-weight: 600; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--card); border-color: var(--ink); }

label.f { display: block; margin-bottom: 14px; }
label.f > span, .flabel { display: block; font-size: 14px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.req::after { content: ' *'; color: var(--orange-ink); }
input[type=text], input[type=email], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: var(--card); font-size: 17px; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--orange); outline-offset: 0; border-color: var(--orange); }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer;
}
.seg button[aria-pressed="true"].yes { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button[aria-pressed="true"].no { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button[aria-pressed="true"].na { background: var(--grey); border-color: var(--grey); color: #1E140A; }

.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.check:first-of-type { border-top: 0; }
.check .lbl { flex: 1; font-size: 15px; font-weight: 600; }
.check .seg { flex: none; width: 168px; }
.check .seg button { min-height: 42px; font-size: 14px; }

.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
.section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 16px; min-height: 56px;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary h3 { flex: 1; }
.section > summary::after { content: ''; width: 9px; height: 9px; border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
.section[open] > summary::after { transform: rotate(-135deg); }
.section .body { padding: 0 16px 6px; }
.count { font-size: 12px; font-weight: 700; color: var(--muted); }
.count.done { color: var(--ok); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(30,20,10,.72); color: #fff; font-size: 11px; padding: 3px 6px; font-weight: 600; }
.ph button { position: absolute; inset: 0; background: none; border: 0; width: 100%; cursor: pointer; }
.need { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.need .badge { font-weight: 600; }
.addphoto { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.addphoto label.btn { position: relative; overflow: hidden; font-size: 15px; min-height: 54px; padding: 0 10px; text-align: center; }
.addphoto input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.problems { background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.problems ul { margin: 6px 0 0; padding-left: 18px; }
.locked { background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.amending { background: #e5edf6; color: var(--blue); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }

.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; justify-content: center;
}
.bottombar .btn { flex: 1; max-width: 360px; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--card); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet .panel {
  background: var(--card); width: 100%; max-width: 760px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
.sheet .panel h2 { margin-bottom: 12px; }
.sheet img.big { width: 100%; border-radius: 12px; display: block; margin-bottom: 12px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--head); font-size: 26px; line-height: 1; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.angle { position: relative; overflow: hidden; }
.angle::after { content: ''; position: absolute; right: -40px; top: -20px; width: 120px; height: 200%; background: var(--orange); opacity: .14; transform: rotate(42.7deg); pointer-events: none; }
