/* Pharmacy portal. Uses the shared tokens in static/css/tokens.css. Classes are prefixed px-. */
body.px { margin: 0; background: var(--dp-bg); color: var(--dp-ink); font-family: var(--dp-font); font-size: 15px; line-height: 1.5; }
.px *, .px *::before, .px *::after { box-sizing: border-box; }
.px h1, .px h2, .px h3, .px p, .px ul, .px ol { margin: 0; }
.px ul, .px ol { padding: 0; list-style: none; }
.px a { color: inherit; }
.px .icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.px :focus-visible { outline: 3px solid var(--dp-primary); outline-offset: 2px; border-radius: 6px; }
.px-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

/* Layout */
.px-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.px-nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.px-sidebar { background: var(--dp-band); color: var(--dp-on-dark); display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.px-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; text-decoration: none; color: #fff; }
.px-brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--dp-primary); color: #fff; }
.px-brand-mark .icon { width: 24px; height: 24px; stroke-width: 2.6; }
.px-brand strong { display: block; font-size: 16px; line-height: 1.2; }
.px-brand strong span { font-weight: 600; color: var(--dp-on-dark); }
.px-brand small { display: block; font-size: 12px; color: var(--dp-on-dark); }
.px-menu { display: grid; gap: 2px; }
.px-menu a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 10px; color: var(--dp-on-dark); text-decoration: none; font-weight: 600; }
.px-menu a:hover { background: rgba(255,255,255,.08); color: #fff; }
.px-menu a[aria-current="page"] { background: var(--dp-primary); color: #fff; }
.px-menu .px-count { margin-left: auto; min-width: 22px; padding: 0 7px; height: 22px; display: inline-grid; place-items: center; border-radius: 999px; background: #FEF3C7; color: #92400E; font-size: 12px; font-weight: 800; }
.px-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.14); }
.px-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--dp-primary-soft); color: var(--dp-primary-hover); font-weight: 800; font-size: 14px; flex: none; }
.px-user strong { display: block; color: #fff; font-size: 14px; line-height: 1.2; }
.px-user small { color: var(--dp-on-dark); font-size: 12px; }
.px-user form { margin-left: auto; }
.px-icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; position: relative; text-decoration: none; }
.px-sidebar .px-icon-btn { color: var(--dp-on-dark); }
.px-icon-btn:hover { background: rgba(15, 42, 36, .08); }
.px-sidebar .px-icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.px-main { min-width: 0; display: flex; flex-direction: column; }
.px-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 28px; background: var(--dp-surface); border-bottom: 1px solid var(--dp-border); }
.px-menu-btn { display: none; }
.px-title h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.px-title p { color: var(--dp-muted); font-size: 13px; }
.px-search { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: 0 1 340px; min-width: 200px; background: var(--dp-bg); border: 1px solid var(--dp-border); border-radius: 10px; padding: 0 6px 0 12px; }
.px-search:focus-within { border-color: var(--dp-primary); box-shadow: 0 0 0 3px var(--dp-primary-soft); }
.px-search input { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; font: inherit; color: var(--dp-ink); }
.px-search input:focus { outline: none; }
.px-search .icon { color: var(--dp-muted); }
.px-bell .px-dot { position: absolute; top: 9px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: #DC2626; border: 2px solid #fff; }
.px-content { padding: 24px 28px 56px; display: grid; gap: 24px; align-content: start; max-width: 1400px; width: 100%; }

/* Toasts */
.px-toasts { position: fixed; right: 20px; top: 20px; z-index: 50; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.px-toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--dp-border); border-left: 4px solid var(--dp-primary); box-shadow: 0 10px 30px rgba(15,42,36,.15); animation: px-fade 7s forwards; }
.px-toast.is-error { border-left-color: #DC2626; }
.px-toast p { flex: 1; font-weight: 600; font-size: 14px; word-break: break-word; }
.px-toast button { border: 0; background: none; cursor: pointer; width: 32px; height: 32px; color: var(--dp-muted); border-radius: 8px; }
@keyframes px-fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* Buttons and form controls */
.px-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 18px; border: 1px solid transparent; border-radius: 10px; font: inherit; font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.px-btn-primary { background: var(--dp-primary); color: #fff; }
.px-btn-primary:hover { background: var(--dp-primary-hover); }
.px-btn-outline { background: #fff; border-color: var(--dp-border); color: var(--dp-ink); }
.px-btn-outline:hover { background: var(--dp-primary-soft); border-color: var(--dp-primary); }
.px-btn-danger { background: #fff; border-color: #FECACA; color: #991B1B; }
.px-btn-danger:hover { background: #FEE2E2; }
.px-btn-sm { min-height: 44px; padding: 6px 14px; }
.px-btn[disabled] { opacity: .55; cursor: not-allowed; }
.px-field { display: grid; gap: 6px; }
.px-field label { font-size: 13px; font-weight: 700; }
.px-field input, .px-field select, .px-field textarea { font: inherit; min-height: 44px; padding: 8px 12px; border: 1px solid var(--dp-border); border-radius: 10px; background: #fff; color: var(--dp-ink); width: 100%; }
.px-field input:focus, .px-field select:focus, .px-field textarea:focus { outline: 3px solid var(--dp-primary-soft); border-color: var(--dp-primary); }
.px-field .px-error { color: #991B1B; font-weight: 600; font-size: 13px; }
.px-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.px-check input { width: 20px; height: 20px; accent-color: var(--dp-primary); }

/* Cards */
.px-card { background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: 16px; padding: 20px; }
.px-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.px-card-head h2 { font-size: 17px; font-weight: 800; }
.px-link { color: var(--dp-primary); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.px-link:hover { text-decoration: underline; }
.px-empty { padding: 28px 12px; text-align: center; color: var(--dp-muted); display: grid; gap: 10px; justify-items: center; }
.px-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.px-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.px-kpi { display: grid; gap: 6px; text-decoration: none; }
.px-kpi:hover { border-color: var(--dp-primary); }
.px-kpi-label { color: var(--dp-muted); font-size: 13px; font-weight: 700; }
.px-kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.px-kpi-note { font-size: 13px; color: var(--dp-muted); }
.px-up { color: #0A5139; font-weight: 700; }
.px-down { color: #991B1B; font-weight: 700; }

/* Pills */
.px-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-new { background: var(--pill-new-bg); color: var(--pill-new-fg); }
.pill-info { background: var(--pill-info-bg); color: var(--pill-info-fg); }
.pill-preparing { background: var(--pill-preparing-bg); color: var(--pill-preparing-fg); }
.pill-ok { background: var(--pill-ok-bg); color: var(--pill-ok-fg); }
.pill-done { background: var(--pill-done-bg); color: var(--pill-done-fg); }
.pill-bad { background: var(--pill-bad-bg); color: var(--pill-bad-fg); }

/* Tables */
.px-table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.px-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.px-table th { text-align: left; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--dp-muted); padding: 10px 12px; border-bottom: 1px solid var(--dp-border); white-space: nowrap; }
.px-table td { padding: 12px; border-bottom: 1px solid var(--dp-border); vertical-align: middle; }
.px-table tr:last-child td { border-bottom: 0; }
.px-table small { display: block; color: var(--dp-muted); font-size: 12px; }
.px-table .num { text-align: right; white-space: nowrap; }
.px-table input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--dp-primary); }

/* Tabs, filters, pagination */
.px-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.px-tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px; border-radius: 10px; text-decoration: none; font-weight: 700; color: var(--dp-muted); background: #fff; border: 1px solid var(--dp-border); }
.px-tabs a:hover { border-color: var(--dp-primary); color: var(--dp-ink); }
.px-tabs a[aria-current="page"] { background: var(--dp-band); border-color: var(--dp-band); color: #fff; }
.px-tabs .px-tab-count { font-size: 12px; background: rgba(15,42,36,.08); border-radius: 999px; padding: 1px 8px; }
.px-tabs a[aria-current="page"] .px-tab-count { background: rgba(255,255,255,.2); }
.px-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.px-filters .px-field { min-width: 150px; }
.px-filters .px-field.grow { flex: 1 1 240px; }
.px-bulk { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--dp-primary-soft); }
.px-pager { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 16px; color: var(--dp-muted); font-size: 14px; }
.px-pager div { display: flex; gap: 8px; }

/* Order detail */
.px-detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.px-dl { display: grid; gap: 10px; }
.px-dl > div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px dashed var(--dp-border); padding-bottom: 8px; }
.px-dl dt { color: var(--dp-muted); font-weight: 600; }
.px-dl dd { margin: 0; text-align: right; font-weight: 700; }
.px-total td { font-weight: 800; font-size: 16px; }
.px-timeline { display: grid; gap: 0; }
.px-timeline li { position: relative; padding: 0 0 18px 28px; }
.px-timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--dp-primary); }
.px-timeline li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--dp-border); }
.px-timeline li:last-child::after { display: none; }
.px-timeline small { color: var(--dp-muted); display: block; }
.px-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.px-actions form { margin: 0; }
.px-stack { display: grid; gap: 14px; }
.px-reason { padding: 10px 14px; border-radius: 10px; background: var(--pill-info-bg); color: var(--pill-info-fg); font-weight: 600; font-size: 14px; }

/* Charts and bars */
.px-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 200px; padding-top: 8px; }
.px-bar-col { display: grid; grid-template-rows: 1fr auto auto; gap: 6px; height: 100%; text-align: center; font-size: 12px; color: var(--dp-muted); }
.px-bar-track { display: flex; align-items: end; }
.px-bar { width: 100%; min-height: 4px; background: #BFD9CC; border-radius: 8px 8px 0 0; }
.px-bar-col.is-today .px-bar { background: var(--dp-primary); }
.px-bar-col.is-today { color: var(--dp-ink); font-weight: 800; }
.px-meter { height: 8px; border-radius: 99px; background: var(--dp-primary-soft); overflow: hidden; }
.px-meter span { display: block; height: 100%; background: var(--dp-primary); border-radius: 99px; }
.px-meter.is-low span { background: #D97706; }
.px-list { display: grid; gap: 14px; }
.px-list li { display: grid; gap: 6px; }
.px-list-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }

/* Sign-in */
.px-login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--dp-bg); }
.px-login-panel { background: var(--dp-band); color: #fff; padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.px-login-panel h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 800; line-height: 1.1; }
.px-login-panel li { display: flex; align-items: center; gap: 12px; color: var(--dp-on-dark); font-weight: 600; }
.px-login-panel li .icon { color: #8FD3B5; }
.px-login-panel .px-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: 13px; font-weight: 700; }
.px-login-panel p { color: var(--dp-on-dark); }
.px-login-form { display: grid; place-items: center; padding: clamp(24px, 5vw, 56px); }
.px-login-form form { width: min(420px, 100%); display: grid; gap: 18px; }
.px-login-form h2 { font-size: 26px; font-weight: 800; }
.px-form-error { padding: 10px 14px; border-radius: 10px; background: var(--pill-bad-bg); color: var(--pill-bad-fg); font-weight: 600; }
.px-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

@media (max-width: 1100px) { .px-detail { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .px-shell { grid-template-columns: 1fr; }
  .px-sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  .px-nav-toggle:checked ~ .px-sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(15,42,36,.45); }
  .px-nav-toggle:focus-visible ~ .px-main .px-menu-btn { outline: 3px solid var(--dp-primary); }
  .px-menu-btn { display: inline-grid; }
  .px-topbar { padding: 12px 16px; }
  .px-search { margin-left: 0; flex-basis: 100%; }
  .px-content { padding: 16px 16px 48px; }
  .px-login { grid-template-columns: 1fr; }
  .px-login-panel { padding: 32px 24px; }
}
@media print {
  .px-sidebar, .px-topbar, .px-toasts, .no-print { display: none !important; }
  .px-shell { display: block; }
  body.px { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { .px-sidebar { transition: none; } .px-toast { animation: none; } }

/* Forms, product cells and small helpers */
.px-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.px-form-grid .px-wide { grid-column: 1 / -1; }
.px-help { color: var(--dp-muted); font-size: 12px; }
.px-prod { display: flex; align-items: center; gap: 12px; }
.px-thumb { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; overflow: hidden; background: var(--dp-primary-soft); color: var(--dp-primary); flex: none; }
.px-thumb img { width: 100%; height: 100%; object-fit: cover; }
.px-expiry.bad { color: #991B1B; font-weight: 800; }
.px-expiry.warn { color: #92400E; font-weight: 800; }
.px-narrow { width: 90px !important; }
.px-inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.px-inline-form input, .px-inline-form select, .px-table td input:not([type=checkbox]) { min-height: 44px; padding: 6px 10px; border: 1px solid var(--dp-border); border-radius: 10px; font: inherit; background: #fff; }
.px-table td .px-meter { min-width: 90px; margin-bottom: 4px; }
.px-selected { border-color: var(--dp-primary); box-shadow: 0 0 0 2px var(--dp-primary-soft); }
.px-kpis > li { list-style: none; display: contents; }
.px-kpis > li > .px-kpi { height: 100%; }

/* Link-styled buttons: beat ".px a { color: inherit }" so "Add medicine", "Receive stock" etc. stay readable. */
.px a.px-btn-primary { color: #fff; }
.px a.px-btn-outline { color: var(--dp-ink); }
.px a.px-btn-danger { color: #991B1B; }

/* Prescription review cards */
.px-rx-list { display: grid; gap: 16px; }
.px-rx { display: grid; grid-template-columns: 160px minmax(0, 1fr) minmax(260px, 320px); gap: 20px; align-items: start; }
.px-rx-preview { display: grid; place-items: center; width: 160px; height: 200px; border-radius: 12px; border: 1px solid var(--dp-border); background: var(--dp-bg); overflow: hidden; color: var(--dp-muted); text-decoration: none; font-size: 13px; font-weight: 700; text-align: center; }
.px-rx-preview img { width: 100%; height: 100%; object-fit: cover; }
.px-rx-preview .icon { width: 40px; height: 40px; }
.px-rx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.px-rx-head h3 { font-size: 18px; font-weight: 800; white-space: nowrap; }
.px-rx-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.px-rx-facts dt { color: var(--dp-muted); font-weight: 600; }
.px-rx-facts dd { margin: 0; }
.px-rx-actions { display: grid; gap: 10px; }
.px-rx-actions label { font-size: 13px; font-weight: 700; }
.px-rx-actions textarea { font: inherit; font-size: 14px; min-height: 72px; padding: 8px 10px; border: 1px solid var(--dp-border); border-radius: 10px; resize: vertical; }
.px-rx-actions .px-rx-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.px-rx-actions .px-rx-buttons .px-btn { flex: 1 1 120px; }
@media (max-width: 1100px) { .px-rx { grid-template-columns: 140px minmax(0, 1fr); } .px-rx-actions { grid-column: 1 / -1; } .px-rx-preview { width: 140px; height: 180px; } }
@media (max-width: 560px) { .px-rx { grid-template-columns: 1fr; } .px-rx-preview { width: 100%; height: 220px; } }
.px-rx-facts a.px-link { display: inline; min-height: 0; padding: 0; font-weight: 700; }
.px-rx-checks { margin: 0; padding: 0; border: 0; display: grid; gap: 4px; }
.px-rx-checks legend { font-size: 13px; font-weight: 700; margin-bottom: 4px; padding: 0; }
.px-rx-checks label { display: flex; gap: 10px; align-items: flex-start; min-height: 32px; font-size: 13px !important; font-weight: 500 !important; line-height: 1.4; cursor: pointer; }
.px-rx-checks input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--dp-primary); flex: none; }
.px-kpi.is-attention { border-color: #C7D2FE; box-shadow: inset 0 0 0 1px #C7D2FE; }
