:root {
  --bg: #f5f6f8; --card: #ffffff; --ink: #0f172a; --muted: #5b6474; --line: #e3e6eb;
  --accent: #1d4ed8; --accent-ink: #ffffff; --good: #0f7b4b; --warn: #b45309; --chip: #eef2ff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1020; --card: #141a2e; --ink: #e7eaf2; --muted: #9aa3b5; --line: #263049;
    --accent: #6d8dff; --accent-ink: #0b1020; --good: #4ade80; --warn: #fbbf24; --chip: #1e2742; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 400; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 380px; margin: 40px auto; }
h1 { font-size: 1.35rem; margin: 0 0 6px; }
h2 { font-size: 1.1rem; margin: 2px 0; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px; }
.muted { color: var(--muted); }
.err { color: #dc2626; }
input, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; }
.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.big { width: 100%; padding: 16px; font-size: 1.1rem; margin-top: 12px; }
button:disabled { opacity: .5; cursor: default; }
#loginForm { display: grid; gap: 10px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 16px; }
#barFill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#log { padding-left: 18px; color: var(--muted); font-size: .9rem; max-height: 220px; overflow: auto; }
.run-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.run-row:first-child { border-top: 0; }
.lead-head { display: flex; gap: 12px; align-items: flex-start; }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--line); flex: none; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--chip); color: var(--accent); }
.tag.pending { color: var(--warn); }
.agent { margin-top: 10px; }
.agent a { color: var(--accent); }
.issue { margin-top: 6px; font-size: .92rem; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .cols { grid-template-columns: 1fr; } }
ul { margin: 0; padding-left: 18px; }
li { margin: 3px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.actions .btn { flex: 1 1 140px; }
.subject { margin-bottom: 8px; }
.desc { margin-top: 14px; }
.desc p { white-space: pre-wrap; font-size: .92rem; }
.status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.chip { background: var(--chip); color: var(--ink); font-weight: 500; padding: 6px 10px; font-size: .85rem; }
.chip.on { background: var(--good); color: #fff; }
.other { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.other a { color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: .92rem; z-index: 10; }

/* ---- one lead per screen, swipe between leads; swipe photos inside a lead ---- */
#leads .lead { display: none; }
#leads .lead.active { display: block; }
#results { padding-bottom: 84px; }
#pager { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
#pager button { flex: 1; padding: 14px; font-size: 1rem; }
#leadCount { min-width: 64px; text-align: center; font-weight: 600; }
.carousel-wrap { position: relative; margin: -16px -16px 0; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 14px 14px 0 0; background: #000;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.carousel::-webkit-scrollbar { display: none; }
.carousel img { flex: 0 0 100%; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; scroll-snap-align: center; background: #000; }
.ccount { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: .8rem; padding: 3px 8px; border-radius: 99px; }
.photo-note { font-size: .8rem; margin: 6px 0 10px; }
.zbtn { margin-top: 8px; padding: 8px 12px; }
.lead h2 { font-size: 1.15rem; }
@media (max-width: 640px) {
  main { padding: 10px; }
  .card { padding: 14px; }
  .carousel-wrap { margin: -14px -14px 0; }
  textarea, input { font-size: 16px; } /* stops iOS zooming into fields */
}

#summary h1 { margin-bottom: 4px; }
#summary details { margin: 4px 0 10px; }
