:root {
  --ink: #141414;
  --bone: #f3efe6;
  --paper: #fffdf8;
  --yellow: #ffc629;
  --line: #d9d2c3;
  --muted: #6b665c;
  --green: #1d7a3a;
  --red: #b3261e;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--ink); color: var(--bone);
  border-bottom: 4px solid var(--yellow);
}
.top h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
.who { font-size: 13px; text-align: right; }
.who { display: flex; align-items: center; gap: 10px; }
.who .linkish { color: var(--yellow); }
.top select { width: auto; min-height: 32px; padding: 2px 6px; font-size: 14px; font-weight: 600; background: var(--ink); color: var(--yellow); border: 1px solid #555; border-radius: 6px; }
main { max-width: 560px; margin: 0 auto; padding: 12px 16px 48px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
h2 { font-size: 16px; margin: 0 0 8px; }
label, legend { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
fieldset { border: 0; padding: 0; margin: 0; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--yellow); outline-offset: 0; border-color: var(--ink); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row .grow { flex: 1; min-width: 0; }
.row textarea { flex: 1; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; font-size: 15px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 11px 4px; cursor: pointer; }
.seg label + label span { border-left: 1px solid var(--ink); }
.seg input:checked + span { background: var(--ink); color: var(--yellow); }
.seg input:focus-visible + span { outline: 2px solid var(--yellow); outline-offset: -4px; }
.tick { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 8px 0; }
.tick input { width: 22px; height: 22px; margin: 0; accent-color: var(--ink); flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; margin: 0;
}
.scanrow { display: flex; gap: 8px; margin: 0 0 12px; }
.scanrow .scan { flex: 1; margin: 0; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.quick:empty { display: none; }
.chip { min-height: 36px; padding: 0 14px; border: 1px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--yellow); }
.desk { display: none; margin: -4px 0 12px; }
#scanNote { margin: 0 0 12px; }
.dragging #form { outline: 3px dashed var(--yellow); outline-offset: 4px; }
input.scanned:not([type=radio]):not([type=checkbox]), select.scanned { background: #fff6d6; }
.btn.primary { width: 100%; margin-top: 16px; background: var(--yellow); }
.btn:disabled { opacity: .5; }
.small-btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; color: inherit; }
.photo { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 12px; }
.photo label.btn { margin: 0; font-size: 15px; }
#preview { max-height: 120px; max-width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.note { font-size: 14px; margin: 8px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--bone); }
.note.warn { background: #fde8e6; color: var(--red); }
.note.good { background: #e4f3e8; color: var(--green); }
.small { font-size: 13px; color: var(--muted); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.head-row h2 { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .what { flex: 1; min-width: 0; }
.list .what b, .list .what span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .what span { font-size: 13px; color: var(--muted); }
.list .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.list .err { color: var(--red); white-space: normal; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bone); white-space: nowrap; }
.badge.Approved, .badge.Paid { background: #e4f3e8; color: var(--green); }
.badge.Rejected { background: #fde8e6; color: var(--red); }
.remove { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
#toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: var(--bone); font-size: 14px; z-index: 5;
}
/* Laptop and desktop: the form on the left, what is waiting and sent on the right. */
@media (min-width: 960px) {
  main { max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; padding-top: 20px; }
  #signin { grid-column: 1 / -1; }
  #form { grid-column: 1; margin: 0; }
  .side { grid-column: 2; position: sticky; top: 76px; }
  #preview { max-height: 320px; }
  /* Nothing waiting or sent yet: centre the form. */
  main:not(:has(.side > section:not([hidden]))) { grid-template-columns: minmax(0, 640px); justify-content: center; }
}
@media (hover: hover) and (pointer: fine) {
  .desk { display: block; }
}
[hidden] { display: none !important; }
