.tp-custody-chain{padding:14px 0;border-bottom:1px solid var(--line)}
.tp-custody-chain h4,.tp-custody-chain p{margin:0 0 8px;overflow-wrap:anywhere}
.tp-custody-chain ol{margin:10px 0 0;padding-left:24px}
.tp-custody-chain li{padding:0 0 12px 4px;overflow-wrap:anywhere}
.tp-holder{padding:12px 0;border-bottom:1px solid var(--line,#e1e7ef);overflow-wrap:anywhere}
.tp-holder button{max-width:100%;white-space:normal;overflow-wrap:anywhere}
body.tool-panel-open{overflow:hidden}
.tool-panel{width:min(820px,calc(100vw - 24px));max-height:calc(100dvh - 32px);border:0;border-radius:18px;padding:0;margin:auto;overflow-y:auto;overscroll-behavior:contain;background:#fff;color:var(--text,#172b45);box-shadow:0 24px 90px #071a3d50}
.tool-panel::backdrop{background:#091a31b8;backdrop-filter:blur(3px)}
.tp-header,.tp-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:18px 22px}
.tp-header{border-bottom:1px solid var(--line,#e1e7ef)}
.tp-header small{color:var(--muted);font-size:11px;font-weight:800;letter-spacing:.08em}
.tp-header h2{margin:4px 0;overflow-wrap:anywhere}
.tp-header button{flex:none}
.tp-body{padding:22px}
.tp-photo{height:auto;min-height:110px;min-width:0;padding:12px;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);place-items:center;background:radial-gradient(ellipse at 25% 10%,#fff,#e4efff);border:1px solid #b7d0f6;border-radius:18px;box-shadow:inset 0 1px 0 #fff,0 10px 28px #1d4ed814;overflow:hidden;color:var(--muted)}
.tp-photo img{display:block;width:auto;height:auto;max-width:100%;max-height:100%;min-width:0;min-height:0;object-fit:contain;object-position:center}
.tp-photo>img{max-height:min(55dvh,560px)}
.tp-photo .hidden,.tp-borrower-photo .hidden{display:none}
.tp-summary{display:grid;grid-template-columns:minmax(0,.7fr) minmax(0,1.3fr);gap:18px;margin-top:20px}
.tp-availability,.tp-latest{padding:18px;border:1px solid var(--line,#e1e7ef);border-radius:12px;min-width:0}
.tp-summary h3{margin:0 0 16px;font-size:14px;color:var(--muted)}
.tp-availability{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;background:#f1f8f4}
.tp-availability>strong{font-size:48px;line-height:1.2;color:#17633f}
.tp-availability>span{margin-top:4px;color:var(--muted);overflow-wrap:anywhere}
.tp-borrower{display:grid;gap:12px;justify-items:center;text-align:center;overflow-wrap:anywhere}
.tp-borrower>strong{font-size:20px;max-width:100%}
.tp-borrower-photo{width:min(100%,220px);height:220px;min-width:0;padding:5px;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);place-items:center;background:#f1f5f9;border-radius:10px;overflow:hidden;color:var(--muted);font-size:13px}
.tp-borrower-photo img{display:block;width:100%;height:100%;max-width:100%;max-height:100%;min-width:0;min-height:0;object-fit:contain;object-position:center}
.tp-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin:22px 0}
.tp-fields dt{font-size:11px;text-transform:uppercase;color:var(--muted);font-weight:700;margin-bottom:4px}
.tp-fields dd{margin:0;overflow-wrap:anywhere;white-space:pre-wrap}
.tp-records h3{margin:22px 0 12px}
.tp-record{display:grid;gap:5px;width:100%;text-align:left;border:1px solid var(--line,#e1e7ef);border-radius:10px;background:#f8fafc;padding:14px;margin:8px 0;overflow-wrap:anywhere}
.tp-record small{color:var(--muted);line-height:1.6}
.tp-footer{border-top:1px solid var(--line,#e1e7ef);flex-wrap:wrap}
.tp-footer p{font-size:12px;color:var(--muted);flex:1;min-width:180px}
.tp-footer button{flex:none}
.tp-footer [hidden]{display:none}
[data-tool-record]{cursor:pointer}
[data-tool-record]:hover{background:#f3f7fd}
@media(max-width:520px){.tp-body,.tp-header,.tp-footer{padding:16px}.tp-footer p{flex-basis:100%}.tp-photo{height:auto;padding:8px;border-radius:14px}.tp-fields{gap:16px 12px}.tp-header h2{font-size:20px}.tp-summary{grid-template-columns:1fr;gap:12px}.tp-availability{padding:14px}.tp-availability h3{margin-bottom:8px}.tp-availability>strong{font-size:38px}}
/* Keep navigation and actions reachable while long histories scroll. */
.tool-panel{overflow:hidden}
.tool-panel[open]{display:flex;flex-direction:column}
.tp-header,.tp-footer{flex:none}
.tp-header>div{min-width:0}
.tp-body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.tp-footer button{max-width:100%;white-space:normal;overflow-wrap:anywhere}
@media(max-width:600px){
 .tp-footer{padding-bottom:calc(16px + env(safe-area-inset-bottom))}
 .tp-footer button{flex:1 1 80px;min-height:44px}
 .tp-fields{grid-template-columns:minmax(0,1fr)}
}
@media(max-height:520px) and (orientation:landscape){
 .tool-panel{max-height:98dvh}
 .tp-photo{height:auto;min-height:70px}
 .tp-photo>img{max-height:45dvh}
 .tp-header,.tp-footer{padding-top:10px;padding-bottom:10px}
}
