/* 搜索站位分析 */
#bdSearchPosition {
  width: 100%;
  min-height: calc(100vh - var(--bd-topbar-h, 56px));
}

html.bd-view-search-position .bd-main,
.bd-main:has(> #bdSearchPosition:not([hidden])) {
  padding: 16px 20px 32px;
  overflow: auto;
  max-height: calc(100vh - var(--bd-topbar-h, 56px));
}

.sp-root {
  max-width: 960px;
  margin: 0 auto;
  font-size: 13px;
  color: #334155;
}

.sp-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e8ecf3;
  margin-bottom: 18px;
}

.sp-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 18px;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.sp-tab.is-active {
  color: var(--bd-primary, #3c66ff);
  font-weight: 600;
  border-bottom-color: var(--bd-primary, #3c66ff);
}

.sp-card {
  background: #fff;
  border: 1px solid #e8ecf3;
  border-radius: 12px;
  padding: 24px 28px 28px;
}

.sp-disclaimer {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #ffedd5;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.5;
}

.sp-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

@media (max-width: 768px) {
  .sp-modes {
    grid-template-columns: 1fr;
  }
}

.sp-mode {
  appearance: none;
  text-align: left;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 14px 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sp-mode:hover {
  border-color: #a5b4fc;
}

.sp-mode.is-active {
  border-color: var(--bd-primary, #3c66ff);
  box-shadow: 0 0 0 3px rgba(60, 102, 255, 0.12);
  background: #f8faff;
}

.sp-mode-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.sp-mode-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.45;
}

.sp-sample {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 20px;
  background: #f5f8ff;
  border: 1px solid #e0e7ff;
  border-radius: 8px;
  font-size: 12px;
  color: #475569;
}

.sp-sample a {
  color: var(--bd-primary, #3c66ff);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.sp-section {
  margin-bottom: 20px;
}

.sp-section-title {
  margin: 0 0 10px;
  padding-left: 10px;
  border-left: 3px solid var(--bd-primary, #3c66ff);
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

.sp-section-hint {
  margin: -4px 0 10px;
  font-size: 12px;
  color: #94a3b8;
}

.sp-input,
.sp-textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: #0f172a;
  background: #fff;
  box-sizing: border-box;
}

.sp-input {
  height: 38px;
}

.sp-textarea {
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.sp-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sp-row .sp-input {
  flex: 1;
  min-width: 0;
}

.sp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sp-chip {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  height: 28px;
}

.sp-chip.is-active {
  border-color: var(--bd-accent-border, #a5b4fc);
  color: var(--bd-accent-text, #2952e6);
  background: var(--bd-primary-light);
  font-weight: 600;
}

.sp-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 10px;
}

.sp-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
}

.sp-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
}

.sp-kw-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.sp-kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  font-size: 12px;
  color: #334155;
}

.sp-kw-tag button {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.sp-predict {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sp-predict button {
  appearance: none;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
}

.sp-predict button:hover {
  border-color: var(--bd-primary, #3c66ff);
  color: var(--bd-primary, #3c66ff);
}

.sp-brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-top: 10px;
}

.sp-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.sp-brand-logo-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.sp-brand-name {
  font-weight: 600;
  color: #0f172a;
}

.sp-brand-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.sp-brand-clear {
  margin-left: auto;
  appearance: none;
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 12px;
}

.sp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.sp-cost {
  font-size: 12px;
  color: #64748b;
}

.sp-cost strong {
  color: var(--bd-down, #f53f3f);
  font-weight: 600;
}

.sp-btn {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  border-radius: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
}

.sp-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sp-btn-primary {
  background: var(--bd-primary, #3c66ff);
  border-color: var(--bd-primary, #3c66ff);
  color: #fff;
  font-weight: 600;
}

.sp-error {
  margin: 0 0 12px;
  color: var(--bd-down, #f53f3f);
  font-size: 12px;
}

.sp-empty {
  padding: 48px 16px;
  text-align: center;
  color: #94a3b8;
}

/* modal */
.sp-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.sp-modal-panel {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  background: #fff;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sp-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.sp-modal-head h3 {
  margin: 0;
  font-size: 15px;
}

.sp-modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #94a3b8;
}

.sp-modal-search {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
}

.sp-modal-list {
  overflow: auto;
  padding: 0 16px 16px;
  flex: 1;
}

.sp-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f8fafc;
}

.sp-modal-item-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.sp-modal-empty {
  padding: 28px 8px;
  text-align: center;
  color: #94a3b8;
}

/* result */
.sp-result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sp-result-toolbar h2 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}

.sp-result-actions {
  display: flex;
  gap: 8px;
}

.sp-result {
  background: #fff;
  border: 1px solid #e8ecf3;
  border-radius: 12px;
  padding: 24px 28px;
}

.sp-cover h1 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #0f172a;
}

.sp-cover-meta {
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 18px;
}

.sp-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

@media (max-width: 768px) {
  .sp-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.sp-kpi {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}

.sp-kpi-val {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

.sp-kpi-lbl {
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
}

.sp-block {
  margin-bottom: 20px;
}

.sp-block h3 {
  margin: 0 0 10px;
  padding-left: 8px;
  border-left: 3px solid var(--bd-primary, #3c66ff);
  font-size: 14px;
  font-weight: 600;
}

.sp-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sp-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr 48px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.sp-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
}

.sp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3c66ff, #60a5fa);
  border-radius: 999px;
}

.sp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.sp-table th,
.sp-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: middle;
}

.sp-table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 500;
}

.sp-note-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 160px;
}

.sp-note-cover {
  width: 36px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.sp-hit {
  background: #fff7ed !important;
}

.sp-status {
  padding: 24px 8px;
  text-align: center;
  color: #64748b;
}

@media print {
  .bd-sidebar,
  .bd-topbar,
  .sp-tabs,
  .sp-result-toolbar,
  .sp-modal {
    display: none !important;
  }

  .sp-result {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  #bdSearchPosition {
    min-height: auto;
  }
}
