/* Dentigram Rx Pro — compact mobile-first prescription workflow */
body.rxp-open { overflow: hidden !important; }
.rxp-overlay { position: fixed; inset: 0; z-index: 30000; display: none; background: rgba(7,24,32,.66); backdrop-filter: blur(5px); }
.rxp-overlay.open { display: block; }
.rxp-shell { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto; background: #f3f7f8; color: #122430; direction: rtl; }
body[dir="ltr"] .rxp-shell, html[dir="ltr"] .rxp-shell { direction: ltr; }
.rxp-head { z-index: 3; display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; min-height: 76px; padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); background: #fff; border-bottom: 1px solid #dfe9ec; box-shadow: 0 2px 12px rgba(12,47,60,.08); }
.rxp-icon-btn { width: 44px; height: 44px; border: 1px solid #d8e3e7; border-radius: 14px; background: #f7fafb; color: #243b45; font-size: 27px; line-height: 1; cursor: pointer; }
.rxp-head-copy { min-width: 0; }
.rxp-eyebrow { display: block; color: var(--teal-600,#0e7490); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.rxp-head h2 { margin: 1px 0 0; font-size: clamp(19px,4.5vw,25px); line-height: 1.25; }
.rxp-head p { margin: 3px 0 0; color: #667a83; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rxp-status { align-self: center; padding: 6px 10px; border-radius: 999px; background: #e3f5f2; color: #087569; font-size: 11px; font-weight: 800; }
.rxp-main { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px 14px 130px; scroll-padding-top: 16px; }
.rxp-workspace { width: min(100%, 980px); margin: 0 auto; display: grid; gap: 14px; }
.rxp-panel { background: #fff; border: 1px solid #dfe8eb; border-radius: 20px; padding: 16px; box-shadow: 0 5px 18px rgba(13,49,62,.055); scroll-margin-top: 14px; }
.rxp-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.rxp-section-head > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.rxp-section-head h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.rxp-section-head > small { color: #71848c; font-size: 11px; line-height: 1.5; text-align: end; }
.rxp-step { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 12px; background: #e4f4f2; color: #087a70; font-weight: 900; }
.rxp-linked { background: #ecfdf3; color: #047857; border: 1px solid #b7ebcf; border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 800; }
.rxp-context-grid, .rxp-med-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; }
.rxp-span-2 { grid-column: 1 / -1; }
.rxp-field { display: grid; gap: 6px; min-width: 0; }
.rxp-field > span { color: #465d67; font-size: 11px; font-weight: 800; }
.rxp-field input, .rxp-field select, .rxp-field textarea { width: 100%; min-height: 46px; box-sizing: border-box; border: 1.5px solid #d8e3e7; border-radius: 13px; background: #fff; color: #142c36; padding: 10px 12px; font: 600 13px/1.5 inherit; outline: none; transition: border-color .18s, box-shadow .18s; }
.rxp-field textarea { resize: vertical; min-height: 104px; }
.rxp-field input:focus, .rxp-field select:focus, .rxp-field textarea:focus, .rxp-search input:focus { border-color: var(--teal-600,#0e7490); box-shadow: 0 0 0 3px rgba(14,116,144,.12); }
.rxp-field select:disabled { background: #eef4f5; color: #304a54; opacity: 1; }
.rxp-context-note { border-radius: 12px; background: #f5f8f9; padding: 9px 11px; color: #4b626b; font-size: 12px; }
.rxp-alert { display: grid; gap: 3px; border: 1px solid #f1c2be; border-radius: 13px; background: #fff7f6; color: #8d332c; padding: 10px 12px; font-size: 12px; }
.rxp-favorites { display: grid; gap: 8px; }
.rxp-favorite-card { display: grid; grid-template-columns: 1fr 42px; align-items: stretch; gap: 6px; border: 1px solid #d9e6e7; border-radius: 14px; padding: 5px; background: #fbfdfd; }
.rxp-fav-use { min-width: 0; display: grid; gap: 3px; text-align: start; border: 0; background: transparent; padding: 8px; color: inherit; cursor: pointer; }
.rxp-fav-use b { font-size: 13px; }
.rxp-fav-use span { color: #627780; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rxp-fav-delete { border: 0; border-radius: 10px; background: #fff0ef; color: #bb3d34; font-size: 21px; cursor: pointer; }
.rxp-replace-banner { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin-bottom: 12px; padding: 11px 12px; border: 1px solid #e6bd66; border-radius: 14px; background: #fff8e7; color: #6f4b08; }
.rxp-replace-banner div { display: grid; gap: 2px; }
.rxp-replace-banner b { font-size: 13px; }
.rxp-replace-banner span { font-size: 11px; line-height: 1.55; }
.rxp-replace-banner button { min-height: 40px; border: 1px solid #d8ad54; border-radius: 11px; background: #fff; color: #71500c; font: 800 12px inherit; padding: 0 12px; cursor: pointer; }
.rxp-library-tools { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.rxp-search { position: relative; min-width: 0; }
.rxp-search > span { position: absolute; inset-inline-start: 13px; top: 9px; color: #607780; font-size: 23px; pointer-events: none; }
.rxp-search input { width: 100%; min-height: 46px; box-sizing: border-box; border: 1.5px solid #d8e3e7; border-radius: 13px; padding: 10px 42px 10px 12px; font: 600 13px inherit; outline: none; }
.rxp-categories { display: flex; gap: 7px; overflow-x: auto; padding: 10px 0 8px; scrollbar-width: none; }
.rxp-categories::-webkit-scrollbar { display: none; }
.rxp-categories button { flex: 0 0 auto; min-height: 38px; border: 1px solid #d7e2e5; border-radius: 999px; background: #fff; color: #536a73; padding: 0 13px; font: 800 11px inherit; cursor: pointer; }
.rxp-categories button.active { border-color: var(--teal-600,#0e7490); background: var(--teal-600,#0e7490); color: #fff; }
.rxp-catalog { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.rxp-catalog-card { position: relative; min-width: 0; min-height: 112px; display: grid; align-content: start; gap: 4px; border: 1.5px solid #dce6e9; border-radius: 15px; background: #fff; color: #1b343e; text-align: start; padding: 13px; cursor: pointer; overflow: hidden; }
.rxp-catalog-card:hover, .rxp-catalog-card:focus-visible { border-color: var(--teal-600,#0e7490); box-shadow: 0 4px 14px rgba(14,116,144,.12); }
.rxp-catalog-card b { padding-inline-end: 55px; font-size: 13px; line-height: 1.45; }
.rxp-catalog-card small, .rxp-catalog-card span { color: #637881; font-size: 10.5px; line-height: 1.45; }
.rxp-catalog-card i { color: #087a70; font-size: 9.5px; font-style: normal; font-weight: 800; }
.rxp-catalog-card .rxp-catalog-add { position: absolute; inset-block-start: 9px; inset-inline-end: 9px; color: #087a70; background: #e6f5f2; border-radius: 999px; padding: 4px 7px; font-weight: 900; }
.rxp-regimen-list { display: grid; gap: 12px; }
.rxp-med-card { border: 1.5px solid #dce6e9; border-radius: 17px; padding: 13px; background: #fff; scroll-margin-top: 14px; }
.rxp-med-card.incomplete { border-color: #e9cf8e; }
.rxp-med-head { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; margin-bottom: 12px; }
.rxp-med-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; background: #e4f4f2; color: #087a70; font-weight: 900; }
.rxp-med-head h4 { margin: 0; font-size: 14px; line-height: 1.4; }
.rxp-med-head p { margin: 1px 0 0; color: #6e8088; font-size: 10.5px; }
.rxp-med-tools { display: flex; align-items: center; gap: 5px; }
.rxp-med-tools button { min-height: 38px; border: 1px solid #d9e4e7; border-radius: 11px; background: #f8fbfb; color: #39535d; padding: 0 9px; font: 800 10.5px inherit; cursor: pointer; white-space: nowrap; }
.rxp-med-tools button.danger { width: 38px; padding: 0; background: #fff3f2; color: #bd3c33; border-color: #f0d1cf; font-size: 20px; }
.rxp-quantity { display: grid; grid-template-columns: minmax(0,1fr) minmax(78px,.65fr); gap: 6px; }
.rxp-review-note, .rxp-incomplete-note { margin: -2px 0 11px; border-radius: 10px; padding: 8px 10px; font-size: 10.5px; line-height: 1.55; }
.rxp-review-note { background: #fff5da; color: #76520d; }
.rxp-incomplete-note { margin: 10px 0 0; background: #fff9eb; color: #72571d; }
.rxp-empty { grid-column: 1 / -1; min-height: 104px; display: grid; place-content: center; justify-items: center; gap: 5px; border: 1.5px dashed #cad9dd; border-radius: 15px; color: #60757e; text-align: center; padding: 16px; }
.rxp-empty b { font-size: 13px; }.rxp-empty span { font-size: 11px; }
.rxp-actions { z-index: 4; display: grid; grid-template-columns: auto auto auto minmax(170px,1fr); align-items: center; gap: 8px; padding: 11px max(14px,env(safe-area-inset-right)) calc(11px + env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left)); background: rgba(255,255,255,.97); border-top: 1px solid #dce6e9; box-shadow: 0 -6px 20px rgba(8,37,48,.09); }
.rxp-actions button, .rxp-secondary, .rxp-primary { min-height: 48px; border-radius: 14px; padding: 0 16px; font: 900 13px inherit; cursor: pointer; }
.rxp-secondary { border: 1.5px solid #d5e1e4; background: #fff; color: #38535d; }
.rxp-primary { border: 1.5px solid var(--teal-600,#0e7490); background: var(--teal-600,#0e7490); color: #fff; box-shadow: 0 5px 14px rgba(14,116,144,.2); }
.rxp-action-status { display: grid; min-width: 76px; line-height: 1.1; }
.rxp-action-status b { color: var(--teal-600,#0e7490); font-size: 18px; }.rxp-action-status span { color: #71838a; font-size: 9px; }

/* Professional compact A4 prescription */
.rx-print { box-sizing: border-box; min-height: 270mm; display: flex; flex-direction: column; padding: 14mm 15mm !important; color: #172b34; font-family: Tajawal,Arial,sans-serif; }
.rx-print-head { min-height: 58px; padding-bottom: 7px; }
.rx-print-mark { display: grid; justify-items: center; min-width: 54px; color: var(--rxc); }
.rx-print-mark > span { font: 900 38px/1 Georgia,serif; }.rx-print-mark > small { margin-top: 2px; font-size: 8px; letter-spacing: .05em; }
.rx-print-pt-grid { display: grid !important; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0 !important; border: 1px solid #cfdade; border-radius: 8px; overflow: hidden; margin: 7px 0 12px !important; }
.rx-print-pt-grid > div { display: grid; gap: 1px; min-width: 0; padding: 6px 8px; border-inline-end: 1px solid #dbe3e6; }
.rx-print-pt-grid > div:last-child { border-inline-end: 0; }.rx-print-pt-grid span { color: #697c84; font-size: 9px; }.rx-print-pt-grid b { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-print-section-title { margin: 1px 0 2px; color: var(--rxc); font-size: 11px; font-weight: 900; letter-spacing: .02em; }
.rx-print-meds { display: grid; gap: 0; }
.rx-print-med { display: grid !important; grid-template-columns: 25px 1fr; gap: 8px; align-items: start; min-height: 50px; padding: 7px 2px !important; border-bottom: 1px solid #dbe3e6 !important; }
.rx-print-med-no { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--rxc); color: #fff; font-size: 10px; font-weight: 900; }
.rx-print-med-body { min-width: 0; }.rx-print-med-name { font-size: 13px; font-weight: 900; }.rx-print-med-generic { margin-top: 1px; color: #687a82; font-size: 9px; }
.rx-print-regimen { display: flex; flex-wrap: wrap; gap: 4px 15px; margin-top: 4px; }.rx-print-regimen > span { display: inline-grid; grid-template-columns: auto auto; gap: 4px; align-items: baseline; }.rx-print-regimen small { color: #75868d; font-size: 8px; }.rx-print-regimen b { font-size: 10px; }
.rx-print-instructions { margin-top: 4px; color: #40545d; font-size: 9px; }
.rx-print-notes { margin-top: 10px !important; padding: 8px 10px !important; font-size: 10px !important; line-height: 1.55 !important; }
.rx-print-sign { margin-top: auto !important; padding-top: 18px; display: grid !important; grid-template-columns: 1fr 1fr; gap: 30px; align-items: end; font-size: 10px !important; }.rx-print-sign > div { display: grid; gap: 3px; }.rx-print-sign span { color: #6d7f87; }.rx-print-sign b { font-size: 11px; }.rx-sign-line i { display: block; height: 24px; border-bottom: 1px solid #6e7e85; }
.rx-foot { margin-top: 12px !important; padding-top: 6px !important; }.rx-foot-text { font-size: 10px !important; }.rx-foot-contact { font-size: 9px !important; }

body.theme-dark .rxp-shell { background: #141b1f; color: #eef5f6; }
body.theme-dark .rxp-head, body.theme-dark .rxp-panel, body.theme-dark .rxp-actions, body.theme-dark .rxp-field input, body.theme-dark .rxp-field select, body.theme-dark .rxp-field textarea, body.theme-dark .rxp-search input, body.theme-dark .rxp-catalog-card, body.theme-dark .rxp-med-card, body.theme-dark .rxp-favorite-card { background: #202a2f; color: #eef5f6; border-color: #334148; }
body.theme-dark .rxp-head p, body.theme-dark .rxp-section-head small, body.theme-dark .rxp-field > span, body.theme-dark .rxp-catalog-card small, body.theme-dark .rxp-catalog-card span { color: #aebdc2; }

@media (max-width: 680px) {
  .rxp-head { min-height: 68px; grid-template-columns: 42px 1fr auto; padding-block: 9px; gap: 9px; }.rxp-icon-btn { width: 40px; height: 40px; border-radius: 12px; }.rxp-status { padding: 5px 8px; }
  .rxp-main { padding: 10px 8px 150px; }.rxp-workspace { gap: 10px; }.rxp-panel { padding: 13px 11px; border-radius: 16px; }.rxp-section-head { margin-bottom: 11px; }
  .rxp-context-grid, .rxp-med-grid { grid-template-columns: 1fr; gap: 9px; }.rxp-span-2 { grid-column: 1; }
  .rxp-library-tools { grid-template-columns: 1fr; }.rxp-library-tools .rxp-secondary { min-height: 44px; }
  .rxp-catalog { grid-template-columns: 1fr; }.rxp-catalog-card { min-height: 96px; }
  .rxp-med-head { grid-template-columns: 32px 1fr; align-items: start; }.rxp-med-tools { grid-column: 1 / -1; justify-content: stretch; }.rxp-med-tools button { flex: 1; min-height: 42px; }.rxp-med-tools button.danger { flex: 0 0 42px; width: 42px; }
  .rxp-actions { grid-template-columns: 1fr 1fr; gap: 7px; }.rxp-action-status { display: none; }.rxp-actions button { min-height: 50px; padding: 0 10px; }.rxp-actions .rxp-primary { grid-column: 1 / -1; grid-row: 1; }.rxp-actions .rxp-print-btn { grid-column: 1; }.rxp-actions [data-rxp="close"] { grid-column: 2; }
}
@media (max-width: 390px) { .rxp-med-tools button span { display: none; }.rxp-head p { max-width: 210px; } }
@media print {
  .rxp-overlay { display: none !important; }
  .rx-print { width: 210mm; min-height: 297mm; margin: 0; box-shadow: none !important; page-break-after: avoid; }
}
@media (prefers-reduced-motion: reduce) { .rxp-overlay *, .rxp-overlay *::before, .rxp-overlay *::after { scroll-behavior: auto !important; transition: none !important; } }
