/* Clinical tools (pages/tools.js, js/tools/*): hub, dose calculator, protocol library, reports, converter. Uses app.css tokens. */
:root { --tl-warn: #8a6d00; --tl-warn-bg: #fff3cd; --tl-bad: #b03a2e; --tl-bad-bg: #fde2df; --tl-ok: #1e7a45; --tl-ok-bg: #dcefe3; --tl-info-bg: #eef7fc; }
.tl-head-sub { color: var(--text-2); font-size: 13px; }
.tl-tabs a { white-space: nowrap; }
.tl-dim { color: var(--text-2); font-size: 13px; }
.tl-grow { flex: 1; }
.tl-note, .tl-ref { display: flex; gap: 10px; align-items: flex-start; background: var(--tl-info-bg); border-left: 4px solid var(--blue); padding: 10px 14px; margin: 12px 0; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.tl-note > .ico, .tl-ref > .ico { color: var(--blue); flex: none; width: 18px; height: 18px; }
.tl-ref { padding: 6px 10px; margin: 8px 0; font-size: 12px; }
.tl-ref-top { background: var(--tl-warn-bg); border-left-color: var(--yellow); color: var(--tl-warn); font-size: 13px; padding: 10px 14px; }
.tl-ref-top > .ico { color: var(--tl-warn); }
.tl-badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; background: #e0e6eb; color: var(--text-2); margin-left: 6px; vertical-align: 1px; }
.tl-badge.warn { background: var(--red); color: #fff; } .tl-badge.blue { background: #e3f2fb; color: #0a5f8c; } .tl-badge.green { background: var(--tl-ok-bg); color: var(--tl-ok); }
.tl-link { border: 0; background: none; color: var(--blue-link); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.tl-search { position: relative; display: flex; align-items: center; margin-bottom: 14px; }
.tl-search .ico { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.tl-search .search-input { padding-left: 38px; border-radius: 20px; }
.tl-search.grow { flex: 1; }

/* hub */
.tl-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.tl-tile { display: flex; align-items: center; gap: 16px; padding: 22px 20px; background: var(--tile); color: #fff; text-decoration: none; border-radius: 4px; min-height: 120px; transition: background .12s; }
.tl-tile:hover { background: var(--tile-hover); }
.tl-tile-icon { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .12); display: flex; align-items: center; justify-content: center; flex: none; }
.tl-tile-icon .ico { width: 28px; height: 28px; }
.tl-tile-text { flex: 1; min-width: 0; }
.tl-tile-title { font-size: 19px; font-weight: 700; }
.tl-tile-desc { font-size: 13px; opacity: .8; margin-top: 4px; line-height: 1.4; }
.tl-tile-go { width: 22px; height: 22px; opacity: .7; }

/* dose calculator */
.tl-dose-inputs { display: grid; grid-template-columns: auto auto 1fr; gap: 14px 24px; align-items: end; margin-bottom: 14px; }
.tl-dose-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.tl-dose-field.wide { min-width: 0; }
.tl-weight { display: flex; align-items: center; gap: 6px; }
.tl-weight .input { width: 90px; font-size: 18px; font-weight: 600; }
.tl-weight span { color: var(--text-2); font-size: 13px; margin-right: 6px; }
.tl-pop button { padding: 9px 16px; font-weight: 600; }
.tl-pop button.on { background: var(--navy); color: #fff; }
.tl-tape { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-tape-btn { border: 2px solid transparent; border-radius: 4px; padding: 4px 8px; min-width: 64px; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; font: inherit; line-height: 1.2; }
.tl-tape-btn.on { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(45, 62, 80, .25); }
.tl-tape-name { font-weight: 700; font-size: 12px; } .tl-tape-kg { font-size: 11px; opacity: .85; }
.tape-grey { background: #9ea7ad; color: #fff; } .tape-pink { background: #f7a6c4; color: #4a1730; } .tape-red { background: #d93a33; color: #fff; }
.tape-purple { background: #7d4fa8; color: #fff; } .tape-yellow { background: #f6d43b; color: #4a3d00; } .tape-white { background: #fff; color: #333; border-color: #c4ccd3; }
.tape-blue { background: #2e7cd6; color: #fff; } .tape-orange { background: #f08a24; color: #fff; } .tape-green { background: #2fa35a; color: #fff; }
.tape-white.on { border-color: var(--navy); }
.tl-dose-toolbar { display: flex; gap: 12px; align-items: flex-start; }
.tl-dose-toolbar .tl-search { flex: 1; }
.tl-filter-note { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.tl-dose-list { display: flex; flex-direction: column; gap: 8px; }
.tl-dose-card { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 4px; background: var(--bg); }
.tl-dose-card.capped { border-left-color: var(--red); }
.tl-dose-card.open { box-shadow: 0 2px 10px rgba(20, 30, 45, .08); }
.tl-dose-card-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.tl-dose-med { flex: 1; min-width: 0; }
.tl-dose-name { font-weight: 700; color: var(--navy); }
.tl-dose-ind { font-size: 13px; color: var(--text-2); }
.tl-dose-result { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.tl-dose-num { font-size: 20px; font-weight: 700; color: var(--navy); }
.tl-dose-vol { font-size: 14px; color: var(--text-2); font-weight: 600; }
.tl-dose-none { font-size: 13px; color: var(--muted); font-style: italic; }
.tl-dose-detail { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.tl-dose-dl { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 12px 0; font-size: 14px; }
.tl-dose-dl dt { color: var(--text-2); font-weight: 600; } .tl-dose-dl dd { margin: 0; }
.tl-warn { display: flex; gap: 8px; align-items: center; background: var(--tl-bad-bg); color: var(--tl-bad); padding: 7px 10px; border-radius: 3px; font-weight: 600; font-size: 13px; margin: 6px 0; }
.tl-warn .ico { width: 16px; height: 16px; flex: none; }
.tl-dose-use { display: flex; justify-content: flex-end; }
.tl-dose-modal .modal-body { background: var(--bg-soft); }

/* rule editor */
.tl-re { display: grid; grid-template-columns: 260px 1fr; gap: 18px; min-height: 420px; }
.tl-re-side { display: flex; flex-direction: column; gap: 8px; }
.tl-re-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 4px; max-height: 55vh; overflow: auto; }
.tl-re-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); background: var(--bg); cursor: pointer; text-align: left; font: inherit; font-size: 13px; }
.tl-re-item span { color: var(--text-2); font-size: 12px; }
.tl-re-item.on { background: #e3f2fb; }
.tl-re-form label { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; }
.tl-re-form label .input { margin-top: 3px; }
.tl-re-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tl-re-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.tl-re-block { border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px 12px; margin: 0 0 10px; }
.tl-re-block legend { font-weight: 700; color: var(--navy); padding: 0 4px; }
.tl-re-notes { margin-bottom: 8px; }
.tl-re-del { display: flex; justify-content: flex-end; }

/* protocol library */
.tl-proto-toolbar { display: flex; gap: 12px; align-items: flex-start; }
.tl-cats { display: flex; flex-wrap: wrap; margin-bottom: 12px; }
.tl-proto-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tl-proto-card { display: block; border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 4px; padding: 14px 16px; background: var(--bg); text-decoration: none; color: inherit; }
.tl-proto-card:hover { border-color: var(--blue); }
.tl-proto-cat { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--blue); }
.tl-proto-title { font-weight: 700; color: var(--navy); font-size: 16px; margin: 4px 0; }
.tl-proto-excerpt { font-size: 13px; color: var(--text-2); line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tl-proto-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.tl-proto-view { max-width: 920px; }
.tl-proto-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.tl-proto-h { margin: 2px 0 4px; color: var(--navy); font-size: 26px; }
.tl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tl-tag { font-size: 12px; padding: 2px 9px; border-radius: 10px; background: #e8edf1; color: var(--text-2); }
.tl-md { line-height: 1.6; font-size: 15px; }
.tl-md h2 { font-size: 22px; color: var(--navy); margin: 18px 0 8px; } .tl-md h3 { font-size: 17px; color: var(--navy); margin: 16px 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.tl-md h4, .tl-md h5, .tl-md h6 { font-size: 15px; margin: 12px 0 4px; }
.tl-md ul, .tl-md ol { padding-left: 24px; margin: 6px 0 10px; }
.tl-md blockquote { margin: 10px 0; padding: 8px 14px; background: var(--tl-warn-bg); border-left: 4px solid var(--yellow); color: var(--tl-warn); }
.tl-md table { border-collapse: collapse; margin: 10px 0; width: 100%; max-width: 680px; }
.tl-md th, .tl-md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.tl-md th { background: var(--bg-soft); }
.tl-md code { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; font-size: 13px; }
.tl-md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.tl-pdf { border: 1px solid var(--line); border-radius: 4px; margin-top: 18px; overflow: hidden; }
.tl-pdf-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-soft); border-bottom: 1px solid var(--line); font-weight: 600; }
.tl-pdf-frame { width: 100%; height: 70vh; border: 0; display: block; }
.tl-ed-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 10px 14px; margin-bottom: 12px; }
.tl-ed-grid label { font-size: 12px; color: var(--text-2); font-weight: 600; } .tl-ed-grid .wide { grid-column: 1 / -1; }
.tl-ed-grid .input { margin-top: 3px; }
.tl-ed-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tl-ed-label { font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.tl-md-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; min-height: 360px; }
.tl-preview { border: 1px solid var(--line); border-radius: 3px; padding: 6px 14px; height: 380px; overflow: auto; background: var(--bg); font-size: 14px; }
.tl-ed-pdf { margin-top: 12px; } .tl-ed-pdf-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.tl-pdf-info { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.tl-pdf-info .ico { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.tl-hist { display: grid; grid-template-columns: 240px 1fr; gap: 18px; min-height: 360px; }
.tl-hist-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 4px; align-self: start; }
.tl-hist-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--bg); text-align: left; cursor: pointer; font: inherit; font-size: 13px; }
.tl-hist-item span { font-size: 12px; color: var(--text-2); }
.tl-hist-item.current { background: var(--bg-soft); cursor: default; }
.tl-hist-item.on { background: #e3f2fb; }
.tl-hist-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 6px; }

/* protocols shelf (chart) */
.tl-shelf .shelf-body { padding: 0; }
.tl-shelf-search { padding: 14px 18px 0; position: sticky; top: 0; background: var(--bg); z-index: 1; border-bottom: 1px solid var(--line); }
.tl-shelf-body { padding: 8px 18px 40px; }
.tl-shelf-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); margin: 14px 0 6px; }
.tl-shelf-item { display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font: inherit; color: inherit; }
.tl-shelf-item:hover { border-color: var(--blue); }
.tl-shelf-item-top { display: flex; align-items: center; }
.tl-shelf-nav { display: flex; gap: 8px; margin: 10px 0 12px; }

/* reports */
.tl-rep-tabs { margin-bottom: 12px; }
.tl-rep-tabs button { display: inline-flex; align-items: center; }
.tl-rep-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tl-eta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.tl-eta .input { width: 90px; padding: 6px 8px; }
.tl-rep-text { white-space: pre-wrap; font-family: inherit; font-size: 15px; line-height: 1.6; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 4px; padding: 16px 18px; margin: 0; }
.tl-disclaimer { font-size: 12px; color: var(--muted); margin-top: 10px; }
.tl-rep-modal .modal-body { min-height: 420px; }
.tl-rep-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.tl-rep-chart { flex: 1; color: var(--text-2); }
.tl-back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--blue-link); font-weight: 600; }
.tl-chart-list { margin-top: 4px; }
.tl-sheet { border: 1px solid var(--line); border-radius: 4px; padding: 16px 18px; background: var(--bg); }
.tl-sheet-head { border-bottom: 2px solid var(--navy); padding-bottom: 8px; margin-bottom: 12px; }
.tl-sheet-title { font-size: 20px; font-weight: 700; color: var(--navy); }
.tl-sheet-sub { color: var(--text-2); font-size: 13px; }
.tl-sheet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 20px; }
.tl-sheet-sec h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); background: var(--bg-soft); padding: 4px 8px; }
.tl-sheet-sec.wide { margin-top: 12px; }
.tl-sheet-sec dl { display: grid; grid-template-columns: 130px 1fr; gap: 3px 10px; margin: 0; font-size: 14px; }
.tl-sheet-sec dt { color: var(--text-2); } .tl-sheet-sec dd { margin: 0; font-weight: 600; }
.tl-sheet-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tl-sheet-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tl-sheet-table td.t { width: 60px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tl-sheet-narr { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }

/* outcomes page: collapsible handoff sheet */
.tl-oc-handoff { margin-top: 18px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.tl-oc-handoff > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; color: var(--navy); background: var(--bg-soft); display: flex; align-items: center; gap: 8px; }
.tl-oc-handoff[open] > summary { border-bottom: 1px solid var(--line); }
.tl-oc-handoff-body { padding: 14px 16px; }

/* unit converter */
.tl-conv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tl-conv { border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; background: var(--bg); border-top: 4px solid var(--blue); }
.tl-conv h3 { margin: 0 0 10px; font-size: 16px; color: var(--navy); }
.tl-conv-row { display: flex; align-items: center; gap: 10px; }
.tl-conv-row label { display: flex; align-items: center; gap: 6px; flex: 1; }
.tl-conv-row label span { color: var(--text-2); font-weight: 600; min-width: 28px; }
.tl-conv-row .input { font-size: 18px; }
.tl-conv-eq { font-size: 20px; color: var(--muted); }
.tl-conv-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 10px; }
.tl-conv-form label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.tl-conv-form .input { margin-top: 3px; }
.tl-conv-out { font-size: 20px; font-weight: 700; color: var(--navy); margin: 12px 0 4px; }

/* flowchart hook */
.tl-fc-dose { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; font-size: 13px; color: var(--text-2); }

@media (max-width: 900px) {
  .tl-dose-inputs { grid-template-columns: 1fr; }
  .tl-dose-dl { grid-template-columns: 120px 1fr; }
  .tl-re, .tl-hist, .tl-ed-split, .tl-ed-grid, .tl-re-grid2 { grid-template-columns: 1fr; }
  .tl-re-grid { grid-template-columns: 1fr 1fr; }
  .tl-proto-toolbar, .tl-dose-toolbar { flex-direction: column; align-items: stretch; }
}
@media print { .tl-tabs, .tl-rep-actions, .tl-rep-tabs { display: none; } }
