/* 数量流水账 · 全局精简账本 */

.ledger-intro,
.ledger-intro-modal {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.85;
}

#stab-ledger {
  padding: 4px 0 8px;
}

#ledger-open-from-settings {
  min-height: 44px;
}

.ledger-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.ledger-toolbar input,
.ledger-toolbar select {
  min-height: 40px;
  font-size: 14px;
}

.ledger-toolbar #ledger-q {
  flex: 1 1 200px;
  min-width: 0;
}

.ledger-list-wrap {
  border: 1px solid var(--line, rgba(100, 116, 139, 0.3));
  border-radius: 10px;
  overflow: auto;
  max-height: min(58vh, 560px);
  -webkit-overflow-scrolling: touch;
}

.ledger-list-wrap .ledger-table.desk-ledger-table {
  margin: 0;
}

.ledger-table.desk-ledger-table {
  display: none;
}

.ledger-list {
  display: flex;
  flex-direction: column;
}

.ledger-card {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line, rgba(100, 116, 139, 0.28));
}

.ledger-card:last-child {
  border-bottom: 0;
}

.ledger-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-bottom: 4px;
}

.ledger-card-time {
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
}

.ledger-card-model {
  font-weight: 800;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line, rgba(100, 116, 139, 0.35));
  white-space: nowrap;
}

.ledger-pill-in {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border-color: rgba(34, 197, 94, 0.35);
}

.ledger-pill-out {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.35);
}

.ledger-pill-tf {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border-color: rgba(59, 130, 246, 0.35);
}

.ledger-pill-other {
  background: rgba(148, 163, 184, 0.15);
}

.ledger-card-loc {
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.ledger-card-loc .sh-loc-line,
.ledger-table .sh-loc-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  line-height: 1.45;
  padding: 2px 0;
}

.ledger-card-loc .sh-loc-line + .sh-loc-line,
.ledger-table .sh-loc-line + .sh-loc-line {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line, rgba(100, 116, 139, 0.28));
}

.ledger-card-loc .sh-loc-code,
.ledger-table .sh-loc-code {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.ledger-card-loc .sh-loc-act,
.ledger-table .sh-loc-act {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.ledger-card-loc .sh-loc-qty,
.ledger-table .sh-loc-qty {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ledger-card-loc .sh-loc-ba,
.ledger-table .sh-loc-ba {
  font-size: 12px;
  opacity: 0.82;
  font-variant-numeric: tabular-nums;
}

.ledger-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.82;
}

.ledger-card-who {
  font-weight: 700;
}

.ledger-card-note {
  flex: 1 1 120px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.ledger-table col.lg-col-time {
  width: 108px;
}

.ledger-table col.lg-col-type {
  width: 72px;
}

.ledger-table col.lg-col-model {
  width: 15%;
}

.ledger-table col.lg-col-loc {
  width: 30%;
}

.ledger-table col.lg-col-operator {
  width: 88px;
}

.ledger-table col.lg-col-note {
  width: auto;
}

.ledger-table th,
.ledger-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line, rgba(100, 116, 139, 0.25));
  vertical-align: middle;
  text-align: left;
  line-height: 1.3;
  overflow: hidden;
}

.ledger-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--glass-strong, rgba(15, 23, 42, 0.92));
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

html[data-theme="excel"] .ledger-table thead th,
html[data-theme="classic"] .ledger-table thead th {
  background: var(--glass-strong, #f1f5f9);
}

.ledger-table .lg-time {
  white-space: nowrap;
  font-size: 12px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.ledger-table .lg-type {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-table .lg-type .ledger-pill {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  padding: 2px 6px;
  vertical-align: middle;
}

.ledger-table .lg-model {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: none;
  word-break: normal;
}

.ledger-table .lg-loc-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: none;
  font-variant-numeric: tabular-nums;
}

.ledger-table th.lg-th-operator,
.ledger-table td.lg-operator {
  width: 88px;
  min-width: 88px;
  max-width: 96px;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  text-align: center;
}

.ledger-table th.lg-th-operator {
  text-align: center;
}

.ledger-table .lg-note {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  opacity: 0.88;
}

.ledger-table .ledger-row td {
  height: 34px;
  max-height: 34px;
}

.ledger-table .lg-loc-cell,
.ledger-table .lg-model,
.ledger-table .lg-time,
.ledger-table .lg-note {
  word-break: keep-all;
  overflow-wrap: normal;
}

.ledger-foot {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.dash-loc-ledger-link {
  margin-top: 10px;
}

.dash-loc-ledger-link button {
  min-height: 40px;
}

.ledger-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ledger-modal-head h3 {
  flex: 1 1 auto;
  min-width: 0;
}

.ledger-head-actions {
  flex-shrink: 0;
}

.ledger-filter-toggle {
  min-height: 40px;
  font-weight: 700;
}

.ledger-filter-toggle.has-active {
  border-color: rgba(96, 165, 250, 0.55) !important;
  color: var(--accent, #60a5fa) !important;
}

.ledger-filters {
  margin-bottom: 8px;
}

#ledger-filters.collapsed .ledger-toolbar {
  display: none;
}

.ledger-toolbar #ledger-model,
.ledger-toolbar #ledger-loc,
.ledger-toolbar #ledger-operator {
  min-width: 0;
}

.mq-card-btn-ledger {
  border-color: rgba(96, 165, 250, 0.45) !important;
  color: var(--accent, #60a5fa) !important;
}

.mq-loc-ledger-link {
  margin-top: 8px;
}

.mq-loc-ledger-link button {
  min-height: 40px;
  width: 100%;
}

@media (min-width: 861px) {
  .ledger-intro-modal {
    display: none;
  }

  #modal-ledger .ledger-panel {
    display: flex;
    flex-direction: column;
    max-height: min(92vh, 880px);
  }

  #modal-ledger .modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    padding-top: 6px;
  }

  #ledger-meta {
    flex-shrink: 0;
    margin-bottom: 6px;
  }

  .ledger-list-wrap {
    flex: 1;
    min-height: 280px;
    max-height: none;
  }

  .ledger-list {
    display: none;
  }

  .ledger-table.desk-ledger-table {
    display: table;
  }

  #ledger-filters:not(.collapsed) .ledger-toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--line, rgba(100, 116, 139, 0.28));
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.22);
  }

  html[data-theme="excel"] #ledger-filters:not(.collapsed) .ledger-toolbar,
  html[data-theme="classic"] #ledger-filters:not(.collapsed) .ledger-toolbar {
    background: rgba(241, 245, 249, 0.85);
  }

  #ledger-filters:not(.collapsed) .ledger-toolbar #ledger-q {
    grid-column: 1 / -1;
    flex: none;
  }

  #ledger-filters:not(.collapsed) .ledger-toolbar #ledger-refresh {
    justify-self: end;
    min-width: 88px;
    font-weight: 700;
  }
}

@media (max-width: 860px) {
  .ledger-filter-toggle {
    min-height: 44px;
    padding: 8px 14px !important;
  }

  .ledger-intro-modal {
    display: none;
  }

  #ledger-filters.collapsed .ledger-toolbar {
    display: none;
  }

  .ledger-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .ledger-toolbar #ledger-q {
    grid-column: 1 / -1;
    flex: none;
  }

  .ledger-toolbar #ledger-model,
  .ledger-toolbar #ledger-loc,
  .ledger-toolbar #ledger-operator {
    flex: none;
    max-width: none !important;
    min-width: 0;
  }

  .ledger-toolbar #ledger-type,
  .ledger-toolbar #ledger-dir {
    min-width: 0;
  }

  .ledger-toolbar #ledger-date-from,
  .ledger-toolbar #ledger-date-to {
    flex: none;
    min-width: 0;
  }

  .ledger-toolbar #ledger-refresh {
    grid-column: 1 / -1;
    min-height: 44px;
    font-weight: 800;
  }

  .ledger-toolbar input[type="date"] {
    flex: none;
    min-width: 0;
  }

  .ledger-list-wrap {
    max-height: none;
    flex: 1;
    border: 0;
    border-radius: 0;
  }

  #modal-ledger .modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    padding-top: 8px;
  }

  #modal-ledger .ledger-panel {
    display: flex;
    flex-direction: column;
    max-height: 100dvh;
  }

  #ledger-meta {
    margin-bottom: 6px;
  }

  .ledger-card-note {
    white-space: normal;
  }
}
