/* 借货占款（全款可退）· 专用样式，全部 .loan- 前缀，避免和既有类名打架 */
#sub-finance-loans { padding: 14px 0 28px; }

.loan-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.loan-head-txt { flex: 1; min-width: 220px; }
.loan-head-txt b { display: block; font-size: 15px; color: #1a1a2e; font-weight: 800; }
.loan-head-txt span { display: block; margin-top: 3px; font-size: 12px; color: #6b7280; line-height: 1.6; }
.loan-btn.big { flex: 0 0 auto; padding: 10px 18px; font-size: 13px; }

/* 库存卡片上的「借货·可退」标记 */
.inv-loan-tag { background: #ecfdf5 !important; color: #047857 !important; border: 1px solid #a7f3d0; }

.loan-topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.loan-topbar .loan-title { font-size: 15px; font-weight: 800; color: #1a1a2e; }
.loan-topbar .loan-desc { font-size: 12px; color: #9ca3af; }
.loan-topbar .loan-btn.primary { margin-left: auto; }

.loan-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.loan-kpi { background: #fff; border: 1px solid #eef0f2; border-radius: 12px; padding: 12px 14px; }
.loan-kpi .k { font-size: 12px; color: #6b7280; }
.loan-kpi .v { font-size: 20px; font-weight: 800; color: #1d3b33; margin-top: 2px; letter-spacing: -.3px; }
.loan-kpi .s { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.loan-kpi.is-alert { background: #fef2f2; border-color: #fecaca; }
.loan-kpi.is-alert .v { color: #dc2626; }
.loan-kpi.is-warn { background: #fffbeb; border-color: #fde68a; }
.loan-kpi.is-warn .v { color: #b45309; }

#loanBatchList { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.loan-card { background: #fff; border: 1px solid #e9edf0; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.loan-card.is-done { background: #f7faf8; border-color: #e3ece6; }
.loan-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.loan-brand { font-size: 14px; font-weight: 800; color: #1a1a2e; }
.loan-no { font-size: 11px; font-weight: 500; color: #9ca3af; margin-left: 6px; }
.loan-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef2f0; color: #4b5563; }
.loan-chip.is-open { background: #ecfdf5; color: #047857; }
.loan-chip.is-over { background: #fef2f2; color: #b91c1c; }
.loan-chip.is-done { background: #f1f5f9; color: #64748b; }

.loan-bar { height: 6px; border-radius: 999px; background: #eef1f3; overflow: hidden; }
.loan-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #0f766e, #34d399); border-radius: 999px; }
.loan-card.is-done .loan-bar > i { background: #94a3b8; }

.loan-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.loan-nums > div { display: flex; flex-direction: column; }
.loan-nums span { font-size: 11px; color: #9ca3af; }
.loan-nums b { font-size: 14px; color: #1f2937; font-weight: 700; }
.loan-nums .is-remain b { color: #b07d3a; }

.loan-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 11px; color: #6b7280; }
.loan-days { font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.loan-days.is-ok { background: #ecfdf5; color: #047857; }
.loan-days.is-warn { background: #fffbeb; color: #b45309; }
.loan-days.is-over { background: #fef2f2; color: #b91c1c; }
.loan-days.is-none { background: #f3f4f6; color: #6b7280; }
.loan-days.is-done { background: #f1f5f9; color: #64748b; }

.loan-actions { display: flex; gap: 8px; margin-top: 2px; }
.loan-btn { flex: 1; padding: 8px 10px; border-radius: 9px; border: 1px solid #d8dee3; background: #fff; color: #374151; font-size: 13px; font-weight: 600; cursor: pointer; }
.loan-btn:hover { border-color: #0f766e; color: #0f766e; }
.loan-btn.primary { background: #1d3b33; border-color: #1d3b33; color: #f5dfa8; }
.loan-btn.primary:hover { background: #14312a; color: #f5dfa8; }
.loan-btn.ghost { background: #fafbfc; }
.loan-btn.sm { flex: 0 0 auto; padding: 5px 10px; font-size: 12px; }
.loan-btn:disabled { opacity: .6; cursor: not-allowed; }

.loan-empty { grid-column: 1 / -1; text-align: center; padding: 42px 16px; color: #9ca3af; font-size: 13px; line-height: 1.8; }
.loan-empty span { font-size: 12px; color: #b0b7bf; }

/* 弹窗 */
.loan-modal { position: fixed; inset: 0; z-index: 1200; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.loan-modal-card { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); overflow: hidden; }
.loan-modal-card.wide { max-width: 780px; }
.loan-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; border-bottom: 1px solid #f1f3f5; }
.loan-modal-head b { font-size: 15px; color: #111827; }
.loan-modal-head button { background: none; border: none; font-size: 18px; color: #6b7280; cursor: pointer; line-height: 1; }
.loan-modal-body { padding: 14px 18px 18px; overflow: auto; }
.loan-modal-body label { display: block; font-size: 12px; color: #6b7280; margin: 10px 0 5px; font-weight: 600; }
.loan-modal-body input, .loan-modal-body select { width: 100%; padding: 9px 11px; border: 1px solid #d8dee3; border-radius: 9px; font-size: 14px; box-sizing: border-box; background: #fff; }
.loan-modal-body input:focus, .loan-modal-body select:focus { outline: none; border-color: #0f766e; }
.loan-modal-foot { display: flex; gap: 10px; margin-top: 16px; position: sticky; bottom: -18px; background: #fff; padding: 10px 0 2px; }
.loan-tip { background: #f6f8f7; border: 1px solid #e6ece9; border-radius: 10px; padding: 9px 11px; font-size: 12px; color: #4b5563; line-height: 1.6; }
.loan-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.loan-preview { margin-top: 10px; font-size: 13px; font-weight: 700; color: #b07d3a; }
.loan-item-name { margin-top: 10px; font-size: 14px; font-weight: 700; color: #111827; }

.loan-detail-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.loan-detail-kpis > div { background: #f8fafb; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.loan-detail-kpis span { font-size: 11px; color: #9ca3af; }
.loan-detail-kpis b { font-size: 15px; color: #111827; }
.loan-detail-meta { margin-top: 8px; font-size: 12px; color: #6b7280; }
.loan-sub-title { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: #374151; }
.loan-table-wrap { overflow-x: auto; }
.loan-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 0; }
.loan-table th, .loan-table td { padding: 7px 8px; border-bottom: 1px solid #f1f3f5; text-align: left; }
.loan-table th { font-size: 11px; color: #9ca3af; font-weight: 600; }
.loan-sku { font-size: 11px; color: #9ca3af; }

@media (max-width: 640px) {
  /* 🔴 财务现在有 5 个子标签，375 宽下横向滚动会把「借货占款」藏在屏幕外
     （用户看不见 = 功能不存在）。窄屏直接把子标签做成可换行的卡片式按钮。 */
  #finance-tab .quote-sub-tabs {
    flex-wrap: wrap; overflow-x: visible; gap: 6px;
    border-bottom: 0; margin-bottom: 14px;
  }
  #finance-tab .quote-sub-tab {
    flex: 1 1 calc(50% - 6px); margin-bottom: 0;
    border: 1px solid #e8e8e8; border-radius: 9px;
    padding: 9px 6px; font-size: 13px; text-align: center; background: #fff;
  }
  #finance-tab .quote-sub-tab.active {
    border-color: #0f3460; background: #eef2f7; border-bottom-color: #0f3460;
  }

  .loan-kpis { grid-template-columns: 1fr 1fr; }
  .loan-topbar .loan-btn.primary { margin-left: 0; width: 100%; }
  .loan-head .loan-btn.big { width: 100%; }
  .loan-2col { grid-template-columns: 1fr; }
  .loan-detail-kpis { grid-template-columns: 1fr 1fr; }
  .loan-modal { align-items: flex-start; padding: 10px 8px; }
  .loan-modal-card, .loan-modal-card.wide { max-height: 94vh; }
  #loanBatchList { grid-template-columns: 1fr; }
}
