:root {
  --paper: #eceae3;
  --panel: #f7f6f2;
  --ink: #1b1f24;
  --ink-soft: #4a5159;
  --line: #cfcabd;
  --line-soft: #e0dcd0;
  --steel: #2f4d6e;
  --steel-deep: #21384f;
  --amber: #d98a1f;
  --amber-deep: #b06f12;
  --flag: #c2502b;
  --full: #3f7d52;
  --ghost: #ded9cd;
  --shadow: 0 1px 0 #fff inset, 0 2px 10px rgba(27, 31, 36, 0.07);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background-image: radial-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 22px 22px;
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
}
.mono {
  font-family: "IBM Plex Mono", monospace;
}
a {
  color: var(--steel-deep);
}
header.top {
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.top-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 22px 16px;
  flex-wrap: wrap;
}
h1 {
  font-family: "Saira Condensed", sans-serif;
  font-weight: 700;
  font-size: 33px;
  line-height: 1;
  margin: 0;
  letter-spacing: 0.01em;
}
.sub {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin: 7px 0 0;
  text-transform: uppercase;
}
.tally {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: right;
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 14px;
}
.tally b {
  color: var(--ink);
  font-weight: 600;
}
.tally .arr {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--full);
  margin-right: 6px;
}
.navlink {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.navlink:hover {
  background: var(--ink);
  color: var(--paper);
}
.navlink.primary {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}
.navlink.primary:hover {
  background: var(--steel-deep);
  border-color: var(--steel-deep);
}
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 6px;
  flex-wrap: wrap;
}
.controls .lbl {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
#search {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  border: 1.5px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 11px;
  border-radius: 2px;
  min-width: 230px;
}
#search::placeholder {
  color: #9a9486;
}
.seg {
  display: inline-flex;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  overflow: hidden;
}
.seg button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 0;
  background: transparent;
  padding: 7px 13px;
  cursor: pointer;
  color: var(--ink);
  border-right: 1px solid var(--line);
}
.seg button:last-child {
  border-right: 0;
}
.seg button.active {
  background: var(--ink);
  color: var(--paper);
}
.csvbtn {
  margin-left: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
}
.csvbtn:hover {
  background: var(--ink);
  color: var(--paper);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(370px, 1fr));
  gap: 20px;
  padding: 14px 0 54px;
}
#listview {
  padding: 14px 0 54px;
}
.ltwrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.ltable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: var(--panel);
  min-width: 1180px;
}
.ltable th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: #f0ede5;
  white-space: nowrap;
}
.ltable th.r,
.ltable td.r {
  text-align: right;
}
.ltable td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.ltable tbody tr:last-child td {
  border-bottom: 0;
}
.ltable tbody tr {
  cursor: pointer;
}
.ltable tbody tr:hover {
  background: #f0ede5;
}
.ltable td.pn {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  white-space: nowrap;
}
.ltable td.cost {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  color: var(--steel-deep);
  white-space: nowrap;
}
.ltable td.note {
  color: var(--ink-soft);
}
.ltable .lthumb {
  width: 44px;
  height: 38px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 2px;
  display: block;
  background: #20242a;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.card .head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 11px;
  border-bottom: 1px solid var(--line-soft);
  align-items: flex-start;
}
.card .pn {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  margin: 0;
  word-break: break-word;
}
.card .vendor {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  margin: 3px 0 0;
}
.card .cost {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--steel-deep);
  white-space: nowrap;
}
.card .editbtn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid #fff;
  background: rgba(20, 24, 28, 0.72);
  color: #fff;
  padding: 4px 9px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
}
.card .editbtn:hover {
  background: var(--steel);
}
.hero {
  position: relative;
  background: #20242a;
  aspect-ratio: 4/3;
  overflow: hidden;
  cursor: zoom-in;
}
.hero .stage {
  width: 100%;
  height: 100%;
  position: relative;
}
.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero .count {
  position: absolute;
  right: 9px;
  bottom: 9px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(20, 24, 28, 0.72);
  padding: 3px 8px;
  border-radius: 2px;
}
.thumbs {
  display: flex;
  gap: 5px;
  padding: 8px 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
  background: #f1efe8;
}
.thumbs img {
  width: 52px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.7;
  transition:
    opacity 0.15s,
    border-color 0.15s;
}
.thumbs img:hover {
  opacity: 1;
}
.thumbs img.active {
  opacity: 1;
  border-color: var(--steel);
  box-shadow: 0 0 0 1px var(--steel);
}
.specs {
  padding: 11px 16px 15px;
}
.specs table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.specs td {
  padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.specs tr:last-child td {
  border-bottom: 0;
}
.specs td.k {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
  width: 118px;
  padding-right: 12px;
  padding-top: 7px;
}
.specs td.v {
  color: var(--ink);
}
.pill {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #efece4;
  color: var(--ink-soft);
}
.note {
  color: var(--ink-soft);
  font-size: 12.5px;
}
footer {
  border-top: 1px solid var(--line);
  padding: 16px 0 40px;
}
footer p {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #9a9486;
  letter-spacing: 0.03em;
  margin: 0;
}
.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

/* lightbox */
.lb {
  position: fixed;
  inset: 0;
  background: rgba(16, 18, 21, 0.94);
  display: none;
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.lb.open {
  display: flex;
}
.lb .stage {
  position: relative;
  max-width: 92vw;
  max-height: 82vh;
}
.lb img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  display: block;
}
.lb .cap {
  font-family: "IBM Plex Mono", monospace;
  color: #d8d4c8;
  font-size: 12px;
  margin-top: 14px;
  letter-spacing: 0.05em;
}
.lb .x {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 30px;
  color: #d8d4c8;
  cursor: pointer;
  line-height: 1;
  font-family: "IBM Plex Sans", sans-serif;
}
.lb .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 40px;
  color: #d8d4c8;
  cursor: pointer;
  user-select: none;
  padding: 10px 18px;
  font-family: "IBM Plex Sans", sans-serif;
}
.lb .prev {
  left: 6px;
}
.lb .next {
  right: 6px;
}
.lb .x:hover,
.lb .nav:hover {
  color: #fff;
}
@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .lb .nav {
    font-size: 32px;
    padding: 8px 10px;
  }
}

/* read-only annotation overlay (shared by gallery hero, lightbox, editor) */
.anno-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.anno-box {
  position: absolute;
  border: 1.5px solid var(--amber);
  background: rgba(20, 24, 28, 0.62);
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.25;
  padding: 3px 6px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anno-box.nobg {
  background: transparent;
}
.anno-box .leader {
  position: absolute;
  background: var(--amber);
  height: 1.5px;
  transform-origin: 0 0;
  pointer-events: none;
}

/* ---- forms (login / editor) ---- */
.formcard {
  max-width: 640px;
  margin: 40px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.formcard h2 {
  font-family: "Saira Condensed", sans-serif;
  font-size: 24px;
  margin: 0 0 18px;
}
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
  border: 1.5px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 2px;
}
.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}
.field .check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field .check input {
  width: 16px;
  height: 16px;
}
.formgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.formgrid .field.span2 {
  grid-column: 1/-1;
}
@media (max-width: 640px) {
  .formgrid {
    grid-template-columns: 1fr;
  }
}
.formerr {
  background: #fceceac;
  border: 1px solid var(--flag);
  color: var(--flag);
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 13px;
  margin-bottom: 14px;
}
.btnrow {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.btn {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn.primary {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}
.btn.primary:hover {
  background: var(--steel-deep);
  border-color: var(--steel-deep);
}
.btn.danger {
  border-color: var(--flag);
  color: var(--flag);
}
.btn.danger:hover {
  background: var(--flag);
  color: #fff;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled:hover {
  background: transparent;
  color: var(--ink);
}

/* ---- image uploader ---- */
.uploader {
  border: 1.5px dashed var(--line);
  border-radius: 4px;
  padding: 20px;
  text-align: center;
  background: #f1efe8;
  cursor: pointer;
}
.uploader.drag {
  border-color: var(--steel);
  background: #e9eef3;
}
.uploader p {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
}
.imglist {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.imgcard {
  position: relative;
  width: 120px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}
.imgcard .thumbwrap {
  position: relative;
  overflow: hidden;
}
.imgcard .thumb {
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
  background: #20242a;
}
.imgcard .delbtn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #fff;
  background: rgba(20, 24, 28, 0.72);
  color: #fff;
  font-size: 12px;
}
.imgcard .delbtn:hover {
  background: var(--flag);
  border-color: var(--flag);
}
.imgcard .row {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 5px 6px;
  gap: 4px;
  overflow: hidden;
}
.imgcard button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: #fff;
  padding: 3px 6px;
  border-radius: 2px;
  cursor: pointer;
}
.imgcard button:hover {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.imgcard .status {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 28, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  text-align: center;
  padding: 6px;
}

/* ---- annotator ---- */
.annobar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.annobar .sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}
.annostage-wrap {
  padding: 22px;
  display: flex;
  justify-content: center;
}
.annostage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  background: #20242a;
  box-shadow: var(--shadow);
}
.annostage img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.anno-edit {
  position: absolute;
  border: 1.5px dashed var(--amber);
  background: rgba(20, 24, 28, 0.55);
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.25;
  padding: 3px 6px;
  border-radius: 2px;
  cursor: move;
  min-width: 28px;
  min-height: 20px;
}
.anno-edit.selected {
  border-color: var(--full);
  box-shadow: 0 0 0 1px var(--full);
}
.anno-edit .txt {
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.anno-edit .resize {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--full);
  border-radius: 50%;
  cursor: nwse-resize;
}
.styles-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.styles-row label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 5px;
}
