/* CEMR PHARMACY MODULE STYLESHEET */

/* ============================================================
   CEMR PHARMACY MODULE
   ============================================================ */

:root,
.pharmacy-viewport-page {
    --pharmacy-primary: var(--app-accent, #2a6b82);
    --pharmacy-primary-dark: var(--app-accent-dark, #205568);
    --pharmacy-primary-soft: var(--app-accent-soft, #edf6f8);
    --pharmacy-border: #e3e8ef;
    --pharmacy-background: #f6f8fb;
    --pharmacy-surface: #ffffff;
    --pharmacy-text: #1f2937;
    --pharmacy-muted: #667085;
    --pharmacy-danger: #d64545;
    --pharmacy-warning: #c97908;
    --pharmacy-success: #18875c;
}

.pharmacy-content-card {
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--pharmacy-surface);
    border: 1px solid var(--pharmacy-border);
    border-radius: 10px;
    overflow: hidden;
}

.pharmacy-content-card-header {
    flex: 0 0 auto;
    min-height: 58px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--pharmacy-border);
}

    .pharmacy-content-card-header h2 {
        margin: 0;
        color: var(--pharmacy-text);
        font-size: 14px;
        font-weight: 700;
    }

    .pharmacy-content-card-header p {
        margin: 3px 0 0;
        color: var(--pharmacy-muted);
        font-size: 11px;
    }

.pharmacy-grid-host {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.pharmacy-primary-button,
.pharmacy-secondary-button,
.pharmacy-danger-button {
    min-height: 36px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.pharmacy-primary-button {
    color: #ffffff;
    background: var(--pharmacy-primary);
    border: 1px solid var(--pharmacy-primary);
}

    .pharmacy-primary-button:hover {
        background: var(--pharmacy-primary-dark);
    }

.pharmacy-secondary-button {
    color: var(--pharmacy-text);
    background: #ffffff;
    border: 1px solid var(--pharmacy-border);
}

    .pharmacy-secondary-button:hover {
        color: var(--pharmacy-primary);
        border-color: var(--pharmacy-primary);
        background: var(--pharmacy-primary-soft);
    }

.pharmacy-danger-button {
    color: var(--pharmacy-danger);
    background: #fff5f5;
    border: 1px solid #f4cccc;
}

.pharmacy-search {
    width: min(320px, 100%);
}

.pharmacy-filter {
    width: 180px;
}

.pharmacy-date-filter {
    width: 220px;
}

.pharmacy-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.status-success {
    color: #147a50;
    background: #e8f7ef;
}

.status-warning {
    color: #a96708;
    background: #fff3dc;
}

.status-danger {
    color: #bc3c3c;
    background: #ffeded;
}

.status-info {
    color: #3e5eb6;
    background: #edf2ff;
}

.status-neutral {
    color: #596579;
    background: #edf1f5;
}

.pharmacy-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.pharmacy-icon-button {
    width: 29px;
    height: 29px;
    display: inline-grid;
    place-items: center;
    color: var(--pharmacy-primary);
    background: #ffffff;
    border: 1px solid var(--pharmacy-border);
    border-radius: 6px;
    cursor: pointer;
}

    .pharmacy-icon-button:hover {
        color: #ffffff;
        background: var(--pharmacy-primary);
        border-color: var(--pharmacy-primary);
    }

@media (max-width: 900px) {
    .pharmacy-search,
    .pharmacy-filter,
    .pharmacy-date-filter {
        flex: 1 1 200px;
        width: auto;
    }
}
.pharmacy-dispensing-layout {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 10px;
}

.pharmacy-dispensing-side {
    min-width: 0;
}

.pharmacy-patient-summary {
    flex: 0 0 auto;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 12px;
    border-bottom: 1px solid var(--pharmacy-border);
}

    .pharmacy-patient-summary div {
        min-width: 0;
    }

    .pharmacy-patient-summary span,
    .pharmacy-patient-summary strong {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .pharmacy-patient-summary span {
        color: var(--pharmacy-muted);
        font-size: 10px;
    }

    .pharmacy-patient-summary strong {
        margin-top: 3px;
        color: var(--pharmacy-text);
        font-size: 12px;
    }

.pharmacy-summary-list {
    padding: 14px;
}

    .pharmacy-summary-list > div {
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        border-bottom: 1px solid #edf0f4;
    }

    .pharmacy-summary-list span {
        color: var(--pharmacy-muted);
        font-size: 11px;
    }

    .pharmacy-summary-list strong {
        color: var(--pharmacy-text);
        font-size: 12px;
    }

    .pharmacy-summary-list .summary-total {
        margin-top: 8px;
        padding-top: 8px;
        border-bottom: 0;
    }

        .pharmacy-summary-list .summary-total span,
        .pharmacy-summary-list .summary-total strong {
            color: var(--pharmacy-primary);
            font-size: 14px;
            font-weight: 700;
        }

@media (max-width: 1100px) {
    .pharmacy-dispensing-layout {
        grid-template-columns: minmax(0, 1fr);
        overflow-y: auto;
    }

    .pharmacy-dispensing-side {
        min-height: 250px;
    }

    .pharmacy-patient-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.pharmacy-report-grid {
    height: 100%;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    align-content: start;
    gap: 12px;
}

.pharmacy-report-card {
    min-height: 105px;
    padding: 16px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: #ffffff;
    border: 1px solid var(--pharmacy-border);
    border-radius: 10px;
    cursor: pointer;
    transition: 0.18s ease;
}

    .pharmacy-report-card:hover {
        border-color: var(--pharmacy-primary);
        box-shadow: 0 6px 18px rgba(25, 40, 60, 0.08);
        transform: translateY(-2px);
    }

.pharmacy-report-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--pharmacy-primary);
    background: var(--pharmacy-primary-soft);
    border-radius: 10px;
    font-size: 21px;
}

.pharmacy-report-card strong,
.pharmacy-report-card span {
    display: block;
}

.pharmacy-report-card strong {
    color: var(--pharmacy-text);
    font-size: 13px;
}

.pharmacy-report-card span {
    margin-top: 5px;
    color: var(--pharmacy-muted);
    font-size: 11px;
}

.report-arrow {
    color: #a7b0bd;
}

@media (max-width: 1000px) {
    .pharmacy-report-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .pharmacy-report-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pharmacy-master-grid {
    height: 100%;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    align-content: start;
    gap: 12px;
}

.pharmacy-master-card {
    min-height: 96px;
    padding: 15px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: #ffffff;
    border: 1px solid var(--pharmacy-border);
    border-radius: 10px;
    cursor: pointer;
}

    .pharmacy-master-card:hover {
        border-color: var(--pharmacy-primary);
        background: #fbfdfd;
    }

.pharmacy-master-card-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--pharmacy-primary);
    background: var(--pharmacy-primary-soft);
    border-radius: 10px;
    font-size: 20px;
}

.pharmacy-master-card strong,
.pharmacy-master-card span {
    display: block;
}

.pharmacy-master-card strong {
    color: var(--pharmacy-text);
    font-size: 13px;
}

.pharmacy-master-card span {
    margin-top: 4px;
    color: var(--pharmacy-muted);
    font-size: 11px;
}

.pharmacy-master-card > i {
    color: #a8b1bd;
}

@media (max-width: 1000px) {
    .pharmacy-master-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .pharmacy-master-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================================
   BILL HISTORY PANEL
   ============================================================ */

.pharmacy-bill-history-list {
    min-height: 292px;
    padding: 4px 8px 8px;
}

.pharmacy-bill-history-item {
    min-height: 56px;
    padding: 7px 6px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #edf0f4;
}

    .pharmacy-bill-history-item:last-child {
        border-bottom: 0;
    }

    .pharmacy-bill-history-item:hover {
        background: #f8fbfc;
        border-radius: 7px;
    }

.bill-history-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--pharmacy-primary);
    background: var(--pharmacy-primary-soft);
    border-radius: 9px;
    font-size: 17px;
}

.bill-history-patient {
    min-width: 0;
}

    .bill-history-patient strong,
    .bill-history-patient span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bill-history-patient strong {
        color: var(--pharmacy-text);
        font-size: 12px;
        font-weight: 650;
    }

    .bill-history-patient span {
        margin-top: 3px;
        color: var(--pharmacy-muted);
        font-size: 9px;
    }

        .bill-history-patient span i {
            width: 3px;
            height: 3px;
            margin: 0 4px;
            display: inline-block;
            vertical-align: middle;
            background: #aab3bf;
            border-radius: 50%;
        }

.bill-history-amount {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
}

    .bill-history-amount > strong {
        color: var(--pharmacy-text);
        font-size: 11px;
    }

.bill-report-button {
    min-height: 29px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--pharmacy-primary);
    background: var(--pharmacy-primary-soft);
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

    .bill-report-button:hover {
        color: #ffffff;
        background: var(--pharmacy-primary);
    }

.bill-status-paid {
    color: #147a4d;
    background: #e5f7ee;
}

.bill-status-pending {
    color: #a76105;
    background: #fff1d7;
}

.bill-status-partial {
    color: #5a53c8;
    background: #efedff;
}

.bill-status-cancelled {
    color: #bf3434;
    background: #ffebeb;
}

/* ============================================================
   BILL DIALOG
   ============================================================ */

.bill-dialog-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bill-dialog-title-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--pharmacy-primary);
    background: var(--pharmacy-primary-soft);
    border-radius: 8px;
    font-size: 18px;
}

.bill-dialog-header strong,
.bill-dialog-header span {
    display: block;
}

.bill-dialog-header strong {
    color: var(--pharmacy-text);
    font-size: 14px;
}

.bill-dialog-header span {
    margin-top: 2px;
    color: var(--pharmacy-muted);
    font-size: 10px;
}

.pharmacy-bill-dialog-content {
    padding: 0;
}

.bill-dialog-actions {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    background: #f7f9fb;
    border-bottom: 1px solid var(--pharmacy-border);
}

.pharmacy-bill-print-area {
    margin: 14px;
    padding: 20px;
    color: #1f2937;
    background: #ffffff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
}

.bill-document-header {
    padding-bottom: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 2px solid var(--pharmacy-primary);
}

.bill-hospital-information {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bill-hospital-logo {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--pharmacy-primary);
    border-radius: 12px;
    font-size: 26px;
}

.bill-hospital-information h2 {
    margin: 0;
    color: var(--pharmacy-primary);
    font-size: 20px;
}

.bill-hospital-information p {
    margin: 3px 0;
    color: #475467;
    font-size: 11px;
}

.bill-hospital-information span {
    color: #667085;
    font-size: 9px;
}

.bill-document-number {
    text-align: right;
}

    .bill-document-number span,
    .bill-document-number strong,
    .bill-document-number small {
        display: block;
    }

    .bill-document-number span {
        color: var(--pharmacy-muted);
        font-size: 10px;
        font-weight: 700;
    }

    .bill-document-number strong {
        margin-top: 4px;
        color: var(--pharmacy-text);
        font-size: 14px;
    }

    .bill-document-number small {
        margin-top: 4px;
        color: var(--pharmacy-muted);
        font-size: 9px;
    }

.bill-patient-section,
.bill-medicine-section {
    margin-top: 16px;
}

.bill-section-title {
    margin-bottom: 8px;
    padding-bottom: 5px;
    color: var(--pharmacy-primary);
    border-bottom: 1px solid #e6eaf0;
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.bill-patient-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

    .bill-patient-grid div {
        min-width: 0;
    }

    .bill-patient-grid span,
    .bill-patient-grid strong {
        display: block;
    }

    .bill-patient-grid span {
        color: var(--pharmacy-muted);
        font-size: 9px;
    }

    .bill-patient-grid strong {
        margin-top: 3px;
        color: var(--pharmacy-text);
        font-size: 11px;
    }

.bill-table-wrapper {
    overflow-x: auto;
}

.bill-medicine-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}

    .bill-medicine-table th {
        padding: 8px;
        color: #475467;
        background: #f6f8fa;
        border: 1px solid #e2e7ed;
        font-size: 9px;
        font-weight: 750;
        text-align: left;
        text-transform: uppercase;
    }

    .bill-medicine-table td {
        padding: 8px;
        color: #344054;
        border: 1px solid #e6eaf0;
    }

.bill-column-center {
    text-align: center !important;
}

.bill-column-number {
    text-align: right !important;
}

.bill-medicine-name strong,
.bill-medicine-name span {
    display: block;
}

.bill-medicine-name strong {
    color: var(--pharmacy-text);
    font-size: 10px;
}

.bill-medicine-name span {
    margin-top: 2px;
    color: var(--pharmacy-muted);
    font-size: 8px;
}

.bill-item-total {
    color: var(--pharmacy-text) !important;
    font-weight: 700;
}

.bill-summary-section {
    margin-top: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 20px;
}

.bill-payment-information {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 12px;
}

    .bill-payment-information span,
    .bill-payment-information strong {
        display: block;
    }

    .bill-payment-information span {
        color: var(--pharmacy-muted);
        font-size: 9px;
    }

    .bill-payment-information strong {
        margin-top: 3px;
        font-size: 10px;
    }

.bill-total-table {
    border: 1px solid #e2e7ed;
    border-radius: 7px;
    overflow: hidden;
}

    .bill-total-table > div {
        min-height: 32px;
        padding: 6px 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        border-bottom: 1px solid #edf0f4;
    }

        .bill-total-table > div:last-child {
            border-bottom: 0;
        }

    .bill-total-table span {
        color: var(--pharmacy-muted);
        font-size: 9px;
    }

    .bill-total-table strong {
        color: var(--pharmacy-text);
        font-size: 10px;
    }

    .bill-total-table .bill-net-total {
        background: var(--pharmacy-primary-soft);
    }

        .bill-total-table .bill-net-total span,
        .bill-total-table .bill-net-total strong {
            color: var(--pharmacy-primary);
            font-size: 13px;
            font-weight: 750;
        }

.bill-document-footer {
    margin-top: 20px;
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    color: var(--pharmacy-muted);
    border-top: 1px dashed #cfd6df;
    font-size: 9px;
}

    .bill-document-footer strong {
        color: var(--pharmacy-primary);
    }

.bill-dialog-footer {
    padding: 10px 14px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--pharmacy-border);
}

.pharmacy-empty-state {
    min-height: 270px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--pharmacy-muted);
    text-align: center;
}

    .pharmacy-empty-state i {
        margin-bottom: 8px;
        font-size: 30px;
    }

    .pharmacy-empty-state strong {
        color: var(--pharmacy-text);
        font-size: 12px;
    }

    .pharmacy-empty-state span {
        margin-top: 4px;
        font-size: 10px;
    }

@media (max-width: 700px) {
    .pharmacy-bill-history-item {
        grid-template-columns: 34px minmax(0, 1fr) auto;
    }

    .bill-report-button {
        grid-column: 2 / -1;
        justify-self: start;
    }

    .bill-document-header {
        flex-direction: column;
    }

    .bill-document-number {
        text-align: left;
    }

    .bill-patient-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bill-summary-section {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================================
   PHARMACY ENTERPRISE VIEWPORT ENGINE & GRID SYSTEM
   ============================================================ */

/* Scoped layout overrides for all Pharmacy Viewport Pages (Scrollable if necessary) */
.content:has(.pharmacy-viewport-page),
.content:has(.pos-return-root) {
    padding: 10px 14px 10px 14px !important;
    margin: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: calc(100vh - 66px) !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
}

/* Scoped layout for Stock Ledger & Audit Trail: Allow vertical overall scroll */
.content:has(.pharmacy-stock-ledger-page),
.content:has(.pharmacy-audit-page) {
    height: auto !important;
    max-height: none !important;
    min-height: calc(100vh - 66px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: block !important;
    background: #ffffff !important;
}

/* Hide footer completely on all pharmacy pages */
.content:has(.pharmacy-viewport-page) > .footer,
.content:has(.pharmacy-viewport-page) .footer,
.content:has(.pharmacy-page) > .footer,
.content:has(.pharmacy-page) .footer,
.content:has(.pra-page) > .footer,
.content:has(.pra-page) .footer,
.content:has(.pos-return-root) > .footer,
.content:has(.pos-return-root) .footer,
.content:has(.pos-root) > .footer,
.content:has(.pos-root) .footer {
    display: none !important;
}

@media (max-width: 991.98px) {
    .content:has(.pharmacy-viewport-page),
    .content:has(.pos-return-root) {
        min-height: calc(100vh - 60px) !important;
        padding: 8px 10px 8px 10px !important;
    }
    .content:has(.pharmacy-stock-ledger-page),
    .content:has(.pharmacy-audit-page) {
        min-height: calc(100vh - 60px) !important;
    }
}

.pharmacy-viewport-page {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: calc(100vh - 86px) !important;
    height: auto !important;
    width: 100% !important;
    gap: 8px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    font-family: inherit !important;
}

/* Executive Header */
.pharmacy-viewport-page .pharmacy-page-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.pharmacy-viewport-page .pharmacy-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pharmacy-viewport-page .pharmacy-title-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #edf6f8;
    color: #2a6b82;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pharmacy-viewport-page .pharmacy-title-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #172033;
    margin: 0;
    line-height: 1.25;
}

.pharmacy-viewport-page .pharmacy-title-text p {
    font-size: 0.76rem;
    color: #64748b;
    margin: 2px 0 0;
}

.pharmacy-viewport-page .pharmacy-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Claude-Style Executive Button */
.pharmacy-btn {
    min-height: 38px;
    height: 38px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pharmacy-btn i {
    font-size: 13px;
}

.pharmacy-btn-primary {
    color: #ffffff !important;
    background: #2a6b82 !important;
    border-color: #2a6b82 !important;
}

.pharmacy-btn-primary:hover {
    color: #ffffff !important;
    background: #1f566a !important;
    border-color: #1f566a !important;
    box-shadow: 0 2px 6px rgba(42, 107, 130, 0.25) !important;
}

.pharmacy-btn-secondary {
    color: #1f2937 !important;
    background: #ffffff !important;
    border-color: #d1d5db !important;
}

.pharmacy-btn-secondary:hover {
    color: #2a6b82 !important;
    background: #edf6f8 !important;
    border-color: #2a6b82 !important;
}

/* Grid Card Host — Fixed viewport height so even 100 or 200 records scroll inside the grid like Stock Ledger */
.pharmacy-viewport-page .pharmacy-grid-card {
    flex: 0 0 auto !important;
    height: calc(100vh - 170px) !important;
    min-height: 520px !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box !important;
}

@media (max-width: 991.98px) {
    .pharmacy-viewport-page .pharmacy-grid-card {
        height: calc(100vh - 140px) !important;
    }
}

/* Pharmacy Grid Rules — Full Height Flex Engine */
.pharmacy-viewport-page .pharmacy-grid-card .e-grid,
.pharmacy-viewport-page .e-grid {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    border: none !important;
    border-radius: 0 !important;
    font-family: inherit !important;
}

.pharmacy-viewport-page .e-grid .e-toolbar {
    flex: 0 0 auto !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #ffffff !important;
    min-height: 38px !important;
}

.pharmacy-viewport-page .e-grid .e-gridheader {
    flex: 0 0 auto !important;
    border-top: 0 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
}

.pharmacy-viewport-page .e-grid .e-headercell {
    background: #f8fafc !important;
    height: 38px !important;
    padding: 0 10px !important;
    border-color: #e2e8f0 !important;
}

.pharmacy-viewport-page .e-grid .e-headercelldiv {
    color: #475569 !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* ── Clean Aggregate / Summary Footer (Single Border Separator, No Stacking) ── */
.pharmacy-viewport-page .e-grid .e-gridfooter {
    flex: 0 0 auto !important;
    background: #f8fafc !important;
    border: none !important;
    border-top: 1px solid #e2e8f0 !important;
    border-bottom: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.pharmacy-viewport-page .e-grid .e-summarycontent {
    background: transparent !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.pharmacy-viewport-page .e-grid .e-summarycontent table {
    border: none !important;
    margin: 0 !important;
}

.pharmacy-viewport-page .e-grid .e-summaryrow {
    background: #f8fafc !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    height: 38px !important;
}

.pharmacy-viewport-page .e-grid .e-summarycell {
    background: #f8fafc !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    padding: 6px 12px !important;
    font-size: 12.5px !important;
    color: #1e293b !important;
    font-weight: 600 !important;
    height: 38px !important;
    vertical-align: middle !important;
}

/* ── Full Height Grid Content Viewport ── */
.pharmacy-viewport-page .e-grid .e-gridcontent:not(:has(.e-movablecontent)),
.pharmacy-viewport-page.pharmacy-stock-ledger-page .e-grid .e-gridcontent,
.pharmacy-viewport-page.pharmacy-kpi-page .e-grid .e-gridcontent {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    background: #ffffff !important;
}

/* Grids with frozen columns (e.g. Sales Invoices with right-pinned Actions column) */
.pharmacy-viewport-page .e-grid .e-gridcontent:has(.e-movablecontent) {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    overflow: hidden !important;
    background: #ffffff !important;
    display: block !important;
}

.pharmacy-viewport-page .e-grid .e-movablecontent {
    height: 100% !important;
    min-height: 0 !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.pharmacy-viewport-page .e-grid .e-frozencontent {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

.pharmacy-viewport-page .e-grid .e-gridcontent .e-content {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Empty grid occupies 100% height and vertically centers empty message */
.pharmacy-viewport-page .e-grid .e-emptyrow {
    height: 100% !important;
}

.pharmacy-viewport-page .e-grid .e-emptyrow td {
    height: 100% !important;
    vertical-align: middle !important;
    text-align: center !important;
    padding: 60px 20px !important;
    border: none !important;
    background: #ffffff !important;
}

/* When table has rows, let rows size naturally and scroll smoothly */
.pharmacy-viewport-page .e-grid .e-gridcontent .e-content:has(tbody tr:not(.e-emptyrow)) table,
.pharmacy-viewport-page .e-grid .e-movablecontent:has(tbody tr:not(.e-emptyrow)) table,
.pharmacy-viewport-page .e-grid .e-frozencontent:has(tbody tr:not(.e-emptyrow)) table {
    height: auto !important;
    min-height: 0 !important;
}
.pharmacy-viewport-page .e-grid .e-gridcontent .e-content:has(tbody tr:not(.e-emptyrow)) {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
}

.pharmacy-viewport-page .e-grid .e-rowcell {
    height: 42px !important;
    padding: 6px 12px !important;
    font-size: 12.5px !important;
    color: #1e293b !important;
    border-color: #f1f5f9 !important;
}

.pharmacy-viewport-page .e-grid .e-row:hover .e-rowcell {
    background: #f8fafc !important;
}

/* Pager pinned to the bottom of the card */
.pharmacy-viewport-page .e-grid .e-gridpager {
    flex: 0 0 auto !important;
    margin-top: auto !important;
    border: none !important;
    border-top: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    min-height: 42px !important;
    padding: 4px 8px !important;
}

/* Prevent syllable-wrapping across all pharmacy tables */
.pharmacy-viewport-page .e-headertext,
.pharmacy-viewport-page .e-grid .e-headertext {
    white-space: nowrap !important;
}

/* Modal Title Enhancement for Purchase Modules */
.pharmacy-dialog-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pharmacy-dialog-title-icon {
    display: none !important;
}

.pharmacy-dialog-title {
    font-size: 1.12rem;
    font-weight: 700;
    color: #172033;
    line-height: 1.25;
    margin: 0;
}

.pharmacy-dialog-subtitle {
    font-size: 0.72rem;
    color: #64748b;
    margin: 1px 0 0;
    display: block;
}

/* ── Universal Search Shortcut Badge (Alt+P) ── */
.pos-search-kbd {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #475569;
    font-family: inherit;
    flex-shrink: 0;
    user-select: none;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* ── Keyboard Navigation Active Item Highlights ── */
.invoice-patient-item-active,
.pos-patient-item-active {
    background-color: #e0f2fe !important;
    border-left: 3px solid #2a6b82 !important;
}

.invoice-patient-item-active .invoice-patient-name,
.pos-patient-item-active .pos-pt-name {
    color: #0f172a !important;
    font-weight: 700 !important;
}

/* ── Universal Input Focus Overrides (Stick with CEMR Theme Purple #6750a4) ── */
.e-dialog .e-input-group.e-input-focus::after,
.e-dialog .e-input-group.e-control-wrapper.e-input-focus::after,
.pharmacy-viewport-page .e-input-group.e-input-focus::after,
.pharmacy-viewport-page .e-input-group.e-control-wrapper.e-input-focus::after,
.e-input-group.e-input-focus::after,
.e-input-group.e-control-wrapper.e-input-focus::after,
.e-dialog .e-input-group.e-input-focus::before,
.e-dialog .e-input-group.e-control-wrapper.e-input-focus::before,
.pharmacy-viewport-page .e-input-group.e-input-focus::before,
.pharmacy-viewport-page .e-input-group.e-control-wrapper.e-input-focus::before,
.e-input-group.e-input-focus::before,
.e-input-group.e-control-wrapper.e-input-focus::before {
    background: #6750a4 !important;
}

.e-dialog .e-input-group.e-input-focus,
.e-dialog .e-input-group.e-control-wrapper.e-input-focus,
.pharmacy-viewport-page .e-input-group.e-input-focus,
.pharmacy-viewport-page .e-input-group.e-control-wrapper.e-input-focus,
.e-dialog .e-ddl.e-input-group.e-input-focus,
.pharmacy-viewport-page .e-ddl.e-input-group.e-input-focus {
    border-color: #6750a4 !important;
}

/* Suppress focus underline on readonly & disabled inputs */
.e-dialog .e-input-group.e-readonly::after,
.e-dialog .e-input-group.e-disabled::after,
.e-input-group.e-readonly::after,
.e-input-group.e-disabled::after,
.e-dialog .e-input-group.e-readonly.e-input-focus::after,
.e-dialog .e-input-group.e-disabled.e-input-focus::after {
    display: none !important;
    background: transparent !important;
    height: 0 !important;
}

.pharmacy-viewport-page .badge {
    font-size: 0.74rem;
    padding: 4px 8px;
    border-radius: 6px;
}

/* ── Replacement Modal Header Action Buttons ── */
.btn-substitute-add {
    background: #6750a4 !important;
    color: #ffffff !important;
    border: 1px solid #6750a4 !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    padding: 6px 14px !important;
    font-size: 12.5px !important;
    display: inline-flex !important;
    align-items: center !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    box-shadow: 0 1px 3px rgba(103, 80, 164, 0.2) !important;
}
.btn-substitute-add,
.btn-substitute-add *,
.btn-substitute-add span,
.btn-substitute-add i {
    color: #ffffff !important;
    fill: #ffffff !important;
}
.btn-substitute-add:hover,
.btn-substitute-add:focus {
    background: #563f8c !important;
    border-color: #563f8c !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.35) !important;
    transform: translateY(-1px) !important;
}
.btn-substitute-add:hover *,
.btn-substitute-add:focus *,
.btn-substitute-add:hover span,
.btn-substitute-add:focus span,
.btn-substitute-add:hover i,
.btn-substitute-add:focus i {
    color: #ffffff !important;
    fill: #ffffff !important;
}
.btn-substitute-add:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 4px rgba(103, 80, 164, 0.2) !important;
}

.btn-receive-pending {
    background: #ffffff !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
    font-weight: 500 !important;
    border-radius: 6px !important;
    padding: 6px 14px !important;
    font-size: 12.5px !important;
    display: inline-flex !important;
    align-items: center !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
}
.btn-receive-pending,
.btn-receive-pending * {
    color: #334155 !important;
}
.btn-receive-pending:hover,
.btn-receive-pending:focus {
    background: #f8fafc !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    transform: translateY(-1px) !important;
}
.btn-receive-pending:hover *,
.btn-receive-pending:focus * {
    color: #0f172a !important;
}
.btn-receive-pending:active {
    transform: translateY(0) !important;
    box-shadow: none !important;
}

/* ── Pharmacy Stock Ledger Viewport & Scroll Engine ── */
.pharmacy-viewport-page.pharmacy-stock-ledger-page {
    height: auto !important;
    max-height: none !important;
    min-height: 100% !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding-bottom: 24px !important;
    background: #ffffff !important;
}

.pharmacy-stock-ledger-page .ledger-metric-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.pharmacy-stock-ledger-page .pharmacy-grid-card {
    flex: 0 0 auto !important;
    height: calc(100vh - 170px) !important;
    min-height: 560px !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box !important;
}

.pharmacy-stock-ledger-page .pharmacy-grid-card .e-grid {
    flex: 1 1 0% !important;
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.pharmacy-stock-ledger-page .pharmacy-grid-card .e-grid .e-gridcontent {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
}

/* ── Pharmacy Audit Trail Viewport & Scroll Engine ── */
.pharmacy-viewport-page.pharmacy-audit-page {
    height: auto !important;
    max-height: none !important;
    min-height: 100% !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding-bottom: 24px !important;
    background: #ffffff !important;
}

.pharmacy-audit-page .audit-metric-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.pharmacy-audit-page .pharmacy-grid-card {
    flex: 0 0 auto !important;
    height: calc(100vh - 170px) !important;
    min-height: 560px !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box !important;
}

.pharmacy-audit-page .pharmacy-grid-card .e-grid {
    flex: 1 1 0% !important;
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.pharmacy-audit-page .pharmacy-grid-card .e-grid .e-gridcontent {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
}

/* ── Pharmacy Purchase Invoice & Return Dialog Styles ── */
.pharmacy-dialog-header {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.pharmacy-dialog-grid-card .e-emptyrow td {
    height: 180px !important;
    vertical-align: middle !important;
    text-align: center !important;
    color: #64748b !important;
    font-size: 0.88rem !important;
    background: #ffffff !important;
}

.pos-pane-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: .8rem !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
}

.pos-badge-inward {
    background: #edf6f8 !important;
    color: #2a6b82 !important;
    border: 1.5px solid #d2e7ec !important;
}

.pos-badge-refund {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border: 1.5px solid #fca5a5 !important;
}

.pos-no-spinners input::-webkit-outer-spin-button,
.pos-no-spinners input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}
.pos-no-spinners input {
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

/* ── Pharmacy Dialog Line Items Grid & Horizontal Scroll Engine ── */
.pharmacy-dialog-grid-card {
    overflow: hidden !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.pharmacy-dialog-grid-card .card-body {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    padding: 8px !important;
}

.pharmacy-dialog-grid-card .e-grid,
.e-dialog .card .e-grid {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.pharmacy-dialog-grid-card .e-grid .e-gridheader,
.e-dialog .card .e-grid .e-gridheader {
    overflow-x: hidden !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.pharmacy-dialog-grid-card .e-grid .e-gridcontent,
.e-dialog .card .e-grid .e-gridcontent {
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.pharmacy-dialog-grid-card .e-grid .e-gridfooter,
.e-dialog .card .e-grid .e-gridfooter {
    overflow-x: hidden !important;
    border-top: 1px solid #e2e8f0 !important;
}



/* Ensure action buttons inside dialog grids do not get compressed or wrapped */
.pharmacy-dialog-grid-card .e-grid .e-rowcell .btn,
.e-dialog .card .e-grid .e-rowcell .btn {
    white-space: nowrap !important;
}