/* Quiet History ledger: dense, terminal-like information hierarchy.
   Shared theme controls and section inks remain authoritative. */
.history-shell{
 box-sizing:border-box;height:100%;min-height:0;min-width:0;
 display:grid;grid-template-rows:auto auto minmax(0,1fr) 28px;
 padding:var(--page-inset-top) var(--page-inset-x) var(--page-inset-bottom);background:var(--surface);color:var(--text);font:12px/1.35 var(--font);
}
.history-head,.history-toolbar,.history-foot{display:flex;align-items:center;gap:9px;min-width:0}
.history-head{border-bottom:1px solid var(--border)}
.history-head>strong{font-size:15px;font-weight:650;letter-spacing:.01em;margin-right:14px}
.history-head-count{margin-left:auto;color:var(--text-3);font:11px var(--mono);white-space:nowrap}
.history-toolbar{border-bottom:0;gap:5px;overflow:visible;position:relative;z-index:4}
.history-toolbar :is(input,select){
 flex:0 1 auto;min-width:0;box-sizing:border-box;height:30px!important;min-height:30px!important;
 font:12px/18px var(--font);padding:0 7px!important;border-radius:2px;
}
.history-toolbar input[type=search]{flex:1 1 220px;max-width:400px}
.history-toolbar select{width:124px}
.history-tools-spacer{flex:1 1 auto;min-width:0}
.history-toolbar > button,.history-foot button,.history-detail button{
 flex:0 0 auto;padding:0 9px;height:30px;min-height:30px;background:transparent;
 border:1px solid transparent;border-radius:2px;cursor:pointer;color:var(--text-2);
 font:600 11px/18px var(--font);
}
.history-toolbar > button:hover:not(:disabled),.history-foot button:hover:not(:disabled),
.history-detail button:hover:not(:disabled){background:var(--hover);color:var(--text)}
.history-toolbar > button:disabled,.history-foot button:disabled{opacity:.45;cursor:default}
.history-notice{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;
 display:flex;align-items:center;color:var(--text-3);font:11px var(--font)}
.history-scroll{min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain}
.history-table{border-collapse:collapse;table-layout:fixed;width:100%;min-width:740px}
.history-table col.hist-time{width:138px}
.history-table col.hist-action{width:124px}
.history-table col.hist-book{width:27%}
.history-table col.hist-change{width:auto}
.history-table col.hist-reference{width:74px}
.history-table thead{position:sticky;top:0;z-index:1;background:var(--surface-2)}
.history-table th{font-size:11px;font-weight:600;color:var(--text-2);
 padding:5px 7px;height:27px;text-align:left;border-bottom:1px solid var(--border)}
.history-table th button{
 border:0;border-radius:0;background:transparent;padding:0;margin:0;
 font:inherit;color:inherit;cursor:pointer;text-align:left;white-space:nowrap
}
.history-table th button:hover{color:var(--text)}
.history-table th button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.history-sort-indicator{display:inline-block;margin-left:5px;color:var(--section-history,var(--accent));font-size:11px}
.history-table tbody tr.history-row{height:33px;cursor:pointer}
.history-table tbody tr.history-row:nth-child(even){background:var(--row-even)}
.history-table tbody tr.history-row:hover{background:var(--hover)}
.history-table tbody tr.history-row[aria-expanded=true]{background:var(--row-selected)}
.history-table tbody td{padding:6px 7px;vertical-align:middle;
 border-bottom:1px solid color-mix(in srgb,var(--border) 65%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history-table td.history-when,.history-table td.history-ref{
 color:var(--text-2);font:11px/1.3 var(--mono);font-variant-numeric:tabular-nums;
}
.history-ref{text-align:right}
.history-action{font-weight:650;white-space:nowrap}
.history-catalog{color:var(--section-catalog)}
.history-receive{color:var(--section-receive)}
.history-sell{color:var(--section-sell)}
.history-stocktake{color:var(--section-stocktake)}
.history-change{color:var(--text-2)}
.history-detail-row td{white-space:normal!important;background:var(--surface-2);padding:8px 12px!important}
.history-detail{display:grid;gap:7px;min-width:0;font-size:12px}
.history-detail-meta{display:flex;gap:12px;align-items:center}
.history-detail-meta span{color:var(--text-2)}
.history-detail-meta button{margin-left:auto}
.history-detail-grid{max-height:260px;overflow:auto;display:grid;gap:0}
.history-detail-grid>div{display:grid;grid-template-columns:180px minmax(0,1fr);
 gap:10px;padding:4px 0;border-bottom:1px solid var(--border)}
.history-detail-grid>div>span:first-child{color:var(--text-2)}
.history-detail-value{overflow-wrap:anywhere}
.history-detail-value b{color:var(--section-catalog);font-weight:500;margin:0 6px}
.history-detail-bottom{display:flex;gap:18px;flex-wrap:wrap;font:10px var(--mono);color:var(--text-3)}
.history-detail-reason{color:var(--text-2)}
.history-muted,.history-empty{color:var(--text-3)}
.history-empty{text-align:center;padding:30px 8px!important}
.history-foot{justify-content:space-between;border-top:1px solid var(--border);color:var(--text-2);font:11px var(--mono)}
.history-foot>div{display:flex;gap:5px}
@media(prefers-reduced-motion:reduce){.history-shell *{scroll-behavior:auto!important}}


/* History inspection is a steady workspace pane, not a second scrolling table row. */
.history-workspace{display:grid;grid-template-columns:minmax(0,1fr);min-width:0;min-height:0;position:relative}
.history-workspace.has-inspector{grid-template-columns:minmax(0,1fr) minmax(305px,365px)}
.history-inspector{min-height:0;min-width:0;overflow-y:auto;overscroll-behavior:contain;
 padding:0 12px 12px;background:var(--surface-2);border-left:1px solid var(--border)}
.history-inspector[hidden]{display:none!important}
.history-table tbody tr.history-row[aria-selected=true]{background:var(--row-selected)}
.history-inspector-head{display:flex;align-items:center;gap:7px;position:sticky;top:0;z-index:2;
 height:39px;background:var(--surface-2);border-bottom:1px solid var(--border);margin-bottom:10px}
.history-inspector-head strong{font:650 12px var(--font);flex:1}
.history-inspector-head button{border:1px solid transparent;border-radius:2px;background:transparent;
 color:var(--text-2);min-height:26px;padding:2px 7px;cursor:pointer;font:600 11px var(--font)}
.history-inspector-head button:hover{border-color:var(--border);background:var(--hover);color:var(--text)}
.history-inspector-head button:focus-visible,.history-related button:focus-visible,
.history-detail-actions button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.history-inspector-loading{padding:9px 0}
.history-detail{display:grid;gap:9px;font:12px/1.4 var(--font)}
.history-detail-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}
.history-detail-meta span{font-size:11px}
.history-detail-title{font:650 14px/1.35 var(--font);overflow-wrap:anywhere}
.history-detail-ref{display:flex;align-items:center;gap:5px;color:var(--text-3);font:10px/1.3 var(--mono);overflow-wrap:anywhere}
.history-detail-ref .history-copy-ref{height:19px;min-height:19px;padding:0 3px;border:0;background:transparent;
 color:var(--text-3);opacity:.7;font:12px/1 var(--font);cursor:pointer}
.history-detail-ref .history-copy-ref:hover{opacity:1;color:var(--accent)}
.history-detail-ref .history-copy-ref:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.history-detail-reason{font-size:11px;color:var(--text-2);overflow-wrap:anywhere}
.history-detail-filter{display:flex;align-items:center;gap:6px}
.history-detail-filter input{flex:1;min-width:0;height:30px;background:var(--field);
 color:var(--text);border:1px solid var(--border);border-radius:2px;padding:0 7px;font:11px/18px var(--font)}
.history-detail-filter input:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.history-detail-filter span{color:var(--text-3);font:10px var(--mono);white-space:nowrap}
.history-book-groups{display:grid;gap:0;min-width:0}
.history-book-group{border-bottom:1px solid var(--border);min-width:0}
.history-book-group[hidden]{display:none}
.history-book-group>summary{cursor:pointer;display:flex;align-items:center;gap:10px;
 padding:9px 1px;list-style:none;font:600 11px var(--font);color:var(--text)}
.history-book-group>summary::-webkit-details-marker{display:none}
/* All dropdown/accordion chevrons sit at the far-right edge of the clickable row. */
.history-book-group>summary:after{content:"›";font-size:16px;color:var(--text-3);margin-left:4px;flex:0 0 12px;text-align:right}
.history-book-group[open]>summary:after{content:"⌄"}
.history-book-group>summary .history-book-plain{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history-book-group>summary .history-book-title-link{flex:1;min-width:0;max-width:100%;height:auto;min-height:0;border:0;
 background:transparent;padding:0;text-align:left;color:var(--section-catalog,var(--accent));
 font:600 11px/1.4 var(--font);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
.history-book-group>summary .history-book-title-link:hover{text-decoration:underline;color:var(--accent)}
.history-book-group>summary .history-book-title-link:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.history-book-group>summary small{font:10px var(--mono);color:var(--text-3);white-space:nowrap}
.history-book-group>summary:hover{color:var(--accent)}
.history-book-group summary:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.history-change-list{display:grid;gap:0}
.history-change-line{display:grid;grid-template-columns:minmax(75px,30%) minmax(0,1fr) 12px minmax(0,1fr);
 align-items:start;gap:5px;padding:6px 2px;border-top:1px solid color-mix(in srgb,var(--border) 50%,transparent);
 font-size:11px;overflow-wrap:anywhere}
.history-change-line>span:first-child{color:var(--text-2);font-weight:600}
.history-change-before{color:var(--text-3)}
.history-change-arrow{color:var(--section-history,var(--accent))}
.history-change-after{color:var(--text)}
.history-provenance{padding:6px 0 8px}
.history-provenance>summary{font:10px var(--font);color:var(--text-3);cursor:pointer}
.history-related{display:grid;gap:3px;border-top:1px solid var(--border);padding-top:9px}
.history-related strong{font:650 11px var(--font);margin-bottom:4px}
.history-related button{display:flex;align-items:center;justify-content:space-between;gap:8px;
 padding:5px 3px;border:0;border-radius:2px;background:transparent;color:var(--text);
 text-align:left;font:11px var(--font);cursor:pointer}
.history-related button:hover{background:var(--hover)}
.history-related button small{font:10px var(--font);color:var(--text-3);white-space:nowrap}
.history-detail-actions{display:flex;gap:6px;flex-wrap:wrap}
.history-detail-actions button{min-height:28px;border:1px solid transparent;border-radius:2px;
 background:transparent;color:var(--text-2);padding:4px 9px;font:600 11px var(--font);cursor:pointer}
.history-detail-actions button:hover{background:var(--hover);color:var(--text)}
.history-detail-bottom,.history-related-context{font:10px/1.4 var(--mono);color:var(--text-3)}
@container history-pane (max-width:1140px){
 .history-workspace.has-inspector{display:block}
 .history-workspace.has-inspector>.history-scroll{height:100%}
 .history-workspace.has-inspector>.history-inspector{position:absolute;right:0;top:0;bottom:0;
  width:min(365px,calc(100% - 20px));box-sizing:border-box;z-index:5;
  border:1px solid var(--border-strong,var(--border));box-shadow:0 12px 35px rgba(0,0,0,.27)}
}


/* Confirmed, exact-event Catalog reversal only. Never a universal History Undo. */
.history-correction-review{display:grid;gap:9px;padding:10px;border:1px solid var(--border-strong,var(--border));
 border-radius:2px;background:var(--surface);margin-top:3px}
.history-correction-review>strong{font:650 12px var(--font);color:var(--text)}
.history-review-values{display:grid;grid-template-columns:minmax(0,1fr) 14px minmax(0,1fr);
 gap:6px;align-items:center;font:11px var(--font);overflow-wrap:anywhere}
.history-review-values>span:nth-child(1){color:var(--text-3)}
.history-review-values>span:nth-child(2){color:var(--section-history,var(--accent))}
.history-review-values>span:nth-child(3){font-weight:650;color:var(--text)}
.history-correction-review p{font:11px/1.45 var(--font);color:var(--text-2);margin:0}
.history-correction-review .history-correct-confirm{background:var(--accent);border-color:var(--accent);color:#fff}
.history-correction-review .history-correct-confirm:hover:not(:disabled){filter:brightness(1.08);color:#fff}
.history-correction-review button:disabled{opacity:.45;cursor:default}


/* Verified Quill provenance: visible only on Quill-origin rows. Ordinary
   manual activity stays quiet; legacy events are never guessed as manual. */
.history-toolbar [data-hist-origin]{width:142px;flex:0 0 142px}
.history-table col.hist-action{width:174px}
.history-table{min-width:800px}
.history-quill-origin{
 display:inline-block;margin-left:6px;vertical-align:baseline;
 font:600 10px/1.2 var(--font);color:var(--accent);white-space:nowrap
}
.history-quill-assisted{color:var(--text-2);font-weight:500}
.history-origin-detail{display:grid;grid-template-columns:80px minmax(0,1fr);gap:9px;
 padding:4px 0;border-bottom:1px solid var(--border);font-size:11px}
.history-origin-detail span{color:var(--text-3)}
.history-origin-detail strong{font-weight:500;overflow-wrap:anywhere}

/* Keep the record and controls together; no empty status or paging bands. */
.history-toolbar{padding-block:4px;flex-wrap:wrap}
.history-notice:empty{display:block;height:0;min-height:0;padding:0}
.history-notice:not(:empty){min-height:22px;padding-block:3px;white-space:normal;overflow-wrap:anywhere}
.history-foot [data-hist-pagination][hidden]{display:none}
.history-foot button{height:24px;min-height:24px;min-width:26px;padding-inline:5px}
.history-inspector-head{height:auto;min-height:32px;margin-bottom:5px}
.history-inspector{background:var(--surface);padding-inline:10px}
.history-inspector-head{background:var(--surface)}
.history-detail{gap:5px}
.history-detail-ref{flex-wrap:wrap;gap:4px 7px}
.history-detail-ref>button:not(.history-copy-ref){font:600 11px var(--font);height:26px;min-height:26px;padding-inline:5px}
.history-origin-detail{padding:2px 0;border:0}
.history-book-group>summary{padding-block:6px}
.history-change-line{padding-block:4px}
.history-related{padding-top:6px}
.history-correction-review .history-correct-confirm{color:var(--on-primary)}
.history-correction-review .history-correct-confirm:hover:not(:disabled){color:var(--on-primary)}

/* H01/H02: adaptive command surface, literal before/after inspection. */
.history-shell{container:history-pane / inline-size}
.history-head>.history-toolbar{flex:1 1 0;min-width:0}
.history-toolbar input[type=search]{flex:1 1 180px;min-width:130px;max-width:340px}
.history-toolbar select{width:118px}
.history-toolbar [data-hist-origin]{width:132px;flex:0 1 132px}
.history-toolbar [data-history-date-range]{flex:none;max-width:100%}
.history-output-actions{display:flex;align-items:center;gap:2px;margin-left:auto;flex:none}
.history-output-actions>button{height:30px;min-height:30px;padding:0 8px;background:transparent;border:1px solid transparent;border-radius:var(--r);color:var(--text-2);font:600 11px var(--font);cursor:pointer}
.history-output-actions>button:hover:not(:disabled){background:var(--hover);color:var(--text)}
.history-output-actions>button:disabled{opacity:.45;cursor:default}
.history-foot{font-family:var(--font);font-variant-numeric:tabular-nums;min-height:26px}
.history-correction-review{gap:6px;padding:7px 0 0;border:0;border-top:1px solid var(--border-strong,var(--border))}
.history-inspector{container:history-inspection / inline-size}
@container history-inspection (max-width:310px){.history-change-line{grid-template-columns:minmax(0,1fr) 12px minmax(0,1fr);gap:3px 5px}.history-change-line>span:first-child{grid-column:1/-1}.history-change-before{grid-column:1}}
@container history-pane (max-width:830px){.history-head>.history-toolbar{flex:1 1 100%;padding:2px 0 5px}.history-toolbar input[type=search]{max-width:none}}
@container history-pane (max-width:460px){.history-toolbar input[type=search]{flex-basis:100%;max-width:none}.history-toolbar [data-hist-kind],.history-toolbar [data-hist-origin]{flex:1 1 105px;min-width:90px}.history-toolbar [data-history-date-range]{flex:1 1 145px}.history-workspace.has-inspector>.history-inspector{width:100%}}

/* Same scan rhythm as Catalog, with precise timestamps and references. */
html[data-material] .history-table td.history-when,html[data-material] .history-table td.history-ref{font-variant-numeric:tabular-nums}
html[data-material][data-density="compact"] .history-table tbody tr.history-row{height:30px}
html[data-material][data-density="comfortable"] .history-table tbody tr.history-row{height:44px}
html[data-material][data-separators="subtle"] .history-table tbody td{border-bottom:1px solid var(--border)}
