:root {
  --bg: #f4f1e8;
  --ink: #122017;
  --muted: #3d4a41;
  --card: #fffdf6;
  --line: #c9c3b2;
  --pass: #1b7a46;
  --fail: #b42318;
  --skip: #8a5a00;
  --open: #4a5560;
  --accent: #0b3d2e;
  --btn: #0b3d2e;
  --btn-ink: #fffdf6;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

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

body {
  padding: 0 0 calc(12px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

.top {
  background: var(--accent);
  color: #fffdf6;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}

.header-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.brand-left {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}

.brand-logo {
  display: block;
  width: 100px;
  height: 100px;
  max-width: 100px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fffdf6;
  border-radius: 8px;
  padding: 8px;
  box-sizing: border-box;
}

.site-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  max-width: 9.5em;
}

.brand-right {
  margin-left: auto;
  text-align: right;
  min-width: 0;
  flex: 1 1 auto;
}

.page-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.lede {
  margin: 0;
  opacity: 0.92;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top .whoami {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .header-row {
    flex-wrap: wrap;
  }

  .brand-right {
    flex-basis: 100%;
    margin-left: 0;
    text-align: left;
  }
}

.tabs.hidden,
.top .signed-in {
  display: none;
}

body.authed .signed-in {
  display: block;
  margin: 8px 0 0;
  font-size: 15px;
}

.login-card input {
  font-size: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1.55fr 1fr 1fr;
  gap: 4px;
  padding: 8px;
  background: #e8e2d2;
  position: sticky;
  top: 0;
  z-index: 5;
}

.tabs button {
  min-height: var(--tap);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}

.tabs button.active {
  background: var(--accent);
  color: #fff;
}

.tabs button.inspect-tab {
  background: #c45c12;
  color: #fffdf6;
  font-size: 16px;
  min-height: 56px;
  border: 2px solid #9a4308;
  box-shadow: 0 2px 0 #7a3206;
}

.tabs button.inspect-tab.active {
  background: #9a4308;
  color: #fffdf6;
  border-color: #7a3206;
}

.generate-report-btn {
  min-height: 56px;
  font-size: 18px;
}

a.export-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin-top: 8px;
  border-radius: 12px;
  background: var(--btn);
  color: var(--btn-ink);
  font-weight: 800;
  text-decoration: none;
  border: 2px solid var(--btn);
}

a.export-pdf.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.index-item {
  display: grid;
  gap: 6px;
}

main {
  padding: 12px 12px 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

button.stat {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-height: 76px;
  -webkit-tap-highlight-color: transparent;
}

button.stat:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button.stat.stat-fail {
  border-color: #e3b4af;
  background: #fff6f5;
}

button.stat.stat-skip {
  border-color: #e4c48a;
  background: #fff8ea;
}

button.stat:active {
  transform: scale(0.98);
}

.stat b {
  display: block;
  font-size: 1.6rem;
}

.list-heading {
  margin: 12px 0 8px;
  font-size: 1.15rem;
}

.status-box-card {
  scroll-margin-top: 88px;
}

.status-box-card .comment-preview {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--muted);
}

.tap-lg {
  min-height: 56px;
  font-size: 17px;
  font-weight: 700;
}

.status-box-card .secondary {
  margin-top: 8px;
}

.comment-form {
  margin-top: 12px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.done,
.badge.pass {
  background: #d7f3e2;
  color: var(--pass);
}
.badge.fail {
  background: #fde8e6;
  color: var(--fail);
}
.badge.skip {
  background: #ffe9c2;
  color: var(--skip);
}
.badge.open {
  background: #e7ebef;
  color: var(--open);
}

label,
.field-label {
  display: block;
  font-weight: 700;
  margin: 12px 0 6px;
}

input,
select,
textarea,
button.primary,
button.secondary,
.file-btn {
  width: 100%;
  min-height: var(--tap);
  font: inherit;
  border-radius: 12px;
  border: 2px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

button.primary {
  background: var(--btn);
  color: var(--btn-ink);
  border-color: var(--btn);
  font-weight: 800;
  margin-top: 16px;
}

button.secondary {
  background: #fff;
  font-weight: 700;
  margin-top: 8px;
}

button.danger {
  background: #7a1b14;
  color: #fff;
  border-color: #7a1b14;
  width: 100%;
  min-height: var(--tap);
  font-weight: 800;
  margin-top: 8px;
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segment label {
  margin: 0;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 800;
  font-size: 15px;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment label:has(input:checked) {
  border-color: var(--accent);
  background: #d7efe4;
}

.hint {
  color: var(--muted);
  font-size: 15px;
  margin: 4px 0 0;
}

.search {
  margin-bottom: 10px;
}

.status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.status-filters button {
  flex: 1 1 calc(50% - 8px);
  min-height: 52px;
  width: auto;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
}

.status-filters button.active {
  background: var(--accent);
  color: #fffdf6;
  border-color: var(--accent);
}

.status-filters button[data-box-status="fail"].active {
  background: var(--fail);
  border-color: var(--fail);
}

.status-filters button[data-box-status="skip"].active {
  background: var(--skip);
  border-color: var(--skip);
}

.status-filters button[data-box-status="done"].active {
  background: var(--pass);
  border-color: var(--pass);
}

.box-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.box-list li {
  margin: 0 0 8px;
}

.box-list button,
.linkish {
  width: 100%;
  text-align: left;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 10px 12px;
  font: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 6px;
  text-align: left;
  vertical-align: top;
}

.file-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  margin: 0;
  background: #fff;
  color: var(--ink);
}

.photo-slot {
  margin: 8px 0 12px;
  position: relative;
}

.photo-fig {
  margin: 0 0 12px;
}

.photo-fig figcaption {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 4px;
}

.preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 8px;
  background: #ddd;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 20;
}

.field-card h2 {
  margin-top: 0;
}

.field-card ol {
  padding-left: 1.2em;
}

.warn {
  background: #fff3d6;
  border: 1px solid #e0b34a;
  border-radius: 12px;
  padding: 10px 12px;
}

.hidden-ir {
  display: none;
}

@media (min-width: 700px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

body:not(.authed) .tabs {
  display: none;
}

.whoami {
  display: none;
}

body.authed .whoami {
  display: block;
}

.login-card input {
  font-size: 18px;
}

.password-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.password-wrap input {
  flex: 1;
  min-width: 0;
}

.password-toggle {
  flex: 0 0 48px;
  width: 48px;
  min-height: var(--tap);
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.password-toggle .eye-icon {
  width: 28px;
  height: 28px;
}
