/* 租赁业务台账 — 模块样式（基于 vehicle-management vm-* + ledger-shared 壳层） */

@import '../../ledger-shared/styles/ledger-page.css';

.ldb-kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

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

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

.ldb-kpi-card {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--ln-radius-card);
  border: 1px solid var(--ln-hairline);
  background: var(--ln-surface-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
  min-height: 76px;
}

.ldb-kpi-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ln-muted-soft);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.ldb-kpi-val {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--ln-ink);
  line-height: 1.2;
}

.ldb-kpi-val--profit { color: var(--ln-success); }
.ldb-kpi-val--loss { color: var(--ln-error); }

.ldb-kpi-tip {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--ln-muted-soft);
  cursor: help;
}

.ldb-th-tip.ldb-kpi-tip {
  position: relative;
  top: auto;
  right: auto;
}

.ldb-kpi-tooltip {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  width: max-content;
  max-width: 240px;
  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);
}

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

.ldb-kpi-tip .ldb-kpi-tooltip {
  top: auto;
  bottom: calc(100% + 6px);
  right: 0;
  left: auto;
}

.ldb-th-inner .ldb-kpi-tooltip {
  max-width: 280px;
  text-align: left;
  white-space: normal;
  z-index: 50;
}

.ldb-table-toolbar {
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.ldb-toolbar-unpaid-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ldb-toolbar-unpaid-filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 14px 0 10px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ln-ink);
  background: linear-gradient(180deg, var(--ln-surface-card) 0%, color-mix(in srgb, var(--ln-canvas-soft) 35%, var(--ln-surface-card)) 100%);
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-radius-pill);
  box-shadow: var(--ln-shadow-soft);
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease,
    transform 0.12s ease;
}

.ldb-toolbar-unpaid-filter:hover {
  border-color: color-mix(in srgb, var(--ln-primary) 42%, var(--ln-hairline));
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.07);
}

.ldb-toolbar-unpaid-filter:active {
  transform: translateY(1px);
  box-shadow: var(--ln-shadow-soft);
}

.ldb-toolbar-unpaid-filter.is-active {
  border-color: var(--ln-primary);
  background: color-mix(in srgb, var(--ln-primary) 9%, var(--ln-surface-card));
  color: var(--ln-primary-focus);
  font-weight: 600;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ln-primary) 20%, transparent),
    0 2px 10px color-mix(in srgb, var(--ln-primary) 12%, transparent);
}

.ldb-toolbar-unpaid-filter.is-active:hover {
  border-color: var(--ln-primary-focus);
  background: color-mix(in srgb, var(--ln-primary) 12%, var(--ln-surface-card));
}

.ldb-toolbar-unpaid-filter:focus-within {
  outline: 2px solid color-mix(in srgb, var(--ln-primary) 35%, transparent);
  outline-offset: 2px;
}

.ldb-toolbar-data-count {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.8125rem;
  color: var(--ln-muted);
  background: color-mix(in srgb, var(--ln-primary) 7%, var(--ln-surface-muted, #f1f5f9));
  border-radius: var(--ln-radius-pill);
  white-space: nowrap;
}

.ldb-toolbar-data-count-num {
  font-weight: 700;
  color: var(--ln-primary);
}

@media (prefers-reduced-motion: reduce) {
  .ldb-toolbar-unpaid-filter {
    transition: none;
  }

  .ldb-toolbar-unpaid-filter:active {
    transform: none;
  }
}

.ldb-kpi-card--clickable {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--ln-hairline);
  background: var(--ln-surface-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ldb-kpi-card--clickable:hover {
  border-color: var(--ln-primary);
  box-shadow: var(--ln-shadow-soft);
}

.ldb-kpi-card--clickable.ldb-kpi-card--active {
  border-color: var(--ln-primary);
  box-shadow: 0 0 0 1px var(--ln-primary);
}

.ldb-asset-tag {
  display: inline-flex;
  padding: 0 8px;
  border-radius: var(--ln-radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 22px;
}

.ldb-asset--owned { background: #eff6ff; color: #1d4ed8; }
.ldb-asset--leased { background: #fff7ed; color: #c2410c; }
.ldb-asset--affiliated { background: #f5f3ff; color: #6d28d9; }

.ldb-table-wrap { overflow: auto; }
.ldb-table { min-width: 4200px; }

.ldb-table .vm-table thead th,
.ldb-table .vm-table tbody td {
  padding: 10px 12px;
  transition: background-color 0.18s ease;
}

.ldb-table .vm-table tbody tr {
  transition: background-color 0.18s ease;
}

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

.ldb-cell-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ldb-cell-primary {
  font-size: 0.875rem;
  color: var(--ln-ink);
  line-height: 1.35;
}

.ldb-cell-secondary {
  font-size: 0.75rem;
  color: var(--ln-muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ldb-col-money { text-align: left; white-space: nowrap; }
.ldb-col-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ldb-col-remark { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ldb-col-actions { min-width: 168px; white-space: nowrap; }

.ldb-row-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ldb-action-btn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0;
  border: none;
  background: none;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border-radius: var(--ln-radius-xs);
  transition: color 0.15s ease, opacity 0.15s ease, background-color 0.15s ease;
}

.ldb-action-btn:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ldb-action-btn--edit {
  color: var(--ln-primary);
}

.ldb-action-btn--edit:hover {
  color: var(--ln-primary-hover);
}

.ldb-action-btn--link {
  color: #2563eb;
}

.ldb-action-btn--link:hover {
  color: #1d4ed8;
}

.ldb-action-btn--delete {
  color: var(--ln-error);
}

.ldb-action-btn--delete:hover {
  color: #b91c1c;
}

.ldb-th-inner {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 24px;
  padding-right: 8px;
}

.ldb-th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.ldb-th-sort:hover {
  color: var(--ln-primary);
}

.ldb-th-sort.is-active {
  color: var(--ln-primary);
}

.ldb-th-sort-icon {
  display: inline-flex;
  color: var(--ln-muted-soft);
  flex-shrink: 0;
}

.ldb-th-sort.is-active .ldb-th-sort-icon {
  color: var(--ln-primary);
}

.ldb-th-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ldb-col-resizable {
  position: relative;
}

.ldb-col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.ldb-col-resize-handle:hover {
  background: color-mix(in srgb, var(--ln-primary) 18%, transparent);
}

.ldb-table-skeleton {
  padding: 12px 0;
}

.ldb-skeleton-row {
  height: 44px;
  margin: 0 12px 8px;
  border-radius: var(--ln-radius-control);
  background: linear-gradient(90deg, var(--ln-canvas-soft) 25%, #eef1f4 50%, var(--ln-canvas-soft) 75%);
  background-size: 200% 100%;
  animation: ldb-skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes ldb-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.vm-btn-danger {
  background: var(--ln-error);
  color: #fff;
  border-color: var(--ln-error);
}

.vm-btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.ldb-status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--ln-radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 20px;
  border: 1px solid transparent;
}

.ldb-status--unpaid { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ldb-status--partial { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.ldb-status--paid { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.ldb-status--archived { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ldb-status--unarchived { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ldb-status--draft { background: #f8fafc; color: #475569; border-color: #e2e8f0; }

.ldb-confirm-text {
  margin: 0 0 8px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ln-ink);
}

.ldb-confirm-meta {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ln-muted);
}

.ldb-receipt-modal { max-width: 720px; width: calc(100% - 32px); }

.ldb-receipt-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--ln-radius-control);
  background: var(--ln-surface-strong);
  font-size: 0.8125rem;
  color: var(--ln-muted);
}

.ldb-receipt-summary strong {
  color: var(--ln-ink);
  font-weight: 600;
}

.ldb-receipt-table-wrap {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-radius-control);
}

.ldb-receipt-table { margin: 0; }

.ldb-receipt-empty {
  text-align: center;
  color: var(--ln-muted);
  padding: 24px !important;
}

.vm-btn-link:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.ldb-action-sep { color: var(--ln-hairline); margin: 0 2px; }
.ldb-link-danger { color: var(--ln-error) !important; }

.ldb-table .vm-table thead th.ldb-col-money,
.ldb-table .vm-table tbody td.ldb-col-money {
  text-align: left;
}

.ldb-link-preview {
  margin: 12px 0 0;
  font-size: 0.8125rem;
  color: var(--ln-muted);
}

.ldb-link-preview strong {
  color: var(--ln-ink);
}

.ldb-income-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
}

.ldb-income-warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #fff7ed;
  color: #c2410c;
  cursor: pointer;
  flex-shrink: 0;
}

.ldb-income-warn:hover {
  background: #ffedd5;
}

.ldb-income-pending {
  color: #c2410c;
}

.ldb-income-input {
  width: 100%;
  min-width: 88px;
  max-width: 120px;
  padding: 4px 8px;
  font-size: 0.8125rem;
  text-align: left;
}

.ldb-computed-val {
  color: var(--ln-ink);
}

.ldb-cell-readonly {
  color: var(--ln-muted);
}

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

.ldb-th-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--ln-muted-soft);
  cursor: help;
  flex-shrink: 0;
  vertical-align: middle;
}

.ldb-th-tip:focus-visible {
  outline: 2px solid var(--ln-focus-ring, #32a06e);
  outline-offset: 2px;
  border-radius: 4px;
}

.ldb-kpi-tooltip--portal {
  display: block;
  position: fixed;
  z-index: 1000;
  width: max-content;
  max-width: min(280px, calc(100vw - 24px));
  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);
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.ldb-text-input {
  width: 100%;
  min-width: 100px;
  max-width: 140px;
  padding: 4px 8px;
  font-size: 0.8125rem;
}

.ldb-input-required {
  border-color: #f97316;
}

.ldb-linked-badge {
  display: inline-flex;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.6875rem;
  font-weight: 600;
  vertical-align: middle;
}

.ldb-overflow-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--ln-radius-control);
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.ldb-overflow-tag {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: #c2410c;
}

.ldb-alloc-input {
  width: 88px;
  padding: 4px 6px;
  font-size: 0.8125rem;
  text-align: left;
}

.ldb-col-unreceived-warn {
  color: #c2410c;
  font-weight: 600;
}

.ldb-cell-multiline {
  white-space: pre-line;
  line-height: 1.45;
}

.ldb-detail-popover-trigger {
  display: inline-block;
  max-width: 100%;
  border: none;
  background: transparent;
  padding: 2px 6px;
  margin: -2px -6px;
  font: inherit;
  color: inherit;
  text-align: left;
}

.ldb-cell-clickable {
  color: #1d4ed8;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(29, 78, 216, 0.35);
  text-underline-offset: 2px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease, text-decoration-color 0.15s ease;
}

.ldb-cell-clickable:hover,
.ldb-cell-clickable[aria-expanded='true'] {
  color: #1e40af;
  text-decoration-color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
}

.ldb-detail-popover-trigger:hover,
.ldb-detail-popover-trigger[aria-expanded='true'] {
  text-decoration-color: #1d4ed8;
}

.ldb-line-items-trigger--editable {
  color: var(--ln-ink);
}

.ldb-detail-card-modal {
  width: min(640px, calc(100vw - 48px));
  max-height: min(560px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ldb-detail-card-in 0.22s ease-out;
}

.ldb-detail-card-backdrop {
  animation: ldb-detail-backdrop-in 0.18s ease-out;
}

@keyframes ldb-detail-card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ldb-detail-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ldb-detail-card-modal,
  .ldb-detail-card-backdrop {
    animation: none;
  }
}

.ldb-detail-card-header {
  flex-shrink: 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ln-hairline);
}

.ldb-detail-card-body {
  flex: 1;
  min-height: 0;
  padding: 16px 24px 24px;
  overflow: auto;
  max-height: none;
}

.ldb-detail-card-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--ln-radius-control);
  background: var(--ln-surface-strong);
  border: 1px solid var(--ln-hairline);
}

.ldb-detail-card-summary-label {
  font-size: 0.8125rem;
  color: var(--ln-muted);
  font-weight: 500;
}

.ldb-detail-card-summary-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ln-ink);
  letter-spacing: -0.01em;
}

.ldb-detail-card-content {
  min-width: 0;
}

.ldb-detail-card-meta {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: var(--ln-muted);
}

.ldb-detail-card-table-wrap {
  overflow: auto;
  max-height: min(360px, 48vh);
  border: 1px solid var(--ln-hairline);
  border-radius: var(--ln-radius-control);
  background: var(--ln-surface-card);
}

.ldb-detail-card-footer {
  flex-shrink: 0;
  margin: 0;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--ln-hairline);
}

.ldb-detail-popover-empty {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ln-muted);
  border: 1px dashed var(--ln-hairline);
  border-radius: var(--ln-radius-control);
  background: var(--ln-canvas-soft);
}

.ldb-detail-popover-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.ldb-detail-popover-table th,
.ldb-detail-popover-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ln-hairline);
  text-align: left;
  vertical-align: middle;
}

.ldb-detail-popover-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.ldb-detail-popover-table th {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--ln-muted);
  white-space: nowrap;
  background: var(--ln-canvas-soft);
}

.ldb-detail-popover-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

.ldb-detail-popover-table tbody tr:last-child td {
  border-bottom: none;
}

.ldb-detail-col-amount {
  text-align: right;
  font-weight: 500;
  color: var(--ln-ink);
}

.ldb-line-items-table-wrap {
  max-height: min(400px, 52vh);
}

.ldb-line-items-table th.ldb-line-items-col-action,
.ldb-line-items-table td.ldb-line-items-col-action {
  width: 56px;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}

.ldb-line-items-table td.ldb-detail-col-amount {
  text-align: right;
}

.ldb-line-items-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.8125rem;
  border-radius: var(--ln-radius-control);
}

.ldb-line-items-input--amount {
  text-align: right;
}

.ldb-line-items-input:focus {
  outline: none;
  border-color: var(--vm-focus-border-color, #2563eb);
}

.ldb-line-items-empty-cell {
  padding: 24px 12px !important;
  text-align: center;
  color: var(--ln-muted);
  font-size: 0.875rem;
}

.ldb-line-items-row-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--ln-radius-control);
  background: transparent;
  color: var(--ln-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ldb-line-items-row-delete:hover {
  color: var(--ln-error, #dc2626);
  background: #fef2f2;
  border-color: #fecaca;
}

.ldb-line-items-row-delete:focus-visible {
  outline: none;
  border-color: var(--vm-focus-border-color, #2563eb);
}

.ldb-line-items-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.ldb-import-modal {
  width: min(640px, calc(100vw - 48px));
}

.ldb-line-items-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.ldb-action-btn--history {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ldb-action-btn--history:hover {
  color: #1e40af;
  background: rgba(37, 99, 235, 0.08);
}

.ldb-action-btn--save {
  color: var(--ln-success, #15803d);
}

.ldb-action-btn--save:hover {
  color: #166534;
}
