/**
 * 租赁业务明细 — 模块样式（对齐租赁合同 lc-page + 台账 ldb-page）
 */
@import url('../../lease-contract-management/styles/lease-contract.css');

.lbd-page.vm-page.lc-page {
  --lbd-list-chrome-offset: 300px;
}

.lbd-page .vm-filter-header {
  margin-bottom: 0;
}

/* —— KPI 汇总卡片（7 项关键指标） —— */
.lbd-kpi-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 1280px) {
  .lbd-kpi-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .lbd-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.lbd-kpi-card {
  --lbd-kpi-accent: var(--ln-primary);
  --lbd-kpi-accent-soft: color-mix(in srgb, var(--lbd-kpi-accent) 12%, var(--ln-surface-card));
  --lbd-kpi-accent-border: color-mix(in srgb, var(--lbd-kpi-accent) 22%, var(--ln-hairline));
  --lbd-kpi-icon-bg: color-mix(in srgb, var(--lbd-kpi-accent) 14%, var(--ln-surface-card));
  --lbd-kpi-icon-color: var(--lbd-kpi-accent);

  position: relative;
  display: flex;
  min-height: 0;
  border-radius: var(--ln-radius-control);
  border: 1px solid var(--lbd-kpi-accent-border);
  background:
    linear-gradient(
      145deg,
      var(--lbd-kpi-accent-soft) 0%,
      var(--ln-surface-card) 58%
    );
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.lbd-kpi-card:hover {
  border-color: color-mix(in srgb, var(--lbd-kpi-accent) 38%, var(--ln-hairline));
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.05),
    0 10px 24px rgba(15, 23, 42, 0.07);
  transform: translateY(-1px);
}

.lbd-kpi-card-accent {
  flex-shrink: 0;
  width: 3px;
  background: linear-gradient(
    180deg,
    var(--lbd-kpi-accent) 0%,
    color-mix(in srgb, var(--lbd-kpi-accent) 55%, transparent) 100%
  );
}

.lbd-kpi-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 8px 10px 8px 8px;
}

.lbd-kpi-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.lbd-kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--ln-radius-xs);
  background: var(--lbd-kpi-icon-bg);
  color: var(--lbd-kpi-icon-color);
}

.lbd-kpi-label {
  flex: 1;
  min-width: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ln-muted);
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.lbd-kpi-val {
  margin: 0;
  padding-left: 30px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ln-ink);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lbd-kpi-val--warn {
  color: var(--ln-error, #cf1322);
}

.lbd-kpi-val--profit {
  color: var(--ln-success, #16a34a);
}

.lbd-kpi-val--loss {
  color: var(--ln-error, #dc2626);
}

.lbd-kpi-tip {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: -2px -4px -2px 0;
  border-radius: var(--ln-radius-xs);
  color: var(--ln-muted-soft);
  cursor: help;
}

.lbd-kpi-tip:hover,
.lbd-kpi-tip:focus-visible {
  color: var(--ln-ink);
  background: color-mix(in srgb, var(--ln-ink) 6%, transparent);
  outline: none;
}

.lbd-kpi-tip:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ln-primary) 35%, transparent);
}

.lbd-kpi-tooltip {
  display: none;
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: min(240px, 70vw);
  padding: 8px 10px;
  border-radius: var(--ln-radius-control);
  background: var(--ln-ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  box-shadow: var(--ln-shadow-hover);
  pointer-events: none;
}

.lbd-kpi-tip:hover .lbd-kpi-tooltip,
.lbd-kpi-tip:focus-within .lbd-kpi-tooltip {
  display: block;
}

.lbd-kpi-card--neutral {
  --lbd-kpi-accent: #64748b;
}

.lbd-kpi-card--receivable {
  --lbd-kpi-accent: #2563eb;
}

.lbd-kpi-card--received {
  --lbd-kpi-accent: var(--ln-success, #16a34a);
}

.lbd-kpi-card--outstanding {
  --lbd-kpi-accent: #d97706;
}

.lbd-kpi-card--outstanding.lbd-kpi-card--warn {
  --lbd-kpi-accent: var(--ln-error, #dc2626);
  --lbd-kpi-accent-soft: color-mix(in srgb, var(--ln-error, #dc2626) 10%, var(--ln-surface-card));
}

.lbd-kpi-card--income {
  --lbd-kpi-accent: var(--ln-primary);
}

.lbd-kpi-card--cost {
  --lbd-kpi-accent: #7c3aed;
}

.lbd-kpi-card--deduction {
  --lbd-kpi-accent: #0891b2;
}

.lbd-kpi-card--profit {
  --lbd-kpi-accent: #059669;
}

@media (prefers-reduced-motion: reduce) {
  .lbd-kpi-card {
    transition: none;
  }

  .lbd-kpi-card:hover {
    transform: none;
  }
}

.lbd-page .vm-table-toolbar.ldb-table-toolbar {
  justify-content: flex-end;
  align-items: center;
}

.lbd-table-wrap {
  overflow: auto;
  scrollbar-gutter: stable;
  min-width: 0;
  flex: 1;
  max-height: calc(100vh - var(--lbd-list-chrome-offset, 420px));
}

/* lc-page 默认 overflow:hidden 会阻断宽表横向滚动 */
.lbd-page.lc-page .vm-table-card > .vm-table-wrap.lbd-table-wrap {
  overflow: auto;
  scrollbar-gutter: stable;
  min-width: 0;
  flex: 1;
}

.lbd-page.lc-page .vm-table-card {
  overflow: visible;
}

.lbd-page .lbd-detail-table.ldb-table {
  min-width: 0;
  width: max-content;
}

.lbd-detail-table th,
.lbd-detail-table td {
  white-space: nowrap;
}

.lbd-detail-table tbody tr:hover td {
  background: var(--ln-canvas-soft);
}

.lbd-detail-table tbody tr:hover td.sticky-col-left {
  background: var(--ln-canvas-soft);
}

.lbd-col-plate {
  font-weight: 600;
  color: var(--ln-ink);
}

.lbd-cell-customer {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.lbd-detail-table .lbd-col-calc {
  color: var(--ln-muted);
  background: color-mix(in srgb, var(--ln-muted-soft) 6%, transparent);
}

.lbd-detail-table thead th.lbd-col-calc {
  background: color-mix(in srgb, var(--ln-muted-soft) 10%, var(--ln-surface-card));
}

.lbd-detail-table tfoot .lbd-summary-row td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  font-weight: 600;
  background: color-mix(in srgb, var(--ln-primary) 6%, var(--ln-surface-card));
  border-top: 2px solid color-mix(in srgb, var(--ln-primary) 22%, var(--ln-hairline));
  box-shadow: 0 -1px 0 var(--ln-hairline);
}

.lbd-detail-table tfoot .lbd-summary-row td.sticky-col-left {
  z-index: 5;
  background: color-mix(in srgb, var(--ln-primary) 8%, var(--ln-surface-card));
}

.lbd-summary-label {
  font-weight: 700;
  color: var(--ln-ink);
  white-space: nowrap;
}

.lbd-outstanding-warn {
  color: #cf1322;
  font-weight: 600;
}

.lbd-profit-pos {
  color: var(--ln-error, #dc2626);
  font-weight: 600;
}

.lbd-profit-neg {
  color: var(--ln-success, #16a34a);
  font-weight: 600;
}

.lbd-field-check-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.lbd-field-check-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.lbd-field-check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.lbd-field-check-icon.is-ok {
  background: color-mix(in srgb, var(--ln-success, #16a34a) 14%, transparent);
  color: var(--ln-success, #16a34a);
}

.lbd-field-check-icon.is-warn {
  background: color-mix(in srgb, var(--ln-error, #dc2626) 12%, transparent);
  color: var(--ln-error, #dc2626);
}

.lbd-field-check-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: var(--ln-radius-control);
  background: var(--ln-ink);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.45;
  box-shadow: var(--ln-shadow-hover);
}

.lbd-field-check-pop--ok {
  background: var(--ln-surface-card);
  color: var(--ln-ink);
  border: 1px solid var(--ln-hairline);
}

.lbd-field-check-pop__title {
  font-weight: 600;
  margin-bottom: 4px;
}

.lbd-field-check-pop__line + .lbd-field-check-pop__line {
  margin-top: 2px;
}

.lbd-field-check-pop__actions {
  margin-top: 8px;
}

.lbd-detail-table .ldb-th-inner {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 100%;
}

.lbd-detail-table .ldb-th-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lbd-cell-remark {
  display: inline-block;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.lbd-empty {
  padding: 48px 24px;
}

.lbd-import-error-step {
  margin-top: 4px;
}

.lbd-import-error-summary {
  margin: 0 0 10px;
  font-size: 0.875rem;
  color: var(--ln-muted);
  line-height: 1.5;
}

.lbd-import-error-summary strong {
  color: var(--ln-error, #dc2626);
  font-weight: 600;
}

.ldb-import-modal .vm-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
}

.ldb-import-modal .vm-upload-zone p {
  margin: 0;
}

.lbd-page .vm-table-actions {
  margin-left: auto;
}

.lbd-role-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: var(--ln-radius-control);
  border: 1px solid var(--ln-hairline);
  background: color-mix(in srgb, var(--ln-primary) 6%, var(--ln-surface-card));
  font-size: 0.875rem;
  color: var(--ln-text-secondary);
}

.lbd-role-banner-hint {
  color: var(--ln-muted);
  font-size: 0.8125rem;
}

.lbd-detail-table .ldb-col-actions {
  min-width: 200px;
}

.lbd-row-archived td {
  background: color-mix(in srgb, var(--ln-muted) 6%, var(--ln-surface-card));
}

.lbd-row-archived:hover td {
  background: color-mix(in srgb, var(--ln-muted) 10%, var(--ln-surface-card));
}

.lbd-changelog-meta {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--ln-muted);
  line-height: 1.4;
}

.lbd-changelog-modal.vm-modal-lg {
  width: min(920px, calc(100vw - 32px));
}

.lbd-changelog-header {
  align-items: center;
}

.lbd-changelog-header-text {
  min-width: 0;
  flex: 1;
}

.lbd-changelog-header .vm-modal-title {
  line-height: 1.35;
}

.lbd-changelog-body {
  overflow: hidden;
  padding: 12px 24px 20px;
}

.lbd-changelog-footer {
  justify-content: flex-end;
}

.lbd-changelog-table-wrap {
  overflow: auto;
  max-height: min(440px, 58vh);
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-radius-control);
  background: var(--ln-surface-card);
  scrollbar-gutter: stable;
}

.lbd-changelog-table {
  width: 100%;
  min-width: 800px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

.lbd-changelog-table th,
.lbd-changelog-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ln-hairline);
  text-align: left;
  line-height: 1.5;
}

.lbd-changelog-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--ln-muted);
  white-space: nowrap;
  vertical-align: middle;
  background: color-mix(in srgb, var(--ln-canvas-soft) 92%, var(--ln-surface-card));
  box-shadow: inset 0 -1px 0 var(--ln-hairline);
}

.lbd-changelog-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--ln-canvas-soft) 45%, transparent);
}

.lbd-changelog-table tbody tr:hover td {
  background: color-mix(in srgb, var(--ln-primary) 5%, var(--ln-surface-card));
}

.lbd-changelog-table tbody tr:last-child td {
  border-bottom: none;
}

.lbd-changelog-cell-meta {
  vertical-align: middle;
  white-space: nowrap;
  color: var(--ln-text-secondary);
}

.lbd-changelog-cell-field {
  vertical-align: middle;
}

.lbd-changelog-field-tag {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ln-primary) 18%, var(--ln-hairline));
  background: color-mix(in srgb, var(--ln-primary) 6%, var(--ln-surface-card));
  color: var(--ln-ink);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.lbd-changelog-cell-diff {
  vertical-align: middle;
}

.lbd-changelog-diff-text {
  display: block;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8125rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.lbd-changelog-diff-text--before {
  color: #b42318;
  background: color-mix(in srgb, #fecaca 28%, transparent);
}

.lbd-changelog-diff-text--after {
  color: #067647;
  background: color-mix(in srgb, #bbf7d0 32%, transparent);
}

.lbd-changelog-empty {
  display: inline-block;
  min-width: 1.25em;
  color: var(--ln-muted);
  text-align: center;
}

.lbd-edit-hint {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--ln-muted);
  line-height: 1.5;
}

.lbd-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
}

@media (max-width: 960px) {
  .lbd-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .lbd-edit-grid {
    grid-template-columns: 1fr;
  }
}

.lbd-edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.lbd-edit-label {
  font-size: 0.8125rem;
  color: var(--ln-text-secondary);
}

.lbd-edit-form {
  max-height: min(68vh, 640px);
  overflow: auto;
}

