:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1d4ed8;
  --danger: #dc2626;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  white-space: nowrap;
  word-break: keep-all;
}

.muted {
  color: var(--muted);
}

main {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 24px;
}

.card,
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.row-compact {
  margin-bottom: 6px;
}

.row input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.msg {
  min-height: 20px;
}

.risk {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 8px;
  padding: 8px 10px;
}

.hidden {
  display: none !important;
}

.session-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.search-input {
  min-width: 240px;
  flex: 1 1 280px;
  max-width: 420px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
}

.channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.channel-title {
  margin: 0;
  font-size: 16px;
}

.channel-head-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.channel-count {
  font-size: 12px;
  color: var(--muted);
}

.channel-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}

.goods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.goods-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 118px 10px 10px;
  min-height: 112px;
  background: #fff;
}

.goods-thumb-wrap {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 96px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.goods-icon {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.goods-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.goods-name {
  font-weight: 600;
  line-height: 1.3;
}

.goods-meta {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
}

.meta-line {
  line-height: 1.45;
}

.meta-label {
  font-weight: 700;
}

.info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.info-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 12px;
  font-weight: 700;
  cursor: help;
  user-select: none;
}

.info-popover {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: max-content;
  max-width: min(360px, calc(100vw - 24px));
  background: #111827;
  color: #f9fafb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.info-wrap.is-right .info-popover {
  left: auto;
  right: 0;
}

.info-wrap:hover .info-popover,
.info-wrap:focus-within .info-popover {
  display: block;
}

.soldout-mark {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.14);
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
}

footer {
  margin: 18px auto 24px;
  max-width: 1200px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.captcha-row img {
  width: 120px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(1px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-panel {
  min-width: 220px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #c7d2fe;
  border-top-color: #1d4ed8;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .goods-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 24px;
    line-height: 1.2;
  }

  .session-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    column-gap: 10px;
    row-gap: 6px;
    width: 100%;
    font-size: 13px;
  }

  .session-bar span {
    min-height: 20px;
    line-height: 1.4;
  }

  .session-bar .btn {
    grid-column: 1 / -1;
    justify-self: start;
    margin-top: 2px;
  }

  main {
    margin: 12px auto;
    padding: 0 10px 16px;
  }

  .card,
  .panel {
    padding: 12px;
  }

  .row input {
    min-width: 0;
    width: 100%;
  }

  .row .btn {
    width: 100%;
  }

  .toolbar .btn,
  .toolbar .search-input,
  .toolbar .check-inline {
    width: 100%;
    max-width: none;
  }

  .check-inline {
    justify-content: flex-start;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head .btn {
    width: 100%;
  }

  .goods-card {
    padding: 10px;
    min-height: 0;
  }

  .goods-thumb-wrap {
    position: static;
    margin: 2px auto 10px;
    width: 132px;
    height: 96px;
  }

  .goods-title-row {
    justify-content: center;
  }

  .goods-name {
    text-align: center;
  }

  .info-popover {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(360px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
  }

  .info-wrap.is-right .info-popover {
    right: auto;
  }

  .soldout-mark {
    right: 8px;
    bottom: 8px;
  }
}

@media (max-width: 420px) {
  .topbar h1 {
    font-size: 22px;
  }

  .session-bar {
    grid-template-columns: 1fr;
    row-gap: 4px;
    font-size: 12px;
  }

  .session-bar .btn {
    width: 100%;
    justify-self: stretch;
  }

  .loading-panel {
    min-width: 0;
    width: calc(100vw - 28px);
  }
}
