* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f4f7fb 0%, #f5f6f8 55%, #f3f4f7 100%);
  color: #222;
}

.container {
  max-width: 980px;
  margin: 0 auto;
}

.card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  /* padding: 14px; */
  border: 1px solid #e7ecf3;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
  margin-bottom: 12px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

input,
select,
button {
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

button {
  background: #111;
  color: #fff;
  border: none;
}

button.secondary {
  background: #efefef;
  color: #222;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  border-bottom: 1px solid #eee;
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

.thumb {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  border: 1px solid #e9ecef;
}

.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f3f5;
  color: #6c757d;
  font-size: 12px;
  cursor: default;
}

.remark-input {
  min-width: 180px;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f1f1;
}

.tag.on {
  background: #0c7;
  color: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal img {
  max-width: min(96vw, 760px);
  max-height: 90vh;
  border-radius: 10px;
}

#uploadResult {
  white-space: pre-wrap;
  min-height: 44px;
}

.item-card {
  border-radius: 12px;
}

.search-card {
  border-radius: 18px;
  background: linear-gradient(160deg, #ffffff 0%, #f8fbff 100%);
}

.page-header {
  padding: 6px 2px 2px;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #1f2937;
  margin: 0;
}

.search-card .form-control,
.search-card .form-select {
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid #d7dee8;
  background: #fcfdff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.search-card .form-control:focus,
.search-card .form-select:focus {
  border-color: #93b4ff;
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.14);
  background: #fff;
}

.search-card .btn {
  min-height: 38px;
  border-radius: 8px;
}

.search-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-direction: row;
}

.search-main-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}

.search-input {
  flex: 1 1 70%;
  min-width: 0;
}

.search-select {
  flex: 0 1 20%;
  min-width: 88px;
  width: 20%;
  font-size: 13px;
  padding-left: 8px;
  padding-right: 28px;
}

.sort-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sort-btn {
  width: 100%;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid #cfd4dc;
  background: #fff;
  color: #5c6675;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 600;
}

.sort-btn:hover {
  background: #f6f8fb;
  border-color: #aeb8c4;
  color: #3b4452;
}

.sort-btn.active {
  background: #e7f0ff;
  border-color: #9ec5fe;
  color: #0d6efd;
}

.sort-label {
  font-size: 14px;
}

.sort-arrow {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.search-btn,
.reset-btn {
  flex: 0 0 10%;
  min-width: 64px;
  width: 10%;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding-left: 0;
  padding-right: 0;
}

.search-btn {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border: none;
  box-shadow: 0 6px 14px rgba(17, 24, 39, 0.18);
}

.search-btn:hover {
  transform: translateY(-1px);
}

.reset-btn {
  background: #f8fafc;
  color: #4b5563;
  border: 1px solid #c6cfdb;
}

.reset-btn:hover {
  background: #eff3f8;
  color: #374151;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.action-btn {
  min-height: 34px;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 8px;
}

.pin-icon-btn {
  min-height: 28px;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 8px;
  line-height: 1;
}

.pin-icon-btn.pin-on {
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #ad6800;
}

.pin-icon-btn.pin-on:hover {
  background: #ffe7ba;
  border-color: #ffc069;
  color: #874d00;
}

.pin-icon-btn.pin-off {
  background: #fff;
  border: 1px solid #cfd4dc;
  color: #5c6675;
}

.pin-icon-btn.pin-off:hover {
  background: #f6f8fb;
  border-color: #aeb8c4;
  color: #3b4452;
}

.procurement-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.proc-icon {
  font-size: 14px;
  line-height: 1;
}

.proc-text {
  line-height: 1;
}

.remark-empty-btn {
  width: 100%;
  margin-bottom: 8px;
}

.remark-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 52px;
  padding: 4px 0;
  margin-bottom: 8px;
}

.remark-line-label {
  color: #6c757d;
  font-size: 13px;
  flex: 0 0 auto;
}

.remark-line-text {
  flex: 1 1 auto;
  min-width: 0;
  color: #343a40;
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: calc(1.35em * 2);
}

.remark-edit-btn {
  flex: 0 0 auto;
  min-height: 28px;
  min-width: 34px;
  padding: 2px 8px;
  border: 1px solid #cfd4dc;
  background: #fff;
  color: #495057;
}

.remark-edit-btn:hover {
  border-color: #aeb8c4;
  background: #f6f8fb;
  color: #212529;
}

.footer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.page-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-size-wrap .form-select {
  width: 80px;
}

.serial-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #0d6efd;
}

@media (max-width: 576px) {
  body {
    padding: 10px;
  }

  .container {
    padding-left: 2px;
    padding-right: 2px;
  }

  .btn {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-padding-x: 0.5rem;
    --bs-btn-font-size: 0.78rem;
  }

  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .search-toolbar {
    gap: 8px;
  }

  .search-main-row {
    gap: 6px;
  }

  .search-select {
    min-width: 84px;
    font-size: 12px;
    padding-left: 7px;
  }

  .search-btn {
    min-width: 58px;
    font-size: 12px;
  }

  .sort-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .sort-btn {
    min-height: 36px;
    font-size: 13px;
  }

  .sort-label {
    font-size: 13px;
  }

  .sort-arrow {
    font-size: 16px;
  }

  .action-btn {
    font-size: 12px;
    min-height: 32px;
  }

  .remark-line {
    min-height: 48px;
  }

  .remark-line-label,
  .remark-line-text {
    font-size: 12px;
  }

  .pin-icon-btn {
    min-height: 26px;
    min-width: 30px;
  }

  .serial-badge {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .thumb {
    width: 130px;
    height: 130px;
  }
}
