/* ============================================================
   通用组件：按钮、卡片、表格、标签、表单、页签、弹窗、提示
   ============================================================ */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-100);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
}

.btn-orange {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.btn-orange:hover {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
  color: #fff;
}

.btn-plain {
  background: #fff;
  border-color: var(--line);
  color: var(--text-2);
}

.btn-plain:hover {
  border-color: var(--brand-500);
  color: var(--brand-600);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand-600);
  padding: 0 8px;
  height: 28px;
}

.btn-ghost:hover {
  background: var(--brand-50);
}

.btn-danger-ghost {
  color: var(--red);
  background: transparent;
  border-color: transparent;
}

.btn-danger-ghost:hover {
  background: var(--red-50);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand-600);
  font-size: 13px;
}

.link-btn:hover {
  color: var(--brand-500);
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--red);
}

.link-btn:disabled {
  color: var(--text-3);
  cursor: not-allowed;
}

.link-btn:disabled:hover {
  color: var(--text-3);
  text-decoration: none;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-2);
}

.card-head h3 {
  font-size: 15px;
  color: var(--brand-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-head h3::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: var(--brand-600);
}

.card-head .head-extra {
  font-size: 12px;
  color: var(--text-3);
}

.card-body {
  padding: 18px 20px;
}

.section {
  margin-bottom: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-900);
  margin-bottom: 10px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: var(--brand-600);
}

/* ---------- 表格 ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  font-size: 13px;
  min-width: 860px;
}

.table th,
.table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}

.table th {
  background: #f4f7fb;
  color: var(--text-2);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.table tbody tr {
  transition: background 0.12s ease;
}

.table tbody tr:hover {
  background: var(--brand-50);
}

.table tbody tr.is-selected {
  background: #e8f2ff;
}

.table tbody tr.clickable {
  cursor: pointer;
}

.table .col-actions {
  white-space: nowrap;
}

.table .cell-strong {
  color: var(--text);
  font-weight: 700;
}

.table .cell-name {
  color: var(--brand-700);
  font-weight: 700;
}

.table .num {
  font-variant-numeric: tabular-nums;
}

.table th.center,
.table td.center {
  text-align: center;
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--line-2);
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination button {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text-2);
  font-size: 12px;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--brand-500);
  color: var(--brand-600);
}

.pagination button.active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag-blue {
  color: var(--brand-700);
  background: var(--brand-50);
  border-color: var(--brand-100);
}

.tag-green {
  color: var(--green);
  background: var(--green-50);
  border-color: #c9ecdb;
}

.tag-orange {
  color: var(--orange-dark);
  background: var(--orange-50);
  border-color: #f6ddc7;
}

.tag-red {
  color: var(--red);
  background: var(--red-50);
  border-color: #f7d5d5;
}

.tag-gray {
  color: var(--text-2);
  background: var(--surface-2);
  border-color: var(--line);
}

.tag-purple {
  color: var(--purple);
  background: var(--purple-50);
  border-color: #ded7fb;
}

.tag-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- 表单 ---------- */
.form-control {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control::placeholder {
  color: #aab5c5;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(43, 124, 229, 0.12);
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  height: auto;
  min-height: 86px;
  padding: 8px 10px;
  resize: vertical;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label {
  font-size: 12px;
  color: var(--text-2);
}

.field > label .req {
  color: var(--red);
}

.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.checkbox input,
.radio input {
  width: 14px;
  height: 14px;
  accent-color: var(--brand-600);
  cursor: pointer;
}

/* ---------- 页签 ---------- */
.sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
  overflow-x: auto;
}

.sub-tab {
  position: relative;
  padding: 14px 20px;
  color: var(--text-2);
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.sub-tab:hover {
  color: var(--brand-600);
}

.sub-tab.active {
  color: var(--brand-700);
  font-weight: 700;
  border-bottom-color: var(--brand-600);
}

.sub-tab .badge {
  display: inline-block;
  margin-left: 6px;
  min-width: 18px;
  padding: 0 5px;
  height: 17px;
  line-height: 17px;
  border-radius: 9px;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

/* ---------- 提示条 ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #f3e2cd;
  background: #fffaf2;
  border-radius: var(--radius);
  font-size: 12px;
  color: #8a6331;
  line-height: 1.8;
}

.notice.info {
  border-color: var(--brand-100);
  background: var(--brand-50);
  color: var(--brand-700);
}

.notice.warn {
  border-color: #f6ddc7;
  background: var(--orange-50);
  color: var(--orange-dark);
}

.notice.error {
  border-color: #f4cccc;
  background: var(--red-50);
  color: var(--red);
}

.notice.error .notice-icon {
  background: var(--red);
}

.notice .notice-icon {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}

.notice ul {
  list-style: disc;
  padding-left: 16px;
}

/* ---------- 提示浮层 ---------- */
.toast-root {
  position: fixed;
  top: 132px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  animation: toast-in 0.22s ease;
}

.toast::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-600);
}

.toast.success::before {
  background: var(--green);
}

.toast.warn::before {
  background: var(--orange);
}

.toast.error::before {
  background: var(--red);
}

.toast.hide {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 24px;
  background: rgba(11, 36, 71, 0.45);
  animation: fade-in 0.18s ease;
  overflow-y: auto;
}

.modal {
  width: 560px;
  max-width: 100%;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.22s ease;
}

.modal.modal-sm {
  width: 420px;
}

.modal.modal-lg {
  width: 780px;
}

.modal.modal-xl {
  width: 1040px;
  max-width: 96vw;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
}

.modal-head h3 {
  font-size: 16px;
  color: var(--brand-900);
}

.modal-close {
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-3);
  padding: 4px;
}

.modal-close:hover {
  color: var(--red);
}

.modal-body {
  padding: 18px 20px;
  max-height: 66vh;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.8;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--line-2);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.985);
  }
}

/* ---------- 进度条 ---------- */
.progress {
  height: 6px;
  border-radius: 6px;
  background: #e8edf6;
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
  transition: width 0.35s ease;
}

.progress.green > i {
  background: linear-gradient(90deg, #45c08d, var(--green));
}

.progress.orange > i {
  background: linear-gradient(90deg, #f0ab6a, var(--orange));
}

.progress-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-line .progress {
  flex: 1;
  min-width: 60px;
}

.progress-line span {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.empty .empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid;
  place-items: center;
  font-size: 22px;
  border: 1px dashed var(--brand-100);
}

/* ---------- 描述列表 ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.kv-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
  background: #fff;
}

.kv-item:nth-child(3n) {
  border-right: 0;
}

.kv-item dt {
  flex: none;
  width: 96px;
  color: var(--text-3);
}

.kv-item dd {
  flex: 1;
  color: var(--text);
  word-break: break-all;
}

@media (max-width: 1000px) {
  .kv-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kv-item:nth-child(2n) {
    border-right: 0;
  }
}

@media (max-width: 640px) {
  .kv-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- 表单栅格（弹窗内常用） ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-grid .full {
  grid-column: 1 / -1;
}

/* ---------- 规则条目 ---------- */
.rule-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.8;
}

.rule-list li {
  position: relative;
  padding-left: 14px;
}

.rule-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand-500);
}

.rule-list li b {
  color: var(--text);
}

@media (max-width: 1400px) {
  .sub-tabs {
    padding: 0 4px;
  }
  .sub-tab {
    padding: 14px 14px;
    font-size: 13px;
  }
}

