/* ============================================================
   AI 股票引擎 · 通用组件
   ============================================================ */

/* ---------------- 卡片 ---------------- */
.card {
  background: linear-gradient(180deg, var(--surface-1), var(--bg-elev, var(--surface-1)));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1), var(--inset-hi);
  position: relative;
}
.card--pad { padding: 20px; }
.card--flat { box-shadow: none; }

.card-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-hd__title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.card-hd__title h3 { font-size: 15px; font-weight: 600; letter-spacing: 0; }
.card-hd__title .dot {
  width: 6px; height: 6px; border-radius: 99px; background: var(--accent);
  flex: none;
}
.card-bd { padding: 20px; }
.card-ft {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* 卡片悬停微交互 */
.card--hover {
  transition: transform var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out);
}
.card--hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--sh-2), var(--inset-hi);
}
.card--hover:active { transform: translateY(0) scale(.995); }

/* 光晕描边（重点卡片） */
.card--glow::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, var(--accent-line), transparent 42%, transparent 60%, var(--gold-soft));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  color: var(--t1);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  transition: background var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast) var(--ease-out), color var(--t-fast);
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-hi); border-color: var(--border-3); }
.btn:active { transform: scale(.975); }
.btn[disabled], .btn.is-disabled {
  opacity: .45; pointer-events: none;
}

.btn--primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 4px 16px rgba(76,125,255,.28), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn--primary:hover {
  background: linear-gradient(180deg, #7C9EFF, #5885FF);
  border-color: transparent;
  box-shadow: 0 6px 22px rgba(76,125,255,.4), inset 0 1px 0 rgba(255,255,255,.22);
}

.btn--ghost { background: transparent; border-color: var(--border); color: var(--t2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--t1); border-color: var(--border-2); }

.btn--danger { background: var(--up-soft); border-color: var(--up-line); color: var(--up); }
.btn--danger:hover { background: rgba(246,70,93,.2); }

.btn--gold {
  background: linear-gradient(180deg, #E7B96B, var(--gold));
  border-color: transparent; color: #241703; font-weight: 600;
}
.btn--gold:hover { background: linear-gradient(180deg, #EEC47C, #E0B169); }

.btn--sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn--lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { width: 34px; height: 34px; padding: 0; }

.btn__spin {
  width: 14px; height: 14px; border-radius: 99px;
  border: 2px solid rgba(255,255,255,.28); border-top-color: #fff;
  animation: spin .7s linear infinite;
}

/* ---------------- 徽章 / 标签 ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px;
  border-radius: var(--r-xs);
  font-size: 11.5px; font-weight: 500; line-height: 1;
  background: var(--surface-3); color: var(--t2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge--up     { background: var(--up-soft);     color: var(--up);     border-color: var(--up-line); }
.badge--down   { background: var(--down-soft);   color: var(--down);   border-color: var(--down-line); }
.badge--warn   { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(245,165,36,.3); }
.badge--info   { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge--gold   { background: var(--gold-soft);   color: var(--gold);   border-color: rgba(217,168,92,.3); }
.badge--purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(139,123,247,.3); }
.badge--flat   { background: var(--surface-2);   color: var(--flat); }
.badge--ok      { background: var(--up-soft);     color: var(--up);     border-color: var(--up-line); }
.badge--danger  { background: var(--down-soft);   color: var(--down);   border-color: var(--down-line); }
.badge--t4      { background: var(--surface-2);   color: var(--t4);     border-color: var(--border); }
.badge--dot::before {
  content: ""; width: 5px; height: 5px; border-radius: 99px;
  background: currentColor; flex: none;
}

/* 市场标签 */
.mk {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 20px; padding: 0 6px;
  border-radius: 5px; font-size: 11px; font-weight: 700;
  font-family: var(--font-num); letter-spacing: .02em;
}
.mk--A  { background: rgba(246,70,93,.15);   color: #FF6B7A; }
.mk--HK { background: rgba(76,125,255,.15);  color: #6B93FF; }
.mk--US { background: rgba(139,123,247,.15); color: #9E91FA; }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-size: 12.5px; font-weight: 500; color: var(--t2);
  display: flex; align-items: center; gap: 5px;
}
.field__label .req { color: var(--up); }
.field__hint  { font-size: 11.5px; color: var(--t3); }
.field__error { font-size: 11.5px; color: var(--up); display: none; }
.field.is-invalid .field__error { display: block; }
.field.is-invalid .input,
.field.is-invalid .select { border-color: var(--up); }

.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--t1); font-size: 13.5px;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--t4); }
.input:hover, .select:hover { border-color: var(--border-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(76,125,255,.14);
}
.input--num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.input--lg  { height: 46px; font-size: 15px; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%235E6A80' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.select option { background: var(--surface-2); color: var(--t1); }

/* 输入框前缀/后缀 */
.input-group { display: flex; align-items: stretch; }
.input-group__addon {
  display: flex; align-items: center; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  color: var(--t3); font-size: 12.5px; white-space: nowrap;
}
.input-group__addon:first-child { border-right: none; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group__addon:last-child  { border-left: none;  border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group .input:not(:first-child) { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group .input:not(:last-child)  { border-radius: var(--r-sm) 0 0 var(--r-sm); }

/* 分段控件 */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.seg__item {
  height: 30px; padding: 0 14px; border-radius: 9px;
  font-size: 12.5px; font-weight: 500; color: var(--t2);
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.seg__item:hover { color: var(--t1); }
.seg__item.is-active {
  background: var(--surface-3); color: var(--t1);
  box-shadow: var(--sh-1), inset 0 1px 0 rgba(255,255,255,.05);
}
.seg--sm .seg__item { height: 26px; padding: 0 11px; font-size: 12px; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch__box {
  width: 38px; height: 21px; border-radius: 99px; flex: none;
  background: var(--surface-3); border: 1px solid var(--border-2);
  position: relative; transition: background var(--t-base), border-color var(--t-base);
}
.switch__box::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 99px;
  background: var(--t3);
  transition: transform var(--t-base) var(--ease-spring), background var(--t-base);
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch input:checked + .switch__box { background: var(--accent-soft); border-color: var(--accent-line); }
.switch input:checked + .switch__box::after { transform: translateX(17px); background: var(--accent); }
.switch__text { font-size: 13px; color: var(--t2); }
.switch input:checked ~ .switch__text { color: var(--t1); }

/* 单选卡片 */
.radio-card {
  display: flex; gap: 12px; padding: 14px;
  border: 1px solid var(--border-2); border-radius: var(--r-md);
  background: var(--surface-1); cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.radio-card:hover { border-color: var(--border-3); }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card__mark {
  width: 17px; height: 17px; border-radius: 99px; flex: none; margin-top: 2px;
  border: 1.5px solid var(--border-3); position: relative;
  transition: border-color var(--t-fast);
}
.radio-card__mark::after {
  content: ""; position: absolute; inset: 3px; border-radius: 99px;
  background: var(--accent); transform: scale(0);
  transition: transform var(--t-base) var(--ease-spring);
}
.radio-card input:checked ~ .radio-card__mark { border-color: var(--accent); }
.radio-card input:checked ~ .radio-card__mark::after { transform: scale(1); }
.radio-card:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.tbl { font-size: 13px; }
.tbl th {
  text-align: right; font-weight: 500; font-size: 11.5px; color: var(--t3);
  padding: 10px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky; top: 0; z-index: 2;
}
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td {
  text-align: right; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: background var(--t-base);
}
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl--zebra tbody tr:nth-child(even) { background: rgba(255,255,255,.014); }

/* 代码 + 名称单元 */
.stock-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stock-cell__ico {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-family: var(--font-num);
  background: var(--surface-3); color: var(--t2);
}
.stock-cell__name { font-weight: 500; color: var(--t1); }
.stock-cell__code { font-size: 11.5px; color: var(--t3); font-family: var(--font-num); }

/* 价格跳动 */
.tick-up   { animation: tickerUp   .62s var(--ease-out); }
.tick-down { animation: tickerDown .62s var(--ease-out); }

/* ---------------- 进度 / 计量 ---------------- */
.bar {
  height: 5px; border-radius: 99px; background: var(--surface-3);
  overflow: hidden;
}
.bar__fill {
  height: 100%; border-radius: 99px; background: var(--accent);
  transform-origin: left center;
  transition: width var(--t-slow) var(--ease-out), background var(--t-base);
}
.bar--sm { height: 3px; }

.meter { display: flex; gap: 3px; }
.meter__seg { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }

/* ---------------- 状态占位 ---------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 52px 24px; text-align: center;
}
.empty__ico {
  width: 52px; height: 52px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--t3); margin-bottom: 4px;
}
.empty__title { font-size: 14.5px; font-weight: 600; color: var(--t1); }
.empty__desc  { font-size: 12.5px; color: var(--t3); max-width: 340px; line-height: 1.7; }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
  background-size: 400px 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-xs);
  height: 14px;
}

/* ---------------- Toast ---------------- */
.toast-host {
  position: fixed; z-index: 9000; top: 18px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px; border-radius: var(--r-md);
  background: rgba(20,27,42,.94);
  border: 1px solid var(--border-2);
  box-shadow: var(--sh-3);
  backdrop-filter: blur(14px);
  font-size: 13px; color: var(--t1);
  animation: scaleIn .28s var(--ease-out);
  max-width: 90vw;
}
.toast.is-out { animation: fadeIn .2s reverse forwards; }
.toast__ico { flex: none; display: flex; }
.toast--ok    { border-color: var(--down-line); }
.toast--ok    .toast__ico { color: var(--down); }
.toast--err   { border-color: var(--up-line); }
.toast--err   .toast__ico { color: var(--up); }
.toast--warn  { border-color: rgba(245,165,36,.32); }
.toast--warn  .toast__ico { color: var(--warn); }
.toast--info  .toast__ico { color: var(--accent); }

/* ---------------- 弹窗 ---------------- */
.modal-host {
  position: fixed; inset: 0; z-index: 8000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4,6,10,.68);
  backdrop-filter: blur(6px);
  animation: fadeIn .18s var(--ease-out);
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 520px;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: scaleIn .26s var(--ease-out);
  max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  margin: auto;
}
.modal--wide { max-width: 760px; }
.modal--sm   { max-width: 400px; }
.modal__hd {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 14px;
}
.modal__title { font-size: 17px; font-weight: 600; }
.modal__sub   { font-size: 12.5px; color: var(--t3); margin-top: 3px; }
.modal__close {
  width: 30px; height: 30px; border-radius: var(--r-xs); flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); transition: background var(--t-fast), color var(--t-fast);
}
.modal__close:hover { background: var(--surface-3); color: var(--t1); }
.modal__bd { padding: 4px 22px 20px; overflow-y: auto; flex: 1; }
.modal__ft {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------------- 提示气泡 ---------------- */
.tip {
  display: flex; gap: 10px; padding: 11px 13px;
  border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.65;
  border: 1px solid var(--border);
}
.tip--info  { background: var(--accent-soft); border-color: var(--accent-line); color: #B8C9FF; }
.tip--warn  { background: var(--warn-soft);   border-color: rgba(245,165,36,.3); color: #F5C97A; }
.tip--danger{ background: var(--up-soft);     border-color: var(--up-line);     color: #FF8A97; }
.tip--neutral { background: var(--surface-2); color: var(--t2); }
.tip__ico { flex: none; margin-top: 2px; }
.tip strong { color: #fff; font-weight: 600; }

/* 免责声明条 */
.disclaimer {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 13px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.022);
  border: 1px dashed var(--border-2);
  font-size: 11.5px; line-height: 1.7; color: var(--t3);
}
.disclaimer svg { flex: none; margin-top: 2px; }

/* ---------------- 实时脉冲点 ---------------- */
.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--t2);
}
.live-dot__dot {
  width: 6px; height: 6px; border-radius: 99px; background: var(--down);
  animation: pulseRing 2s infinite;
}
.live-dot.is-paused .live-dot__dot { background: var(--t3); animation: none; }

/* ---------------- 图标 ---------------- */
.ico { width: 16px; height: 16px; flex: none; stroke-width: 1.7; }
.ico--18 { width: 18px; height: 18px; }
.ico--20 { width: 20px; height: 20px; }
.ico--24 { width: 24px; height: 24px; }

/* ---------------- 网格 ---------------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0,1fr); }
}
