:root {
  --ink: #21343b;
  --muted: #54666c;
  --paper: #eef1f2;
  --white: #fff;
  --teal: #286a72;
  --line: #ccd6d9;
  --amber: #8a5a1f;
  --red: #a62d37;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
select,
textarea,
summary {
  touch-action: manipulation;
}
a {
  color: var(--teal);
  text-underline-offset: 3px;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 600;
  min-height: 44px;
}
button:hover {
  border-color: var(--teal);
  background: #e8f1f2;
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}
.primary:hover {
  background: #205a61;
  color: white;
}
.danger {
  color: var(--red);
}
:focus-visible {
  outline: 3px solid #b47820;
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 2rem;
  letter-spacing: -0.8px;
  line-height: 1.2;
  margin-bottom: 8px;
}
h2 {
  font-size: 1.3rem;
  margin-bottom: 16px;
}
h3 {
  font-size: 1.05rem;
}
p {
  line-height: 1.55;
  max-width: 75ch;
}
.muted,
small {
  color: var(--muted);
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 218px;
  background: #e1e8ea;
  border-right: 1px solid var(--line);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  line-height: 1.4;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 25px;
  border: 2px solid var(--teal);
  border-radius: 8px;
  color: var(--teal);
}
nav {
  display: grid;
  gap: 8px;
}
.nav {
  background: transparent;
  text-align: left;
  border-color: transparent;
  font-size: 14px;
}
.nav.active {
  background: white;
  border-color: var(--line);
}
.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 18px;
  font-size: 12px;
}
.text-button {
  background: none;
  border: 0;
  color: var(--teal);
  padding: 0;
  min-height: 24px;
  font-size: inherit;
  font-weight: 500;
}
.workspace {
  margin-left: 218px;
  padding: 36px 40px;
  max-width: 1800px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-head p {
  color: var(--muted);
  margin-bottom: 0;
}
.search-area {
  margin-bottom: 24px;
}
.search-label {
  font-size: 14px;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}
input,
select,
textarea {
  border: 1px solid #b3c2c8;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
}
textarea {
  min-height: 85px;
  resize: vertical;
}
input[type="checkbox"] {
  min-height: 20px;
  width: 20px;
  accent-color: var(--teal);
}
input[type="file"] {
  font-size: 13px;
}
.check-label {
  display: flex;
  gap: 9px;
  align-items: center;
}
#search {
  font-size: 17px;
  padding: 15px 17px;
  min-height: 55px;
}
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.filters label {
  flex: 1;
  min-width: 120px;
  font-size: 12px;
  color: var(--muted);
}
.filters select,
.filters input {
  margin-top: 5px;
  font-size: 13px;
}
.size-filter {
  margin-top: 12px;
  font-size: 13px;
}
.size-filter .fields {
  max-width: 550px;
  margin-top: 12px;
}
summary {
  cursor: pointer;
  padding: 7px 0;
  font-weight: 600;
  color: var(--teal);
}
.work-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr);
  gap: 24px;
  align-items: start;
}
.work-grid.has-editor {
  grid-template-columns: minmax(240px, 0.8fr) minmax(400px, 1.3fr);
}
.result-count {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}
.material-row {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 16px;
  text-align: left;
  align-items: center;
  padding: 16px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
  min-height: 96px;
}
.material-row:first-of-type {
  border-radius: 8px 8px 0 0;
}
.material-row:last-of-type {
  border-radius: 0 0 8px 8px;
}
.material-row.selected {
  background: #e1eff0;
  box-shadow: inset 4px 0 var(--teal);
}
.material-name {
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}
.material-meta {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.stock-summary {
  font-size: 13px;
  color: var(--teal);
  line-height: 1.6;
  font-weight: 600;
  max-width: 250px;
}
.photo-placeholder,
.thumb {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 5px;
  background: #e5ecee;
  display: grid;
  place-items: center;
  color: #667c85;
  font-size: 23px;
  font-weight: 400;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #edf2f3;
  color: var(--muted);
  margin: 3px 4px 3px 0;
}
.badge.partial,
.badge.opened {
  color: var(--amber);
  background: #fff1d9;
}
.badge.reorder {
  color: var(--red);
  background: #ffe8e9;
}
.editor {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  min-width: 0;
}
.editor-heading {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: start;
}
.editor-heading h2 {
  margin-bottom: 6px;
}
.editor .material-photo {
  max-width: 100%;
  max-height: 230px;
  object-fit: contain;
  border-radius: 5px;
  margin: 15px 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}
.actions button {
  font-size: 13px;
}
.stock-entry {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}
.stock-entry p {
  margin: 7px 0;
  font-size: 13px;
}
.stock-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.stock-title strong {
  font-variant-numeric: tabular-nums;
}
.stock-entry .actions {
  margin: 10px 0 0;
}
.stock-entry .actions button {
  padding: 6px 10px;
  min-height: 38px;
}
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.fields label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  align-content: start;
}
.fields .wide {
  grid-column: 1/-1;
}
.fields .check-label {
  display: flex;
  align-items: center;
}
.form-section {
  margin: 20px 0;
}
form h3 {
  margin: 20px 0 12px;
}
.form-help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 10px 0;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.notice {
  background: #d9eddf;
  border: 1px solid #a7c6af;
  padding: 13px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
}
.notice.error,
.form-error {
  background: #fff0ef;
  color: #92232d;
  border: 1px solid #e7bdc0;
  padding: 12px;
  border-radius: 5px;
  line-height: 1.5;
}
.form-error:empty {
  display: none;
}
.empty {
  border: 1px dashed #a4b8c1;
  padding: 38px 24px;
  border-radius: 8px;
  text-align: left;
  background: #f8fafb;
}
.empty h2 {
  margin-bottom: 10px;
}
.empty p {
  font-size: 14px;
  color: var(--muted);
}
.empty-mark {
  font-size: 38px;
  color: var(--teal);
  margin-bottom: 18px;
}
.source {
  border-top: 1px solid var(--line);
  padding: 15px 0;
  font-size: 13px;
}
.history-item {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.history-item p {
  margin: 5px 0;
}
.history-item summary {
  font-size: 12px;
}
.session {
  grid-column: 1/-1;
  border-top: 2px solid var(--teal);
  padding-top: 20px;
}
.session > p {
  font-size: 13px;
  color: var(--muted);
}
.session-item {
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 12px 15px;
  font-size: 13px;
}
.auth {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 30px;
}
.auth-box {
  width: 100%;
  max-width: 440px;
  padding: 35px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.auth-box .brand-mark {
  margin-bottom: 25px;
}
.auth-box h1 {
  font-size: 2.3rem;
}
.auth-box form label {
  display: block;
  margin-bottom: 6px;
}
.auth-box form input {
  margin-top: 4px;
}
.auth-box form .primary {
  width: 100%;
}
.auth-box > .muted {
  margin: 25px 0 0;
  font-size: 12px;
}
.errorlist {
  color: var(--red);
  padding-left: 20px;
  font-size: 13px;
}
.remainder {
  border-left: 3px solid var(--line);
  padding-left: 14px;
  margin: 16px 0;
}
.helptext {
  font-size: 12px;
  color: var(--muted);
}
[hidden] {
  display: none !important;
}
@media (min-width: 1150px) {
  .has-editor .material-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .has-editor .material-row .stock-summary {
    grid-column: 2;
  }
  .has-editor .thumb,
  .has-editor .photo-placeholder {
    width: 44px;
    height: 44px;
  }
}
@media (max-width: 1149px) {
  .sidebar {
    width: 185px;
    padding: 25px 14px;
  }
  .workspace {
    margin-left: 185px;
    padding: 28px 24px;
  }
  .work-grid.has-editor {
    grid-template-columns: 1fr;
  }
  .has-editor #library {
    max-height: 310px;
    overflow: auto;
  }
  .material-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .stock-summary {
    grid-column: 2;
  }
  .thumb,
  .photo-placeholder {
    width: 48px;
    height: 48px;
  }
}
@media (max-width: 650px) {
  .sidebar {
    position: static;
    width: 100%;
    padding: 16px;
    border: 0;
    border-bottom: 1px solid var(--line);
    gap: 16px;
  }
  .brand {
    font-size: 13px;
  }
  .brand br {
    display: none;
  }
  .brand strong {
    margin-left: 5px;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 21px;
  }
  nav {
    display: flex;
  }
  .nav {
    flex: 1;
    text-align: center;
  }
  .sidebar-bottom {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 11px;
  }
  .workspace {
    margin: 0;
    padding: 22px 16px;
  }
  .page-head {
    align-items: start;
    margin-bottom: 22px;
  }
  .page-head h1 {
    font-size: 1.65rem;
  }
  .page-head p {
    font-size: 12px;
  }
  .page-head > button {
    font-size: 12px;
    padding: 8px 10px;
    white-space: nowrap;
  }
  .filters {
    gap: 10px;
  }
  .filters label {
    min-width: calc(50% - 10px);
  }
  .filters label:last-child {
    flex-basis: 100%;
  }
  .editor {
    padding: 18px;
  }
  .fields {
    gap: 12px;
  }
  .material-row {
    padding: 14px 12px;
    gap: 10px;
  }
  .material-name {
    font-size: 15px;
  }
  .stock-summary {
    max-width: none;
  }
  .auth {
    padding: 16px;
  }
  .auth-box {
    padding: 25px;
  }
  .form-actions {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 12px 0;
    margin-bottom: -5px;
  }
  .form-actions button {
    flex: 1;
  }
}

/* Keep adding and logging focused on one form, with a quiet library behind it. */
body.editing .search-area,
body.editing #library,
body.editing #session {
  display: none !important;
}
body.editing .work-grid.has-editor {
  display: block;
  max-width: 900px;
  margin: 0 auto;
}
body.editing .page-head {
  display: none;
}
body.editing .editor {
  padding: 30px 36px;
}
.form-section {
  padding: 0 0 24px;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--line);
}
.form-section h3 {
  font-size: 17px;
  margin: 22px 0 14px;
}
.optional-fields {
  margin: 14px 0;
}
.optional-fields > .fields {
  padding-top: 12px;
}
.initial-stock-row,
.purchase-row {
  margin: 16px 0 20px;
  padding: 18px;
  background: #f5f8f8;
  border-radius: 6px;
}
.remove-row {
  font-size: 12px;
  margin-top: 12px;
}
.stock-choice {
  display: flex;
  flex-direction: column;
  text-align: left;
  width: 100%;
  gap: 8px;
  margin: 12px 0;
}
.stock-choice span {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.library-filters {
  margin-top: 10px;
}
.form-actions {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 16px 0;
  margin-bottom: -10px;
  border-top: 1px solid var(--line);
  z-index: 2;
}
@media (max-width: 650px) {
  body.editing .editor {
    padding: 20px 16px;
  }
  .initial-stock-row,
  .purchase-row {
    padding: 12px;
  }
  .fields {
    grid-template-columns: 1fr;
  }
  .fields .wide {
    grid-column: 1;
  }
  .form-section {
    padding-bottom: 18px;
    margin-bottom: 18px;
  }
}
