:root {
  --green: #2f6f4e;
  --green-dark: #245a3f;
  --bg: #f5f4f0;
  --card: #ffffff;
  --ink: #1d2321;
  --muted: #6b746f;
  --line: #e3e1da;
  --danger: #b23b3b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .08);
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.view {
  min-height: 100dvh;
  padding: 0 0 96px;
  max-width: 640px;
  margin: 0 auto;
}
.view[hidden] { display: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(env(safe-area-inset-top), 12px) 14px 12px;
  background: var(--green);
  color: #fff;
}
.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-ghost {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1rem;
  cursor: pointer;
}
.btn-ghost.back, .btn-ghost.close { font-size: 1.25rem; line-height: 1; }

/* ---------- lists / cards ---------- */
.list { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.card .thumb {
  width: 64px; height: 64px;
  flex: 0 0 64px;
  border-radius: 8px;
  object-fit: cover;
  background: #e9e7e0;
}
.card .thumb.icon {
  display: grid; place-items: center;
  font-size: 1.8rem;
}
.card .meta { flex: 1; min-width: 0; }
.card .meta .name { font-weight: 600; }
.card .meta .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.card .count {
  flex: 0 0 auto;
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 600;
}
.card.archived { opacity: .55; }

/* note cards */
.note {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.note.done { opacity: .6; }
.note .note-head { display: flex; align-items: flex-start; gap: 8px; }
.note .note-head .title { flex: 1; font-weight: 600; }
.note.done .title { text-decoration: line-through; }
.note .body { color: var(--muted); font-size: .9rem; margin: 4px 0 0; white-space: pre-wrap; }
.note .when { color: var(--muted); font-size: .78rem; margin-top: 6px; }
.note .thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.note .thumbs img {
  width: 76px; height: 76px; border-radius: 8px; object-fit: cover;
  background: #e9e7e0; cursor: zoom-in;
}
.note .actions { display: flex; gap: 6px; margin-top: 10px; }
.pill {
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .82rem;
  cursor: pointer;
}
.pill.danger { color: var(--danger); border-color: #eccaca; }

/* ---------- picker ---------- */
.picker .card .sub .dist { color: var(--green); font-weight: 600; }
.fix-status, .assigned, .hint { padding: 0 16px; color: var(--muted); font-size: .88rem; }
.assigned { color: var(--ink); }
.hint { padding: 10px 16px 0; }

/* ---------- capture ---------- */
.preview { padding: 14px 14px 0; }
.preview img { width: 100%; border-radius: 12px; max-height: 46dvh; object-fit: cover; }
.field {
  display: block;
  width: calc(100% - 28px);
  margin: 10px 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.btn-block {
  display: block;
  width: calc(100% - 28px);
  margin: 14px;
  padding: 14px;
  border: 1px dashed var(--green);
  background: #fff;
  color: var(--green);
  border-radius: 12px;
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn-block.primary {
  border-style: solid;
  background: var(--green);
  color: #fff;
}

/* ---------- fab ---------- */
.fab {
  position: fixed;
  right: max(env(safe-area-inset-right), 18px);
  bottom: max(env(safe-area-inset-bottom), 18px);
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 16px 22px;
  font-size: 1rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  cursor: pointer;
  z-index: 6;
}

/* ---------- photo viewer ---------- */
.viewer {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.viewer img { max-width: 100%; max-height: 100dvh; }
.viewer .close {
  position: fixed;
  top: max(env(safe-area-inset-top), 14px);
  right: 14px;
  z-index: 7;
}

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

/* ---------- status strip + diagnostics ---------- */
.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .74rem;
  color: var(--muted);
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.chip .dot, .diag-row .dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 8px; background: #bbb;
}
.chip.ok .dot,  .diag-row.ok .dot   { background: #2f9e5e; }
.chip.warn .dot,.diag-row.warn .dot { background: #d99a00; }
.chip.bad .dot, .diag-row.bad .dot  { background: var(--danger); }

.diag { padding: 4px 14px 90px; }
.diag-results { margin-top: 12px; display: flex; flex-direction: column; gap: 1px; }
.diag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--card);
  border: 1px solid var(--line);
}
.diag-row:first-child { border-radius: 10px 10px 0 0; }
.diag-row:last-child  { border-radius: 0 0 10px 10px; }
.diag-row .dr-label { flex: 1; font-size: .9rem; }
.diag-row .dr-detail { color: var(--muted); font-size: .82rem; text-align: right; font-variant-numeric: tabular-nums; }
.diag-row.bad .dr-detail { color: var(--danger); }

@media (prefers-color-scheme: dark) {
  .chip { background: #232a26; }
}

/* ---------- section label + action sheet ---------- */
.section-label {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 16px 4px 2px;
}

.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 8px 12px max(env(safe-area-inset-bottom), 12px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, .25);
  animation: sheet-up .16s ease-out;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-title { text-align: center; color: var(--muted); font-size: .85rem; font-weight: 600; padding: 10px 0; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-btn {
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.sheet-btn.danger { color: var(--danger); border-color: #eccaca; font-weight: 600; }
.sheet-btn.cancel { margin-top: 8px; background: #efeee8; border: 0; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .sheet-btn { background: #232a26; }
  .sheet-btn.cancel { background: #2c332f; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1e2421; --ink: #eef1ee; --muted: #9aa39d;
    --line: #2c332f;
  }
  .pill { background: #232a26; }
  .field, .btn-block { background: #1e2421; color: var(--ink); }
  .btn-block.primary { color: #fff; }
}
