/* ============================================================
   components.css — 通用组件
   ============================================================ */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.btn:hover {
  border-color: var(--hover-line);
  background: var(--hover-bg);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}

.btn-danger {
  color: var(--red);
  border-color: var(--red-line);
}
.btn-danger:hover {
  background: var(--red-tint);
  border-color: var(--red);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--gray-tint);
  border-color: transparent;
  color: var(--text);
}

.btn-dark {
  background: #3D4E66;
  border-color: #3D4E66;
  color: #fff;
}
.btn-dark:hover {
  background: #33425A;
}

.btn-sm {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-lg {
  height: 42px;
  padding: 0 22px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.btn .svg {
  flex: none;
}

/* ---------- 状态徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.st-draft {
  color: var(--gray);
  background: var(--gray-tint);
  border-color: #DCE1E7;
}
.st-wait {
  color: var(--amber);
  background: var(--amber-tint);
  border-color: var(--amber-line);
}
.st-back {
  color: var(--red);
  background: var(--red-tint);
  border-color: var(--red-line);
}
.st-info {
  color: var(--blue);
  background: var(--blue-tint);
  border-color: var(--blue-line);
}
.st-out {
  color: var(--teal);
  background: var(--teal-tint);
  border-color: var(--teal-line);
}
.st-recv,
.st-green {
  color: var(--green);
  background: var(--green-tint);
  border-color: var(--green-line);
}
.st-cancel {
  color: var(--text-3);
  background: transparent;
  border-color: var(--line);
}
.st-orange {
  color: var(--orange);
  background: var(--orange-tint);
  border-color: var(--orange-line);
}

/* 紧急标（危险条纹） */
.urgent-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  background: var(--orange);
  border-radius: 3px;
}
.urgent-tag::before {
  content: "";
  width: 5px;
  height: 5px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}

/* 预警标记 */
.warn-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- 表格 ---------- */
.tbl-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: auto;
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #F4F7FA;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl th.sortable {
  cursor: pointer;
}
.tbl th.sortable:hover {
  color: var(--text);
}

.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tbl tbody tr {
  transition: background 0.12s;
}
.tbl tbody tr:hover {
  background: #F6F9FC;
}
.tbl tbody tr:last-child td {
  border-bottom: none;
}
.tbl tbody tr.clickable {
  cursor: pointer;
}

.tbl .cell-num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.tbl th.cell-num {
  text-align: right;
}

.tbl tfoot td {
  background: #F4F7FA;
  font-weight: 600;
  border-top: 1px solid var(--line);
  border-bottom: none;
  padding: 10px 14px;
}

/* 两行单元格：主信息 + 编码 */
.cell-main {
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.cell-sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.4;
  margin-top: 2px;
}

/* ---------- 表单 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.05em;
}
.field .req {
  color: var(--red);
  margin-left: 2px;
}

.input,
.select,
.textarea {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.textarea {
  height: auto;
  min-height: 72px;
  padding: 8px 12px;
  resize: vertical;
  line-height: 1.6;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--hover-line);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 92, 151, 0.12);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.input.err,
.select.err {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(214, 69, 61, 0.1);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235C6C7F' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.field-err {
  font-size: 12px;
  color: var(--red);
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.switch input {
  display: none;
}
.switch .track {
  width: 38px;
  height: 20px;
  border-radius: 11px;
  background: #C8D2DD;
  position: relative;
  transition: background 0.18s;
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s;
}
.switch input:checked + .track {
  background: var(--blue);
}
.switch input:checked + .track::after {
  transform: translateX(18px);
}
.switch .lab {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

/* 复选筛选 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-2);
}
.check input {
  display: none;
}
.check .box {
  width: 15px;
  height: 15px;
  border: 1.5px solid #B4C0CE;
  border-radius: 3px;
  position: relative;
  transition: all 0.12s;
  flex: none;
}
.check input:checked + .box {
  background: var(--blue);
  border-color: var(--blue);
}
.check input:checked + .box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 19, 32, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 20px 20px;
  overflow: auto;
  animation: fadein 0.16s ease;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: rise 0.2s ease;
  display: flex;
  flex-direction: column;
  max-height: 84vh;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.modal-head::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--blue);
}
.modal-head h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex: 1;
}
.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--r);
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
}
.modal-close:hover {
  background: var(--gray-tint);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: #F8FAFC;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---------- 抽屉（批次明细） ---------- */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 19, 32, 0.45);
  z-index: 90;
  animation: fadein 0.16s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 94vw);
  background: var(--card);
  box-shadow: var(--shadow-3);
  z-index: 91;
  display: flex;
  flex-direction: column;
  animation: slideL 0.22s ease;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: #F5F8FB;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.drawer-head h3 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  letter-spacing: 0.03em;
}
.drawer-head .sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}
.drawer-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 16px;
}
.drawer-close:hover {
  background: var(--gray-tint);
  color: var(--text);
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 20px 22px;
}

/* ---------- 提示条 ---------- */
.alert {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid;
}
.alert-warn {
  background: var(--amber-tint);
  border-color: var(--amber-line);
  color: var(--amber-deep);
}
.alert-info {
  background: var(--blue-tint);
  border-color: var(--blue-line);
  color: var(--blue-deep);
}
.alert-danger {
  background: var(--red-tint);
  border-color: var(--red-line);
  color: var(--red-text);
}
.alert .ic {
  flex: none;
  margin-top: 2px;
}
.alert ul {
  padding-left: 4px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ---------- 页签 ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  padding: 10px 18px 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: none;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}
.tab:hover {
  color: var(--text);
}
.tab.on {
  color: var(--text);
  font-weight: 700;
}
.tab.on::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
}
.tab .cnt {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 7px;
  height: 17px;
  line-height: 17px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  background: var(--gray-tint);
  color: var(--text-2);
}
.tab.on .cnt {
  background: var(--blue-tint);
  color: var(--blue-deep);
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px 0;
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
}
.pager .info {
  flex: 1;
  min-width: 140px;
}
.pager .info b {
  font-family: var(--mono);
  color: var(--text);
}
.pager-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}
.pager-btns button {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 13px;
  font-family: var(--mono);
}
.pager-btns button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}
.pager-btns button.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}
.pager-btns button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pager-size {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pager-size select {
  height: 30px;
  padding: 0 26px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 12.5px;
  color: var(--text-2);
  background-color: var(--card);
}

/* ---------- 空态 / 加载 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 20px;
  color: var(--text-3);
  font-size: 13px;
}
.empty .mark {
  width: 56px;
  height: 40px;
  border: 1.5px dashed #C4CFDB;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #B4C0CE;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 13px;
}
.loading .spin {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- KPI 指标卡 ---------- */
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--line-soft);
}
.kpi:hover {
  border-color: var(--hover-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow-1);
}
.kpi .k-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.1em;
}
.kpi .k-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 8px;
  color: var(--text);
}
.kpi .k-val .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: 4px;
  font-family: var(--sans);
}
.kpi .k-foot {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}
.kpi.k-orange::before {
  background: var(--orange);
}
.kpi.k-blue::before {
  background: var(--blue);
}
.kpi.k-red::before {
  background: var(--red);
}
.kpi.k-green::before {
  background: var(--green);
}
.kpi.k-teal::before {
  background: var(--teal);
}
.kpi.clickable {
  cursor: pointer;
}

/* ---------- 卡片区块 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex: 1;
}
.panel-head h3 .idx {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  margin-right: 8px;
}
.panel-head .more {
  font-size: 12.5px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.panel-head .more:hover {
  color: var(--blue);
}
.panel-body {
  padding: 16px 18px;
}
.panel-body.flush {
  padding: 0;
}

/* ---------- 审批时间线 ---------- */
.timeline {
  display: flex;
  flex-direction: column;
}
.tl-item {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 26px;
}
.tl-item:last-child {
  padding-bottom: 0;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 30px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}
.tl-item:last-child::before {
  display: none;
}
.tl-node {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text-3);
  z-index: 1;
}
.tl-item.done .tl-node {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-tint);
}
.tl-item.rejected .tl-node {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-tint);
}
.tl-item.current .tl-node {
  border-color: var(--orange);
  color: var(--orange-deep);
  background: var(--orange-tint);
  animation: pulse 2s ease-in-out infinite;
}
.tl-main {
  flex: 1;
  min-width: 0;
}
.tl-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tl-title b {
  font-size: 14px;
}
.tl-opinion {
  margin-top: 7px;
  padding: 9px 12px;
  background: #F6F8FA;
  border-left: 3px solid var(--line);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 13px;
  color: var(--text-2);
}
.tl-item.rejected .tl-opinion {
  background: var(--red-tint);
  border-left-color: var(--red);
}
.tl-item.done .tl-opinion {
  border-left-color: var(--green);
}
.tl-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.tl-meta .num {
  font-size: 11.5px;
}

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(400px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid var(--blue);
  animation: slideL 0.2s ease;
}
.toast.ok {
  border-left-color: #4CAF7D;
}
.toast.err {
  border-left-color: #E5655E;
}
.toast.warn {
  border-left-color: var(--orange);
}
.toast .t-close {
  margin-left: 4px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1.2;
  padding: 0 2px;
}
.toast .t-close:hover {
  color: var(--text);
}

/* ---------- 通用小图标 ---------- */
.svg {
  display: inline-block;
  vertical-align: -2px;
}
