/* ===== Ledger archetype (REDESIGN.md §3B): toolbar → KPI strip → table ===== */
.lt-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 0 14px; }
.lt-left, .lt-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lt-right { margin-left: auto; }

/* figures in one row; a real column of numbers, not a row of cards */
.kpi-strip {
  display: flex; flex-wrap: wrap; gap: 0 28px; margin: 0 0 18px; padding: 10px 0 12px;
  border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.kpi-item { min-width: 110px; }
.kpi-item-val { font-family: var(--mono); font-size: 21px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-item-delta { font-size: 12px; font-weight: 500; margin-left: 6px; color: var(--text-faint); }
.kpi-item-label { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.kpi-item.tone-gain .kpi-item-val { color: var(--gain); }
.kpi-item.tone-danger .kpi-item-val { color: var(--danger); }
.kpi-item.tone-warn .kpi-item-val { color: var(--warn); }

/* the table itself: sticky header, sortable, numbers right-aligned in mono */
.ledger-wrap { position: relative; max-height: 70vh; overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.data-table.ledger { border-collapse: separate; border-spacing: 0; }
.data-table.ledger thead th { position: sticky; top: 0; z-index: 2; background: var(--bg-elev); }
.data-table.ledger th.num, .data-table.ledger td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.data-table.ledger td { white-space: nowrap; }
.data-table.ledger td:last-child { width: 1%; }
.th-sort { background: none; border: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--text); }
th.sorted .th-sort { color: var(--text); }
.th-arrow { font-family: var(--mono); font-size: 10px; min-width: 8px; }
.data-table.ledger .chip { font-size: 11px; padding: 2px 8px; }

.empty-state { padding: 22px 8px; text-align: center; color: var(--text-dim); font-size: 13.5px; }
.empty-state p { margin: 0 0 10px; }

/* a form behind a button: inline panel on desktop, bottom sheet on phones */
.lt-disclosure { display: none; }
.lt-disclosure.open { display: block; }
.lt-panel { position: relative; background: var(--bg-elev-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 14px; }
.lt-panel-close { position: absolute; top: 6px; right: 6px; }
.lt-sheet-backdrop { display: none; }
.lt-panel .field, .lt-panel label.field { margin-bottom: 0; }
.lt-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.lt-form .field { display: flex; flex-direction: column; gap: 4px; }
.lt-form .field .lbl { font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.lt-form .input, .lt-form .select { width: auto; min-width: 140px; }
.lt-form .btn { align-self: flex-end; }

@media (max-width: 760px) {
  .kpi-strip { gap: 8px 20px; }
  .kpi-item { min-width: 40%; }
  .kpi-item-val { font-size: 19px; }
  /* two-line rows instead of sideways scrolling */
  .ledger-wrap { max-height: none; border: none; overflow: visible; }
  .data-table.ledger { display: block; white-space: normal; }
  .data-table.ledger thead { display: none; }
  .data-table.ledger tbody { display: block; }
  .data-table.ledger tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
  .data-table.ledger td { display: inline-flex; align-items: baseline; gap: 6px; border: none; padding: 0; white-space: normal; }
  .data-table.ledger td::before { content: attr(data-label); font-size: 11px; color: var(--text-faint); }
  .data-table.ledger td:last-child { width: auto; margin-left: auto; }
  .data-table.ledger td:last-child::before { content: none; }
  .data-table.ledger td.num { text-align: left; }
  /* the disclosure becomes a sheet */
  .lt-disclosure.open .lt-sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 150; }
  .lt-disclosure.open .lt-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 160; margin: 0;
    border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    max-height: 85vh; overflow-y: auto; background: var(--bg-elev-solid); border-color: var(--border); }
  .lt-disclosure.open .lt-panel-close { min-width: 44px; min-height: 44px; top: 4px; right: 4px; }
  .lt-form .input, .lt-form .select { width: 100%; min-width: 0; }
  .lt-form .field { flex: 1 1 140px; }
  .lt-form .btn { width: 100%; }
}

/* The paste panel's two controls are the panel's real work — Copy format and
   Preview/Apply — so on phones they get the 44px target the rest of the app's
   thumb-reachable buttons get, instead of the desktop .btn height. */
@media (max-width: 760px) {
  .lt-paste-actions .btn { flex: 1 1 0; min-height: 44px; justify-content: center; }
}
