/* 自绘下拉（配合 static/js/ts-select.js）
 *
 * 原生 <select> 还在 DOM 里（值 / change / 表单提交 / v-model 全部照旧），
 * 只是视觉上藏起来，换成这里的「按钮 + 面板」。
 * 面板用 position:fixed 挂在 body（或所在 modal）上，不会被卡片/表格的 overflow 裁掉。
 */

.ts-sel { position: relative; }

/* 藏原生 select，但保留它的盒子：外壳的宽高完全由它决定，布局不会动 */
.ts-sel > select.ts-sel__nat {
  visibility: hidden !important;
  pointer-events: none !important;
}

.ts-sel__btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 30px 0 10px;
  border: 1px solid var(--t-line-strong, #d9dfe7);
  border-radius: 8px;
  background: var(--t-surface, #fff);
  color: var(--t-text, #111827);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.ts-sel__btn:hover { border-color: var(--t-muted-2, #9ca3af); }
.ts-sel__btn:focus-visible {
  border-color: var(--t-brand, #2f5fe0);
  box-shadow: 0 0 0 3px rgba(47, 95, 224, .13);
}
.ts-sel.is-open .ts-sel__btn {
  border-color: var(--t-brand, #2f5fe0);
  box-shadow: 0 0 0 3px rgba(47, 95, 224, .13);
}
.ts-sel__btn:disabled {
  background: var(--t-surface-2, #f4f4f5);
  border-color: var(--t-line, #e5e5e5);
  color: var(--t-muted, #71717a);
  cursor: not-allowed;
}

.ts-sel__txt {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ts-sel__btn.is-ph .ts-sel__txt { color: var(--t-muted-2, #a1a1aa); }

.ts-sel__pr {
  flex: none;
  margin-left: auto;
  color: var(--t-muted, #71717a);
  font-variant-numeric: tabular-nums;
}
.ts-sel__pr[hidden] { display: none; }

.ts-sel__chev {
  position: absolute;
  right: 9px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  fill: none;
  stroke: var(--t-muted, #71717a);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  transition: transform .18s ease;
}
.ts-sel.is-open .ts-sel__chev { transform: rotate(180deg); }

/* ---------------- 面板 ---------------- */

.ts-sel-panel {
  position: fixed;
  z-index: 2065;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid var(--t-line, #e5e5e5);
  border-radius: 12px;
  background: var(--t-surface, #fff);
  box-shadow: 0 18px 48px -14px rgba(16, 24, 40, .28), 0 2px 6px rgba(16, 24, 40, .06);
  color: var(--t-text, #111827);
  font-family: var(--t-font, inherit);
  font-size: 13px;
  animation: tsSelIn .13s cubic-bezier(.2, .8, .2, 1);
}

@keyframes tsSelIn {
  from { opacity: 0; transform: translateY(-4px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.ts-sel-panel__q {
  flex: none;
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 5px;
  padding: 8px 9px;
  border: 0;
  border-bottom: 1px solid var(--t-line, #e5e5e5);
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--t-text, #111827);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.ts-sel-panel__q::placeholder { color: var(--t-muted-2, #a1a1aa); }
.ts-sel-panel__q::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.ts-sel-panel__q[hidden] { display: none; }

.ts-sel-panel__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
  margin: 0;
}

.ts-sel-panel__list::-webkit-scrollbar { width: 8px; }
.ts-sel-panel__list::-webkit-scrollbar-thumb {
  background: var(--t-line-strong, #d9dfe7);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 8px;
}
.ts-sel-panel__list::-webkit-scrollbar-thumb:hover { background-clip: padding-box; background-color: var(--t-muted-2, #a1a1aa); }
.ts-sel-panel__list::-webkit-scrollbar-track { background: transparent; }

.ts-sel-opt {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--t-text, #111827);
  line-height: 1.45;
  cursor: pointer;
  user-select: none;
  word-break: break-word;
}
.ts-sel-opt__name { flex: 1 1 auto; min-width: 0; }
.ts-sel-opt__price {
  flex: none;
  margin-left: auto;
  color: var(--t-muted, #71717a);
  font-variant-numeric: tabular-nums;
}
.ts-sel-opt.is-act { background: var(--t-surface-2, #f4f4f5); }
.ts-sel-opt.is-sel { color: var(--t-brand, #2f5fe0); font-weight: 600; background: var(--t-brand-soft, #eef2fe); }
.ts-sel-opt.is-sel .ts-sel-opt__price { color: var(--t-brand, #2f5fe0); font-weight: 500; }
.ts-sel-opt.is-sel.is-act { background: var(--t-brand-soft, #eef2fe); filter: brightness(.985); }
.ts-sel-opt.is-dis {
  color: var(--t-muted-2, #a1a1aa);
  cursor: default;
  background: transparent;
}

.ts-sel-empty {
  padding: 20px 10px;
  text-align: center;
  color: var(--t-muted-2, #a1a1aa);
}

.ts-sel-mask {
  position: fixed;
  z-index: 2060;
  inset: 0;
  background: rgba(15, 23, 42, .34);
  animation: tsSelFade .15s ease;
}
@keyframes tsSelFade { from { opacity: 0; } to { opacity: 1; } }

/* 窄屏：底部抽屉，跟手机原生选择器一个手感。
   高度上限由 ts-select.js 按视口算（约半屏、最多 420px），这里的 56vh 只是兜底，
   原则是「别把整屏吞掉」，上面要留得下页面和刚点的那个下拉。 */
.ts-sel-panel.is-sheet {
  left: 8px;
  right: 8px;
  bottom: 8px;
  top: auto;
  width: auto;
  max-height: 56vh;
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px;
  animation: tsSelUp .2s cubic-bezier(.2, .8, .2, 1);
}
.ts-sel-panel.is-sheet::before {
  content: "";
  display: block;
  width: 34px;
  height: 4px;
  margin: -1px auto 6px;
  border-radius: 4px;
  background: var(--t-line-strong, #d9dfe7);
}
.ts-sel-panel.is-sheet .ts-sel-opt { padding: 11px 12px; font-size: 14px; }
.ts-sel-panel.is-sheet .ts-sel-opt__price { font-size: 14px; }
.ts-sel-panel.is-sheet .ts-sel-panel__q { font-size: 16px; padding: 10px 12px; }

@keyframes tsSelUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ts-sel-panel, .ts-sel-panel.is-sheet, .ts-sel-mask { animation: none !important; }
  .ts-sel__chev { transition: none !important; }
}
