:root {
  --ink: #1c1915;
  --muted: #5e584f;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #ddd4c4;
  --red: #9f1d1d;
  --red-bg: #f8e4e1;
  --yellow: #8a5a00;
  --yellow-bg: #f8efd2;
  --green: #1d6b3a;
  --green-bg: #e3f3e7;
  --gray: #5c6570;
  --gray-bg: #eceff2;
  --accent: #9f1d1d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.45 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
a { color: inherit; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: #221e1a;
  color: #f6f1e8;
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: 0.01em; }
nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
nav a, button.link {
  color: #f6f1e8;
  text-decoration: none;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
main { padding: 18px; max-width: 980px; margin: 0 auto; }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.narrow { max-width: 460px; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; }
input, select, textarea, button {
  font: inherit;
  color: var(--ink);
}
input, select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
button, .button {
  display: inline-block;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
.upload { display: grid; gap: 6px; }
.upload[hidden] { display: none; }
.upload-track { height: 12px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.upload-bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.upload-bar.busy { width: 35%; animation: upload-slide 1.1s ease-in-out infinite; }
.upload-label { margin: 0; color: var(--muted); font-weight: 600; }
@keyframes upload-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.error { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 8px; }
.note { background: var(--yellow-bg); color: var(--note-ink); padding: 10px 12px; border-radius: 8px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.stat.red b { color: var(--red); }
.stat.yellow b { color: var(--yellow); }
.stat.green b { color: var(--green); }
.stat.gray b { color: var(--gray); }
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { flex: 1; }
.list { display: grid; gap: 8px; }
.item {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--gray);
  border-radius: 10px;
  padding: 12px;
  text-decoration: none;
}
.item.red { border-left-color: var(--red); }
.item.yellow { border-left-color: var(--yellow); }
.item.green { border-left-color: var(--green); }
.item-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.badge { border-radius: 999px; padding: 2px 8px; font-size: 0.8rem; background: var(--gray-bg); color: var(--gray); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.green { background: var(--green-bg); color: var(--green); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; gap: 6px; }
legend { font-weight: 700; padding: 0 4px; }
.choice { display: flex; align-items: center; font-weight: 500; }
.choice input { width: auto; flex: none; margin: 0 10px 0 0; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.facts div { background: var(--card); border-radius: 8px; padding: 8px 10px; }
dt { color: var(--muted); font-size: 0.8rem; }
dd { margin: 0; font-weight: 650; }
.reasons { margin: 8px 0 16px; }
.journal { background: var(--card); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.shot { display: inline-block; margin-top: 8px; }
.shot img { display: block; width: 148px; height: 110px; object-fit: cover; border-radius: 8px; background: var(--soft); }
.preview { border: 0; padding: 12px; max-width: min(960px, 96vw); background: #221e1a; border-radius: 12px; }
.preview form { margin: 0 0 8px; text-align: right; }
.preview img { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; }
.preview::backdrop { background: rgba(20, 16, 12, 0.75); }
.role-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 8px 0; }
.role-form select { width: auto; min-width: 12rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 16px; }
.row-actions form { margin: 0; }
a.button.secondary, button.secondary, summary.button.secondary { background: var(--button-2); }
.back { margin-top: 0; }
.sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sticker {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px dashed #8a8175;
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  color: #1c1915;
  min-height: 150px;
}
.sticker svg { width: 116px; height: 116px; }
.scan { margin-top: 8px; font-weight: 700; }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-size: 0.75rem; margin-bottom: 0; }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filters, .facts, .sheet { display: grid; grid-template-columns: 1fr; }
  .top { align-items: flex-start; flex-direction: column; }
}
@media print {
  .top, .screen-only, .preview { display: none !important; }
  body, main { background: #ffffff; margin: 0; padding: 0; max-width: none; }
  .sheet { grid-template-columns: 1fr 1fr; }
  .sticker { break-inside: avoid; }
}
.who { opacity: 0.7; font-size: 0.9rem; }
.last-state { margin: 12px 0 4px; }
.last-state .reasons { margin: 6px 0; }
input[readonly] { background: var(--soft); color: var(--muted); }
.role-form input:not([type="checkbox"]) { width: auto; min-width: 12rem; }
.field { display: grid; gap: 4px; font-weight: 600; }
.dropdown { position: relative; min-width: 14rem; max-width: 24rem; font-weight: 400; }
.dropdown summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 34px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown::after { content: "▾"; position: absolute; right: 12px; top: 12px; pointer-events: none; color: var(--muted); }
.dropdown.off summary { background: var(--soft); color: var(--muted); pointer-events: none; }
.dropdown-list {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-height: 19rem;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(28, 25, 21, 0.16);
  white-space: nowrap;
}

/* menu */
nav a.on { border-bottom: 2px solid #f6f1e8; padding-bottom: 2px; }
.nav-toggle { position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.nav-button { display: none; }
/* panel */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.page-head .row-actions { margin: 0; }
a.stat { display: block; text-decoration: none; }
a.stat:hover { border-color: #8a8175; }
a.stat.on { border: 2px solid var(--ink); padding: 9px; }
.gap-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 14px; }
.chip { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); text-decoration: none; font-weight: 600; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.groups { display: grid; gap: 8px; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.group summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 12px 14px; cursor: pointer; }
.group[open] summary { border-bottom: 1px solid var(--line); background: var(--hover); }
.group-meta { color: var(--muted); }
.t-red { color: var(--red); font-weight: 600; }
.t-yellow { color: var(--yellow); font-weight: 600; }
.t-green { color: var(--green); font-weight: 600; }
.line { display: grid; grid-template-columns: 4.5rem minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; border-left: 5px solid var(--gray); border-bottom: 1px solid var(--line); text-decoration: none; }
.line:last-child { border-bottom: 0; }
.line:hover { background: var(--hover); }
.line.red { border-left-color: var(--red); }
.line.yellow { border-left-color: var(--yellow); }
.line.green { border-left-color: var(--green); }
.line-why { color: var(--muted); }
.line.red .line-why { color: var(--red); }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; display: grid; gap: 2px; min-width: 15rem; padding: 6px; background: var(--field); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 22px rgba(28, 25, 21, 0.16); }
.menu-list a { padding: 10px; border-radius: 6px; text-decoration: none; font-weight: 600; }
.menu-list a:hover { background: var(--hover); }
.menu-list span { padding: 4px 10px 6px; font-size: 0.85rem; }
/* inspection form */
fieldset.seg { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.seg-opt { display: block; position: relative; font-weight: 600; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 52px; height: 100%; padding: 6px; text-align: center; line-height: 1.2; border: 1px solid var(--line); border-radius: 8px; background: var(--field); cursor: pointer; }
.seg-opt input:checked + span { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.seg-opt.bad input:checked + span { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.all-ok { min-height: 56px; background: #1d6b3a; font-size: 1.05rem; }
button.big { min-height: 56px; font-size: 1.05rem; }
.center { text-align: center; margin: 0; }
.who-line { margin: 0; }
.extra { border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.extra summary { padding: 12px; cursor: pointer; font-weight: 600; }
.extra textarea, .extra input { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
/* users */
.users { border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.user-head, .user-row summary { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; align-items: center; padding: 10px 14px; }
.user-head { color: var(--muted); font-size: 0.85rem; border-bottom: 1px solid var(--line); }
.user-row { border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row summary { cursor: pointer; list-style: none; }
.user-row summary::-webkit-details-marker { display: none; }
.user-row summary:hover, .user-row[open] summary { background: var(--hover); }
.user-row .role-form, .user-row .row-actions { padding: 0 14px; }
.badge.red { background: var(--red-bg); color: var(--red); }
.fresh { display: grid; gap: 6px; padding: 14px; margin: 0 0 14px; border: 2px solid var(--green); border-radius: 10px; background: var(--green-bg); }
.fresh code { font: 700 1.5rem/1.2 Consolas, "Courier New", monospace; letter-spacing: 0.06em; user-select: all; }
@media (max-width: 720px) {
  .top { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav-button { display: inline-block; margin-left: auto; padding: 6px 12px; border: 1px solid #5e584f; border-radius: 8px; font-weight: 600; cursor: pointer; }
  nav { display: none; width: 100%; flex-direction: column; align-items: flex-start; gap: 14px; padding-top: 8px; }
  .nav-toggle:checked ~ nav { display: flex; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .line { grid-template-columns: 4.2rem minmax(0, 1fr) auto; }
  .line-why { grid-column: 2 / 4; grid-row: 2; }
  .user-head { display: none; }
  .user-row summary { grid-template-columns: 1fr; gap: 2px; }
  .menu-list { right: auto; left: 0; }
}
@media print {
  .nav-button, .nav-toggle { display: none !important; }
}

/* photos and internal notes */
.shots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.shots .shot { margin-top: 0; }
.shot-edit { display: grid; gap: 4px; }
.notes { margin-top: 12px; padding: 10px 12px; border: 1px dashed #b9ae9b; border-radius: 8px; background: var(--hover); }
.note-row { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.note-row form { margin: 0; }
.note-form { display: flex; gap: 8px; align-items: end; margin-top: 8px; }
.note-form textarea { flex: 1; }
button.link-dark { background: none; color: var(--muted); padding: 0; font-weight: 600; text-decoration: underline; }

/* themes: the device setting decides unless the person picked one */
:root { color-scheme: light; --field: #ffffff; --hover: #f8f4ea; --soft: #ece7dc; --note-ink: #5c3b00; --button-2: #3d3832; }
:root[data-theme="dark"] { color-scheme: dark; --ink: #ece6da; --muted: #a59d90; --paper: #171512; --card: #211e1a; --line: #3d3830; --red: #f0867c; --red-bg: #3d1f1c; --yellow: #e2b34a; --yellow-bg: #3a2f14; --green: #7cc796; --green-bg: #1b3324; --gray: #a3adb8; --gray-bg: #2a2f35; --field: #2a2621; --hover: #2c2823; --soft: #332e28; --note-ink: #f1dca4; --button-2: #4a443c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --ink: #ece6da; --muted: #a59d90; --paper: #171512; --card: #211e1a; --line: #3d3830; --red: #f0867c; --red-bg: #3d1f1c; --yellow: #e2b34a; --yellow-bg: #3a2f14; --green: #7cc796; --green-bg: #1b3324; --gray: #a3adb8; --gray-bg: #2a2f35; --field: #2a2621; --hover: #2c2823; --soft: #332e28; --note-ink: #f1dca4; --button-2: #4a443c; }
}
.sticker .muted { color: #5e584f; }
.theme-button { background: none; border: 1px solid #5e584f; border-radius: 8px; padding: 4px 10px; color: #f6f1e8; font-weight: 500; }
.foot { max-width: 980px; margin: 0 auto; padding: 0 18px 24px; }
.foot .theme-button { color: var(--muted); border-color: var(--line); }
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) { color-scheme: light; --ink: #1c1915; --muted: #5e584f; --paper: #f3efe6; --card: #fffdf8; --line: #ddd4c4; --red: #9f1d1d; --red-bg: #f8e4e1; --yellow: #8a5a00; --yellow-bg: #f8efd2; --green: #1d6b3a; --green-bg: #e3f3e7; --gray: #5c6570; --gray-bg: #eceff2; --field: #ffffff; --hover: #f8f4ea; --soft: #ece7dc; --note-ink: #5c3b00; --button-2: #3d3832; }
  .foot, .theme-button { display: none !important; }
}
.brand { white-space: nowrap; }

/* photos chosen for upload */
.picked p { margin: 0 0 6px; }
.picked-row { display: flex; flex-wrap: wrap; gap: 8px; }
.picked-item { display: grid; gap: 4px; justify-items: center; }
.picked-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--soft); }
.picked-drop { background: none; color: var(--muted); padding: 2px 6px; font-weight: 600; text-decoration: underline; }
.edit-flag[hidden] { display: none; }
.role-form .edit-flag { align-self: center; }

/* cities */
.group-city { color: var(--muted); font-weight: 500; }
.group-city::after { content: " ·"; }
.dropdown-city { color: var(--muted); font-size: 0.85rem; font-weight: 600; margin-top: 4px; }
.site-row summary { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) minmax(0, 0.7fr) minmax(0, 0.6fr); }
.field[hidden] { display: none; }
.site-facts { padding: 0 14px; margin: 8px 0 0; }
