/* Bag lookup: the page (.bl-page), the shared result renderer
   (.bl-result-root, also inside the Monthly bag sheet) and the bag sheet
   frame (.bl-sheet-root). Rules sit under :where(root), zero specificity. */

/* ---------- page ---------- */
:where(.bl-page) { --px-scan-accent: var(--ch-accent-primary); padding: var(--ch-space-lg); font-family: var(--ch-font-primary); color: var(--ch-text-primary); }
:where(.bl-page) .bl-wrap { max-width: 780px; margin: 0 auto; }
:where(.bl-page) .bl-title { font-size: 28px; font-weight: 600; margin: 0 0 4px; }
:where(.bl-page) .bl-sub { color: var(--ch-text-secondary); font-size: 14px; margin: 0 0 var(--ch-space-lg); }
:where(.bl-page) .bl-scanrow { display: flex; gap: 8px; align-items: flex-start; }
:where(.bl-page) .bl-scanbox { flex: 1; }
:where(.bl-page) .bl-find, :where(.bl-page) .bl-cam { min-height: 54px; margin-top: 16px; }
:where(.bl-page) .bl-cam { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: var(--ch-radius-md); background: var(--ch-accent-primary); color: var(--px-ink-on-bright); font: inherit; font-weight: 600; font-size: 15px; padding: 0 18px; cursor: pointer; white-space: nowrap; }
:where(.bl-page) .bl-cam:hover { background: var(--ch-accent-primary-hover); }
:where(.bl-page) .bl-cam svg { width: 22px; height: 22px; }
:where(.bl-page) .bl-results-slot { margin-top: var(--ch-space-lg); }
:where(.bl-page) .bl-camview { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: var(--px-z-camera); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; padding: 20px; text-align: center; }
:where(.bl-page) .bl-camview[hidden] { display: none; }
:where(.bl-page) .bl-camview-scanner { width: min(420px, 90vw); }
@media (max-width: 768px) {
  :where(.bl-page) .bl-scanrow { flex-wrap: wrap; }
  :where(.bl-page) .bl-scanbox { flex-basis: 100%; }
  :where(.bl-page) .bl-find, :where(.bl-page) .bl-cam { margin-top: 0; }
  :where(.bl-page) .bl-cam { padding: 10px 18px; }
}

/* ---------- buttons (page, results, sheet) ---------- */
:where(.bl-page, .bl-result-root, .bl-sheet-root) .bl-btn { font: inherit; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: var(--ch-radius-md); border: 1px solid var(--ch-border); background: var(--ch-bg-card); color: var(--ch-text-primary); cursor: pointer; }
:where(.bl-page, .bl-result-root, .bl-sheet-root) .bl-btn:hover { background: var(--ch-bg-hover); }
:where(.bl-page, .bl-result-root) .bl-btn.primary { background: var(--ch-text-primary); color: var(--ch-bg-card); border-color: var(--ch-text-primary); }
:where(.bl-page, .bl-result-root) .bl-btn.primary:hover { background: var(--ch-text-secondary); border-color: var(--ch-text-secondary); }

/* ---------- result renderer ---------- */
:where(.bl-result-root) .bl-results { display: flex; flex-direction: column; gap: 14px; outline: none; }
:where(.bl-result-root) .bl-msg { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--ch-radius-md); border: 1px solid var(--ch-border); background: var(--ch-bg-card); font-size: 15px; }
:where(.bl-result-root) .bl-msg.warn { background: var(--ch-warning-bg); border-color: var(--ch-warning-border); }
:where(.bl-result-root) .bl-msg.err { background: var(--ch-danger-bg); border-color: var(--ch-danger-border); color: var(--ch-danger-text); }
:where(.bl-result-root) .bl-msg.info { background: var(--ch-info-bg); border-color: var(--ch-info-border); }
:where(.bl-result-root) .bl-msg > .material-symbols-outlined { flex: 0 0 auto; }
:where(.bl-result-root) .bl-msg .bl-btn { margin-top: 8px; }
:where(.bl-result-root) .bl-msg > div { flex: 1; min-width: 0; }
:where(.bl-result-root) .bl-skel { height: 18px; margin: 10px 0; }
:where(.bl-result-root) .bl-skel-short { width: 70%; }
:where(.bl-result-root) .bl-both { font-size: 14px; }
:where(.bl-result-root) .bl-kind { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ch-text-muted); }
:where(.bl-result-root) .bl-sectionlabel { margin: 8px 0 -4px; }
:where(.bl-result-root) .bl-head { background: var(--ch-bg-card); border: 1px solid var(--ch-border); border-radius: var(--ch-radius-lg); padding: 14px 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
:where(.bl-result-root) .bl-id { font-size: 26px; font-weight: 700; letter-spacing: .3px; overflow-wrap: anywhere; }
:where(.bl-result-root) .bl-home { font-size: 15px; font-weight: 600; text-align: right; }
:where(.bl-result-root) .bl-count { font-size: 12px; color: var(--ch-text-secondary); text-align: right; }
:where(.bl-result-root) .bl-sent { display: block; color: var(--ch-text-primary); font-weight: 600; margin-bottom: 2px; }
:where(.bl-result-root) .bl-chip-deact { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 6px; border-radius: var(--ch-radius-full); background: var(--ch-warning-bg); color: var(--px-warning-text); vertical-align: middle; margin-left: 6px; }
:where(.bl-result-root) .bl-card { background: var(--ch-bg-card); border: 1px solid var(--ch-border); border-left: 4px solid var(--ch-accent-primary); border-radius: var(--ch-radius-lg); padding: 14px 18px; box-shadow: var(--ch-shadow-sm); }
:where(.bl-result-root) .bl-card.home-only { border-left-color: var(--ch-text-muted); }
:where(.bl-result-root) .bl-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; }
:where(.bl-result-root) .bl-res { font-size: 17px; font-weight: 700; }
:where(.bl-result-root) .bl-dob { font-weight: 400; font-size: 13px; color: var(--ch-text-muted); margin-left: 6px; }
:where(.bl-result-root) .bl-bags { font-size: 13px; font-weight: 600; color: var(--ch-text-secondary); }
:where(.bl-result-root) .bl-gwhere { display: inline-block; margin-left: 10px; font-weight: 400; color: var(--ch-text-secondary); }
:where(.bl-result-root) .bl-self { font-weight: 700; color: var(--ch-text-primary); }
:where(.bl-result-root) .bl-num { background: none; border: 0; padding: 0; font: inherit; color: var(--ch-accent-primary-text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
:where(.bl-result-root) .bl-num:hover { color: var(--ch-text-primary); }
:where(.bl-result-root) .bl-setnote { font-size: 13px; line-height: 1.45; background: var(--ch-accent-secondary); border-radius: var(--ch-radius-md); padding: 10px 12px; color: var(--ch-text-primary); margin-bottom: 10px; }
:where(.bl-result-root) .bl-where { margin-top: 4px; color: var(--ch-text-secondary); font-size: 12px; }
:where(.bl-result-root) .bl-med { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 9px 0; border-top: 1px solid var(--ch-border); }
:where(.bl-result-root) .bl-med:first-of-type { border-top: 0; }
:where(.bl-result-root) .bl-med-name { font-weight: 600; font-size: 14px; }
:where(.bl-result-root) .bl-med-qty { font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }
:where(.bl-result-root) .bl-med-instr { font-size: 13px; color: var(--ch-text-secondary); }
:where(.bl-result-root) .bl-med-rx { font-size: 12px; color: var(--ch-text-muted); text-align: right; white-space: nowrap; }
:where(.bl-result-root) .bl-hl { background: #fef9c3; margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 6px; }
:where(.bl-result-root) .bl-hltag { display: inline-block; margin-left: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 6px; border-radius: var(--ch-radius-full); background: #facc15; color: #422006; vertical-align: middle; }
[data-theme="dark"] :where(.bl-result-root) .bl-hl { background: rgba(250, 204, 21, .16); }
:where(.bl-result-root) .bl-hl .bl-med-rx { color: var(--ch-text-secondary); }
:where(.bl-result-root) .bl-bagnote { font-size: 13px; margin: 2px 0 4px; }
:where(.bl-result-root) .bl-bagnote b { font-weight: 600; }
:where(.bl-result-root) .bl-empty { color: var(--ch-text-secondary); font-style: italic; padding: 8px 0; }
:where(.bl-result-root) .bl-result-actions { display: flex; justify-content: center; padding: 18px 0 8px; }

/* ---------- bag sheet frame ---------- */
:where(.bl-sheet-root) .bl-panel-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: calc(var(--ch-z-overlay) + 10); }
:where(.bl-sheet-root) .bl-panel { position: fixed; top: 0; right: var(--pa-drawer-inset); bottom: 0; width: min(580px, calc(100vw - var(--pa-drawer-inset))); background: var(--ch-bg-primary); box-shadow: -8px 0 30px rgba(0, 0, 0, .18); z-index: calc(var(--ch-z-overlay) + 11); overflow-y: auto; font-family: var(--ch-font-primary); color: var(--ch-text-primary); border-top: var(--pa-callbar-inset) solid var(--ch-bg-card); }
:where(.bl-sheet-root) .bl-panel-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; background: var(--ch-bg-card); border-bottom: 1px solid var(--ch-border); }
:where(.bl-sheet-root) .bl-panel-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; outline: none; }
:where(.bl-sheet-root) .bl-panel-btn { border: 0; background: none; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; color: var(--ch-text-primary); display: inline-flex; align-items: center; justify-content: center; }
:where(.bl-sheet-root) .bl-panel-btn[hidden] { display: none; }
:where(.bl-sheet-root) .bl-panel-btn:hover { background: var(--ch-bg-hover); }
:where(.bl-sheet-root) .bl-panel-body { padding: 16px 18px 40px; }
