:root {
  --bg: #f6f5f1; --surface: #ebeae4; --paper: #ffffff;
  --ink: #13213a; --muted: #5a6273; --accent: #1c3768;
  --ok: #24573a; --warn: #8a2c1d; --line: #d6d7dc;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { font-family: "STIX Two Text", Georgia, serif; font-weight: 400; letter-spacing: -0.01em; margin: 0 0 12px; }
h2 { font-size: 1.5rem; } h3 { font-size: 1.1rem; margin-top: 20px; }
a { color: inherit; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
button { font: inherit; background: var(--accent); color: #fff; border: 0; border-radius: 0; padding: 9px 16px; cursor: pointer; }
button:hover:not(:disabled) { background: var(--ink); }
button:disabled { opacity: 0.45; cursor: default; }
button.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px #aeb2bc; }
button.ghost:hover:not(:disabled) { background: var(--surface); }
button.danger { background: var(--warn); }
.linklike { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.linklike:hover { background: none !important; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid #b9bcc4; border-radius: 0; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=file] { border: 0; background: none; padding: 6px 0; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; font-size: 15px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); margin: 8px 0; }
.msg { min-height: 1.4em; margin: 10px 0 0; }
.msg.ok { color: var(--ok); } .msg.bad { color: var(--warn); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login__box { width: min(380px, 90vw); }
.login__mark { font-family: "STIX Two Text", Georgia, serif; font-size: 3rem; font-weight: 600; letter-spacing: -0.03em; margin: 0; line-height: 1; }
.login h1 { font-size: 1.25rem; margin: 8px 0 28px; color: var(--muted); }
.login form { display: grid; gap: 14px; }
.login button { margin-top: 6px; padding: 12px; }

/* bar */
.bar { display: flex; align-items: center; gap: 24px; padding: 0 24px; background: var(--ink); color: #fff; min-height: 56px; flex-wrap: wrap; }
.bar__mark { font-family: "STIX Two Text", Georgia, serif; font-size: 1.35rem; font-weight: 600; text-decoration: none; }
.bar__mark span { font-weight: 400; opacity: 0.7; font-size: 1rem; }
.tabs { display: flex; gap: 2px; }
.tabs button { background: transparent; color: #c9cfdb; padding: 18px 14px; }
.tabs button[aria-selected=true] { color: #fff; box-shadow: inset 0 -3px 0 #fff; }
.tabs button:hover { background: rgba(255,255,255,0.06) !important; }
.bar__right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.bar__right .ghost { color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4); }
.bar__right .ghost:hover { background: rgba(255,255,255,0.1) !important; }

main { padding: 24px; max-width: 1280px; margin: 0 auto; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 360px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--paper); }
.grid th, .grid td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th { font-weight: 600; font-size: 13px; color: var(--muted); background: var(--surface); }
.grid td.c, .grid th.c { width: 36px; text-align: center; }
.grid tbody tr:hover { background: #f8f8f6; }
.grid .no { font-weight: 600; letter-spacing: 0.02em; }
.grid .thumb { width: 36px; height: 36px; object-fit: cover; display: block; background: var(--surface); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 14px; }

.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.step { background: var(--paper); padding: 24px; }
.step > * + * { margin-top: 12px; }
.fit { border: 0; padding: 0; margin: 12px 0; }
.fit legend { font-size: 13px; color: var(--muted); padding: 0; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 13px; display: block; overflow: auto; max-height: 300px; }
.preview-table th, .preview-table td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: left; white-space: nowrap; }
progress { width: 100%; height: 8px; }
.issues { margin: 8px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; max-height: 220px; overflow: auto; }

.edit { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.edit__fields { background: var(--paper); padding: 24px; display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.edit__side h3:first-child { margin-top: 0; }
.photo-box { width: 200px; height: 200px; background: var(--surface); display: grid; place-items: center; overflow: hidden; margin-bottom: 8px; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.preview { display: grid; gap: 10px; }
.preview .ngc { --k: calc(360px / 85.6); }

.settings { background: var(--paper); padding: 24px; display: grid; gap: 14px; max-width: 560px; }

.small { font-size: 13px; }
.filebtn { position: relative; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; padding: 9px 16px; font-size: 15px; cursor: pointer; }
.filebtn:hover { background: var(--ink); }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.filebtn:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.sigset { display: grid; gap: 8px; }
.sigset__label { font-size: 13px; color: var(--muted); }
.sigset__box { height: 90px; background: var(--paper); box-shadow: inset 0 0 0 1px #b9bcc4; display: grid; place-items: center; padding: 8px; }
.sigset__box img { max-height: 74px; max-width: 100%; }
.preview .ngc + .ngc { margin-top: 4px; }

@media (max-width: 900px) {
  .steps, .edit { grid-template-columns: 1fr; }
  main { padding: 16px 12px 96px; }
  .edit__side { order: -1; }
  .photo-box { width: 160px; height: 160px; }
  .preview .ngc { --k: calc((100vw - 24px) / 85.6); }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  input, select, textarea { font-size: 16px; padding: 11px 12px; } /* 16px stops iOS zooming */
  button, .filebtn { padding: 12px 16px; }
  .bar { padding: 0 12px; gap: 0; min-height: 0; }
  .bar__mark { padding: 12px 0; }
  .bar__right { margin-left: auto; gap: 10px; font-size: 14px; }
  .tabs { order: 3; width: calc(100% + 24px); margin: 0 -12px; overflow-x: auto; scrollbar-width: none; background: rgba(255,255,255,0.04); }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; padding: 14px 14px; flex: none; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar input[type=search] { grid-column: 1 / -1; max-width: none; }
  .toolbar .spacer { display: none; }
  #sel-count { grid-column: 1 / -1; }
  .toolbar button { width: 100%; font-size: 14px; }

  /* report list as cards */
  table.grid, .grid tbody { display: block; background: none; }
  .grid thead { display: none; }
  .grid tr { display: grid; grid-template-columns: 32px 1fr 64px; grid-template-areas: "c no ph" "c t ph" "c i ph" "c w ed" "c d ed"; column-gap: 12px; background: var(--paper); padding: 12px; margin-bottom: 10px; }
  .grid td { border: 0; padding: 1px 0; font-size: 15px; }
  .grid td.c { grid-area: c; width: auto; align-self: start; padding-top: 2px; }
  .grid td.c input { width: 22px; height: 22px; }
  .grid td.no { grid-area: no; font-size: 17px; }
  .grid td[data-label="Type"] { grid-area: t; color: var(--muted); }
  .grid td[data-label="Item"] { grid-area: i; }
  .grid td[data-label="Weight"] { grid-area: w; }
  .grid td[data-label="Date"] { grid-area: d; color: var(--muted); }
  .grid td.ph { grid-area: ph; }
  .grid td.ph .thumb { width: 64px; height: 64px; }
  .grid td.ed { grid-area: ed; align-self: end; }
  .grid td.ed button { width: 64px; padding: 8px 0; }
  .grid tr td[colspan] { grid-column: 1 / -1; }
  .pager { justify-content: space-between; }

  .step, .edit__fields, .settings { padding: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .actions--sticky { position: sticky; bottom: 0; z-index: 2; background: var(--paper); margin: 0 -16px -16px; padding: 12px 16px; box-shadow: 0 -1px 0 var(--line); }
  .actions--sticky .spacer { display: none; }
  .actions--sticky button[type=submit] { flex: 1 1 100%; }
}
