/* ==========================================================================
   Components — 按钮 / 卡片 / 表单 / 徽标 / 标签 / 表格 / 选项卡 / 提示 / 模态
   ========================================================================== */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: var(--fs-14);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition:
    transform var(--dur-1) var(--ease-spring),
    background-color var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
.btn:active { transform: scale(0.975); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn .icon { width: 18px; height: 18px; }

.btn-primary {
  background: var(--ink);
  color: var(--ink-invert);
  box-shadow: var(--sh-1);
}
.btn-primary:hover:not(:disabled) {
  background: #000;
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--sh-accent);
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 8px 26px rgba(14, 116, 144, 0.3);
}

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--ink-3);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-soft);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn-lg { height: 54px; padding: 0 28px; font-size: var(--fs-16); border-radius: var(--r-md); }
.btn-sm { height: 34px; padding: 0 12px; font-size: var(--fs-13); border-radius: var(--r-xs); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r-sm); }
.btn-icon.btn-sm { width: 32px; height: 32px; }

/* 载入态按钮 */
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: boot-spin 700ms linear infinite;
}
.btn-outline.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after {
  border-color: var(--line-strong); border-top-color: var(--accent);
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--sh-1);
  transition: box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.card-hover:hover { box-shadow: var(--sh-2); border-color: var(--line-strong); }
.card-lift:hover { transform: translateY(-3px); box-shadow: var(--sh-3); }
.card-title {
  font-size: var(--fs-18);
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.card-title .icon { width: 20px; height: 20px; color: var(--accent); }
.card-sub { font-size: var(--fs-13); color: var(--ink-3); margin-top: -14px; margin-bottom: var(--sp-5); }
.card-pad-0 { padding: 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: var(--sp-5); }
.field-label {
  display: block;
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--sp-2);
}
.field-hint { font-size: var(--fs-13); color: var(--ink-3); margin-top: var(--sp-2); }
.field-error { font-size: var(--fs-13); color: var(--danger); margin-top: var(--sp-2); display: flex; align-items: center; gap: 6px; }

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: var(--fs-15);
  color: var(--ink);
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2);
}
.textarea { min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c828c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 42px; }
.input-with-icon .leading-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-3); pointer-events: none;
}

/* 开关 */
.switch { position: relative; display: inline-flex; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--line-strong);
  border-radius: var(--r-pill);
  transition: background-color var(--dur-2) var(--ease-out);
}
.switch-track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  box-shadow: var(--sh-1);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 选择块（类型/方向/长度） ---------- */
.chip-grid { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--dur-2) var(--ease-out);
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-softer); }
.chip.selected {
  background: var(--ink); border-color: var(--ink); color: #fff;
  box-shadow: var(--sh-1);
}
.chip.selected:hover { background: #000; color: #fff; }
.chip .icon { width: 16px; height: 16px; }

/* 分段控件 */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  gap: 2px;
}
.segmented button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink-3);
  transition: all var(--dur-2) var(--ease-out);
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* 方向卡片 */
.dir-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.dir-card {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all var(--dur-2) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.dir-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--sh-2); }
.dir-card .dir-ico { width: 22px; height: 22px; margin-bottom: var(--sp-2); }
.dir-card .dir-name { font-size: var(--fs-15); font-weight: 600; color: var(--ink); }
.dir-card .dir-desc { font-size: var(--fs-12); color: var(--ink-3); margin-top: 2px; }
.dir-card.selected { border-color: var(--accent); background: var(--accent-softer); }
.dir-card.selected.positive .dir-ico { color: var(--dir-positive); }
.dir-card.selected.negative .dir-ico { color: var(--dir-negative); }
.dir-card.selected.neutral .dir-ico { color: var(--accent); }
.dir-card .dir-ico { color: var(--ink-3); transition: color var(--dur-2); }

/* 数量步进器 */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.stepper button { width: 42px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--ink-2); transition: background-color var(--dur-1); }
.stepper button:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper .stepper-val { min-width: 52px; text-align: center; font-weight: 700; font-size: var(--fs-16); font-variant-numeric: tabular-nums; border-left: 1px solid var(--line); border-right: 1px solid var(--line); height: 44px; line-height: 44px; }

/* ---------- 徽标 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 1.6;
  background: var(--surface-3);
  color: var(--ink-2);
  border: 1px solid transparent;
}
.badge .icon { width: 13px; height: 13px; }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-outline { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.badge-vip { background: linear-gradient(120deg, #b8860b22, #b8860b11); color: #8a6508; border-color: #b8860b33; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-danger { background: var(--danger); }
.dot-muted { background: var(--ink-4); }

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: var(--r-xs);
  font-size: var(--fs-12); font-weight: 500;
  background: var(--surface-3); color: var(--ink-2);
}

/* ---------- 统计卡 ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  transition: all var(--dur-2) var(--ease-out);
}
.stat:hover { border-color: var(--line-strong); box-shadow: var(--sh-2); transform: translateY(-2px); }
.stat-label { font-size: var(--fs-13); color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat-label .icon { width: 15px; height: 15px; }
.stat-value { font-size: var(--fs-34); font-weight: 800; letter-spacing: -0.03em; color: var(--ink); line-height: 1.1; margin-top: var(--sp-2); font-variant-numeric: tabular-nums; }
.stat-value.accent { color: var(--accent); }
.stat-foot { font-size: var(--fs-12); color: var(--ink-3); margin-top: var(--sp-1); }

/* ---------- 进度条 ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width var(--dur-4) var(--ease-out); }
.progress-bar.warn { background: var(--warn); }
.progress-bar.danger { background: var(--danger); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
table.data th, table.data td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); white-space: nowrap; }
table.data tbody tr { transition: background-color var(--dur-1); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td { color: var(--ink-2); }

/* ---------- 选项卡 ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-6); overflow-x: auto; }
.tab {
  padding: 11px 16px;
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--dur-2), border-color var(--dur-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .icon { width: 17px; height: 17px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: var(--sp-16) var(--sp-6); color: var(--ink-3); }
.empty-ico { width: 52px; height: 52px; margin: 0 auto var(--sp-4); color: var(--ink-4); opacity: 0.7; }
.empty-title { font-size: var(--fs-16); font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.empty-desc { font-size: var(--fs-14); max-width: 340px; margin: 0 auto; }

/* ---------- Toast ---------- */
.toast-host { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  font-weight: 500;
  box-shadow: var(--sh-3);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease-spring) both;
}
.toast.out { animation: toast-out var(--dur-2) var(--ease-out) both; }
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast-ok .icon { color: #6ee7a8; }
.toast-err .icon { color: #fca5a5; }
.toast-info .icon { color: #7dd3fc; }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(20, 20, 25, 0.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  animation: mask-in var(--dur-2) var(--ease-out) both;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  width: 100%; max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  animation: modal-in var(--dur-3) var(--ease-spring) both;
}
.modal-head { padding: var(--sp-6) var(--sp-6) var(--sp-3); }
.modal-title { font-size: var(--fs-18); font-weight: 700; }
.modal-body { padding: var(--sp-3) var(--sp-6); color: var(--ink-2); font-size: var(--fs-14); }
.modal-foot { padding: var(--sp-5) var(--sp-6) var(--sp-6); display: flex; gap: var(--sp-3); justify-content: flex-end; }

/* ---------- 分隔与列表 ---------- */
.divider { height: 1px; background: var(--line); border: none; margin: var(--sp-5) 0; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }

/* ---------- 复制框 ---------- */
.copybox {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}
.copybox code { font-family: var(--font-mono); font-size: var(--fs-18); font-weight: 700; letter-spacing: 0.06em; color: var(--ink); }

/* 图标默认尺寸 */
.icon { width: 20px; height: 20px; stroke-width: 1.8; }
