:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1d2522;
  --muted: #68736f;
  --line: #d9ded8;
  --accent: #0f766e;
  --accent-soft: #e2f0ec;
  --warn: #8a5a00;
  --mark: #fff0a8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 560px);
  gap: 20px;
  align-items: center;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

h1 {
  margin: 0 0 5px;
  font-size: 22px;
  line-height: 1.2;
}

p {
  margin: 0;
}

.brand p,
.toolbar,
.meta,
.ocr {
  color: var(--muted);
}

.brand p {
  font-size: 13px;
}

.search {
  display: grid;
  grid-template-columns: 1fr 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.search input {
  min-width: 0;
  border: 0;
  padding: 0 14px;
  outline: none;
  background: transparent;
  font-size: 15px;
}

.search button {
  border: 0;
  border-left: 1px solid var(--line);
  background: #eef1ed;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.filters {
  position: sticky;
  top: 75px;
  height: calc(100vh - 75px);
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #edf1ec;
  overflow: auto;
}

.filter-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-list {
  display: grid;
  gap: 8px;
}

.filter-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  padding: 9px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.filter-item:hover {
  background: #dfe6df;
}

.filter-item span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.filter-item b {
  color: var(--accent);
  font-weight: 700;
}

.content {
  min-width: 0;
  padding: 22px 28px 42px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
}

.toolbar-actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.exact-toggle {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  white-space: nowrap;
}

.small-btn {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.small-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.records {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 15px;
}

.record {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.image-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1.2;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0;
  background: #eef1ed;
  cursor: zoom-in;
}

.image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.record-body {
  padding: 12px 13px 14px;
}

.model {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.model.missing {
  color: var(--warn);
}

.meta {
  display: grid;
  gap: 4px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.model-edit {
  display: grid;
  gap: 5px;
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.model-edit input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
  font-size: 14px;
  text-transform: uppercase;
}

.model-edit input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: var(--accent);
}

.ocr {
  margin-top: 9px;
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.actions {
  margin-top: 10px;
}

.actions a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--mark);
}

.empty {
  grid-column: 1 / -1;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: 10px;
  padding: 48px 18px 18px;
  background: rgba(12, 16, 15, 0.88);
}

.image-modal[hidden] {
  display: none;
}

.image-modal img {
  max-width: 100%;
  max-height: calc(100vh - 92px);
  object-fit: contain;
  background: #fff;
}

.modal-caption {
  max-width: min(920px, 100%);
  color: #fff;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.modal-close {
  position: fixed;
  top: 10px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    padding: 14px 16px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
  }

  .filter-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .content {
    padding: 16px;
  }
}
