:root {
  --green: #37B34A;
  --green-dark: #1E7A32;
  --green-pale: #EAF6EC;
  --ink: #262626;
  --grey: #777;
  --line: #dcdfdc;
  --bg: #f5f7f5;
  --card: #fff;
  --red: #d32f2f;
  --amber: #b26a00;
  --amber-pale: #fff4e0;
  --radius: 12px;
  --tap: 44px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.4 var(--font); color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--grey); margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--grey); }
.small { font-size: 13px; }
.warn { color: var(--amber); }
code { font-size: 13px; background: #eef1ee; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.boot { padding: 40px; color: var(--grey); }

/* header */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: #fff; border-bottom: 3px solid var(--green); min-height: 60px;
}
.bar .brand { font-weight: 800; font-size: 22px; color: var(--ink); letter-spacing: -.02em; }
.bar .brand::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-left: 2px; }
.bar .back { font-size: 38px; line-height: 1; color: var(--green-dark); text-decoration: none; padding: 0 10px 4px 0; min-width: var(--tap); }
.bar-title { flex: 1; min-width: 0; }
.bar h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { font-size: 13px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-right { display: flex; gap: 8px; }

.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); padding: 0 max(8px, env(safe-area-inset-left)); position: sticky; top: 63px; z-index: 19; }
.tabs a { flex: 1; text-align: center; padding: 12px 6px; text-decoration: none; color: var(--grey); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--green-dark); border-color: var(--green); }

.page { padding: 8px max(16px, env(safe-area-inset-right)) 120px max(16px, env(safe-area-inset-left)); max-width: 1100px; margin: 0 auto; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.sp { flex: 1; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.big { min-height: 52px; font-size: 17px; padding: 0 22px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--green-dark); }
.btn.danger { color: var(--red); }
.btn:active { filter: brightness(.94); }
.link { background: none; border: 0; color: var(--green-dark); text-decoration: underline; padding: 0 4px; font-size: 13px; text-transform: none; letter-spacing: 0; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-right: 1px solid var(--line); background: #fff; min-height: 40px; padding: 0 14px; font-weight: 600; color: var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--green); color: #fff; }
.seg button .count { font-weight: 500; opacity: .7; font-size: 13px; }
.seg.big button { min-height: 50px; flex: 1; font-size: 16px; }
.seg.big { display: flex; }
.seg.small button { min-height: 34px; font-size: 14px; }
.seg.filter { margin: 12px 0 0; }

/* cards / lists */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; border-left: 5px solid var(--green); }
.card-k { font-weight: 800; font-size: 20px; color: var(--green-dark); }
.card-t { font-weight: 600; margin: 4px 0; }
.card-s { color: var(--grey); font-size: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; flex-wrap: wrap; }
.item-main { flex: 1; min-width: 220px; text-decoration: none; color: inherit; }
.item-t { font-weight: 700; }
.item-s { color: var(--grey); font-size: 14px; }
.item-act { display: flex; gap: 6px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 20px; vertical-align: middle; }
.badge.post { background: var(--amber-pale); color: var(--amber); }
.empty { text-align: center; padding: 40px 20px; color: var(--ink); }
.banner { background: var(--green-pale); border: 1px solid #cfe9d3; border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.banner.warn { background: var(--amber-pale); border-color: #f1d9ad; }
.banner.ok { background: var(--green-pale); }
.banner ul { margin: 6px 0 0; padding-left: 20px; }
.row-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn.save-photos { border-color: #f1d9ad; background: var(--amber-pale); color: var(--amber); }

/* forms */
.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.fld > span { font-size: 13px; font-weight: 600; color: var(--grey); }
.fld.inline { margin-top: 10px; max-width: 260px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form h2:first-child { margin-top: 12px; }
.dates { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dates input { width: auto; }
.date { background: var(--green-pale); border-radius: 20px; padding: 6px 4px 6px 12px; font-weight: 600; }
table.summary, table.staff { border-collapse: collapse; width: 100%; background: #fff; border-radius: var(--radius); overflow: hidden; }
table.summary th, table.summary td, table.staff th, table.staff td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.summary th, table.staff th { background: var(--green-dark); color: #fff; font-size: 13px; }
table.staff input { min-height: 38px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 22px; min-height: 40px; padding: 0 14px;
  font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.chip.add { border-style: dashed; color: var(--green-dark); }
.chip input { display: none; }
input.mm { width: 90px; min-height: 40px; border-radius: 22px; }
.grp { margin-bottom: 4px; }
.grp-h { background: none; border: 0; font-weight: 700; color: var(--green-dark); padding: 6px 0; min-height: 36px; }

/* inspect */
#app.fill { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
#app.fill #tab { flex: 1; min-height: 0; }
.inspect { display: flex; flex-direction: column; height: 100%; }
.tbar { display: flex; gap: 10px; align-items: center; padding: 8px max(12px, env(safe-area-inset-left)); background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tbar.tools { background: #fafbfa; }
.hint { font-size: 13px; color: var(--grey); padding: 4px 14px; background: #fafbfa; border-bottom: 1px solid var(--line); }
.plan-host { flex: 1; position: relative; overflow: hidden; background: #e9edea; touch-action: none; }
.plan-svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; display: block; }
.plan-svg[data-mode=draw] { cursor: crosshair; }
.pin text { fill: #e00000; font-family: Arial, sans-serif; dominant-baseline: middle; paint-order: stroke; stroke: #fff; stroke-linejoin: round; font-weight: 600; }
.pin circle { fill: #e00000; stroke: #fff; }
.pin.orig.todo text { fill: #8a8a8a; }
.pin.orig.todo circle { fill: #8a8a8a; }
.pin.orig.done text, .pin.orig.done circle { fill: var(--green-dark); }
.pin.orig.na text, .pin.orig.na circle { fill: var(--amber); }
.run text { fill: #e00000; font-family: Arial, sans-serif; dominant-baseline: middle; paint-order: stroke; stroke: #fff; font-weight: 600; }
.plan-empty { flex: 1; }
.dock {
  display: flex; align-items: center; gap: 12px; padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: #fff; border-top: 1px solid var(--line);
}
.lastbar { flex: 1; font-size: 14px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lastbar strong { color: #e00000; }

/* sheets */
.overlay { position: fixed; inset: 0; background: rgba(20, 30, 22, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 1180px; max-height: 96dvh; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; overflow: hidden; padding-bottom: env(safe-area-inset-bottom);
}
.sheet.small { max-width: 560px; border-radius: 18px; margin-bottom: auto; margin-top: 8vh; max-height: 84dvh; }
.sheet.capture { height: 96dvh; }
.sheet.working { pointer-events: none; opacity: .7; }
.sh-head { padding: 16px 20px 10px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sh-head h2 { margin: 0; font-size: 20px; }
.sh-form { padding: 16px 20px 0; overflow: auto; }
.sh-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); background: #fafbfa; flex-wrap: wrap; }
.sh-form .sh-foot { margin: 8px -20px 0; }

.cap { flex: 1; display: grid; grid-template-columns: minmax(300px, 42%) 1fr; min-height: 0; }
.cap-photo { padding: 16px 20px; border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.cap-photo img, .nophoto { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #111; border-radius: 10px; }
.nophoto { display: flex; align-items: center; justify-content: center; color: #bbb; background: #f0f2f0; border: 2px dashed var(--line); }
.cap-fields { padding: 16px 20px; overflow: auto; -webkit-overflow-scrolling: touch; }
.cap-fields section { margin-bottom: 18px; }
.rowprev { display: grid; grid-template-columns: 40px 1fr 50px 50px 2fr; gap: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fafbfa; }
.rowprev span:first-child { color: #e00000; font-weight: 700; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px 20px; overflow: auto; }
.compare figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.compare img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #111; border-radius: 10px; }
.compare figcaption { font-weight: 600; text-align: center; }
.recheck-fields { padding: 0 20px 12px; overflow: auto; }

/* photo list */
.plist { display: flex; flex-direction: column; gap: 6px; }
.prow {
  display: grid; grid-template-columns: 84px 44px 150px 50px 1fr; gap: 10px; align-items: center; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; width: 100%;
}
.prow img { width: 84px; height: 63px; object-fit: cover; border-radius: 6px; background: #eee; }
.prow .pno { font-weight: 800; color: #e00000; font-size: 18px; }
.prow .ploc { font-weight: 600; }
.prow.todo { border-left: 5px solid #aaa; }
.prow.done { border-left: 5px solid var(--green); }

/* misc */
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 22px; z-index: 100; font-weight: 600; max-width: 90vw; }
.busy { position: fixed; inset: 0; background: rgba(255, 255, 255, .8); z-index: 90; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 600; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--green-pale); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.ico { font-weight: 700; }

@media (max-width: 860px) {
  .cap { grid-template-columns: 1fr; overflow: auto; }
  .cap-photo { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .cap-photo img, .cap-photo .nophoto { max-height: 26dvh; }
  .cap-fields { overflow: visible; }
  .grid2 { grid-template-columns: 1fr; }
  .prow { grid-template-columns: 72px 36px 1fr; }
  .prow img { width: 72px; height: 54px; }
  .prow .pw { display: none; }
  .prow .pc { grid-column: 2 / -1; }
  .compare { grid-template-columns: 1fr; }
}
