.test-banner {
  margin: 0;
  padding: 10px 16px;
  background: #c4552a;
  color: #fffaf3;
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 30;
}
:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #1d2428;
  --muted: #5d6a72;
  --line: #d7d0c4;
  --card: #fffdf8;
  --accent: #1f6f64;
  --accent-ink: #ffffff;
  --danger: #8d2f2f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.gate, .app { min-height: 100vh; }
.gate {
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate form, .card, .modal .card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.kicker { margin: 0; color: var(--accent); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
h1, h2, h3 { margin: 6px 0 10px; }
.sub, .note { color: var(--muted); }
.note { background: #f7f3ea; border-radius: 10px; padding: 10px 12px; }
label { display: block; margin: 12px 0 6px; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split .card, #item-form, #item-search, #item-history { width: auto; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}
button.primary, button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.quiet { background: transparent; }
.error { color: var(--danger); }
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
aside {
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #ebe6dc;
}
nav { display: grid; gap: 8px; margin: 18px 0; }
nav button { text-align: left; }
nav button.active { background: var(--accent); color: white; border-color: var(--accent); }
main { padding: 28px; }
.row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.person, .version, .event {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0;
}
.perms { display: grid; gap: 6px; margin-top: 8px; }
.perms label { margin: 0; display: flex; gap: 8px; align-items: center; }
#modal-text { white-space: pre-wrap; max-width: 36rem; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(29, 36, 40, 0.45);
  display: grid;
  place-items: center;
  padding: 18px;
}
.issued {
  font-family: Consolas, monospace;
  word-break: break-all;
  background: #f7f3ea;
  padding: 12px;
  border-radius: 10px;
}
.result { white-space: pre-wrap; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .grid { grid-template-columns: 1fr; }
}

.app { height: calc(100vh - 44px); overflow: hidden; }
aside { height: calc(100vh - 44px); overflow: auto; }
main {
  height: calc(100vh - 44px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
}
#view-positions, #view-intake, #view-sheet, #view-staff, #view-tariffs, #view-audit {
  min-height: 0;
  flex: 1;
  overflow: auto;
}
#view-positions, #view-intake { display: none; flex-direction: column; overflow: hidden; }
#view-positions:not([hidden]), #view-intake:not([hidden]) { display: flex; }
.desk-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  padding: 2px 0 4px;
  background: var(--bg);
}
.desk-bar h2 { margin: 0 8px 0 0; font-size: 18px; }
.desk-bar input, .desk-bar select, .desk-bar button { width: auto; height: 26px; padding: 0 6px; border-radius: 4px; }
.desk-bar input { min-width: 140px; }
.check { display: flex; gap: 4px; align-items: center; margin: 0; font-size: 14px; }
.inline-note, .save-state { margin: 0; color: var(--muted); font-size: 13px; }
.find-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 2px 0 6px;
}
.find-bar h2 { margin: 0; font-size: 18px; }
.find-query {
  flex: 1 1 280px;
  min-width: 240px;
  height: 36px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 16px;
}
.find-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.find-filter input, .find-filter select { width: 108px; height: 32px; padding: 0 6px; border-radius: 4px; }
#find-reset, #find-scope { height: 32px; padding: 0 10px; }
#desk, #find-results { overflow: auto; min-height: 0; }
#desk, #find-results { flex: 1; }
.no-photo { color: var(--muted); font-size: 12px; }
.accept-cell { white-space: nowrap; }
#find-results .accept-cell input { width: 72px; }
.accept-cell .primary, .accept-now { font-weight: 700; }
#find-results table { table-layout: fixed; width: 100%; }
#find-results th:nth-child(1), #find-results td:nth-child(1) { width: 64px; }
#find-results th:nth-child(3), #find-results td:nth-child(3) { width: 120px; }
#find-results th:nth-child(4), #find-results td:nth-child(4) { width: 120px; }
#find-results th:nth-child(5), #find-results td:nth-child(5) { width: 88px; }
#find-results th:nth-child(5) { white-space: normal; line-height: 1.15; font-size: 12px; }
#find-results .photo-cell { overflow: hidden; }
#find-results .photo-cell img {
  display: block;
  width: 100%;
  height: 48px;
  max-width: 100%;
  object-fit: cover;
  cursor: zoom-in;
}
#find-more { margin: 8px 0; }
#find-results th:nth-child(6), #find-results td:nth-child(6) { width: 108px; }
#find-results th:last-child, #find-results td:last-child { width: 148px; }
#find-results td:nth-child(3),
#find-results td:nth-child(4),
#find-results td:nth-child(6) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-cell { position: relative; white-space: normal; vertical-align: top; line-height: 1.3; }
.product-url {
  display: block;
  color: var(--accent);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.product-cell .product-source {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.product-cell:focus-within .product-source {
  position: static;
  width: 100%;
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  opacity: 1;
  pointer-events: auto;
}
.product-cell:focus-within .product-url { display: none; }
#desk .product-col, #desk .product-cell { width: 34%; }
#find-results th:last-child, #find-results td.accept-cell {
  position: sticky;
  right: 0;
  background: var(--card);
}
#find-results th:last-child { z-index: 3; background: #f3efe6; }
.buyout { margin: 0 0 14px; }
.buyout-head {
  margin: 8px 0 4px;
  padding: 3px 8px;
  font-size: 14px;
  font-weight: 600;
  border-left: 6px solid var(--accent);
}
.tone-0 { border-color: #1f6f64; background: #e7f3f1; }
.tone-1 { border-color: #8a5a12; background: #f8f1e4; }
.tone-2 { border-color: #24527a; background: #e8f0f6; }
.tone-3 { border-color: #6d3b55; background: #f6eaf0; }
.buyout-head input { height: 22px; margin-left: 4px; padding: 0 4px; border-radius: 4px; width: auto; }
.desk table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  line-height: 1.25;
  background: var(--card);
}
.desk th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f3efe6;
  text-align: left;
  font-weight: 600;
}
.desk th, .desk td { padding: 0 4px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1; }
.desk td input, .desk td select, .desk td button { margin: 0; vertical-align: middle; }
.desk input, .desk select {
  width: 100%;
  height: 22px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 14px;
}
.desk button { height: 22px; padding: 0 6px; border-radius: 4px; font-size: 13px; }
.buyout-head { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; min-height: 0; }
.buyout-head input { width: 180px; height: 22px; flex: 0 0 auto; }
.client-cell, .photo-cell { position: relative; }
.photo-tools { display: flex; align-items: center; gap: 2px; height: 24px; white-space: nowrap; }
.photo-tools img { width: 22px; height: 22px; object-fit: cover; display: block; cursor: zoom-in; }
.photo-tools input[type=file] { display: none; }
.suggest {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 100%;
  width: 280px;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
}
.suggest button { display: block; width: 100%; height: auto; text-align: left; border: 0; border-radius: 0; background: #fff; padding: 4px 6px; }
.suggest small { display: block; color: var(--muted); }
.row-historical { background: #f6f1e8; }
#distribution-form.compact, #view-intake .card { padding: 6px 8px; margin: 4px 0; }
#distribution-form.compact { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#distribution-form.compact h3, #distribution-form.compact label { margin: 0; font-size: 13px; }
#distribution-form.compact input, #distribution-form.compact select { width: 160px; height: 26px; padding: 0 6px; }
#view-intake .card label { margin: 4px 0 2px; }
#view-intake .card input, #view-intake .card select { height: 26px; padding: 2px 6px; }
.legacy { margin-top: 8px; }
.photo-view {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(20, 24, 28, 0.72);
  padding: 24px;
}
.photo-view img { max-width: min(92vw, 1100px); max-height: 86vh; background: #fff; }
.photo-view button { position: absolute; top: 12px; right: 12px; }
