/* ── Prescription Manager – Admin Styles ───────────────────── */

.pm-wrap { max-width: 1200px; }

/* Cards */
.pm-card {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.pm-card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    font-size: 15px;
    color: #1d2327;
}

/* Grid helpers */
.pm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pm-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.pm-full-span { grid-column: 1 / -1; }

/* Fields */
.pm-field { display: flex; flex-direction: column; gap: 4px; }
.pm-field label { font-weight: 600; font-size: 13px; color: #444; }
.pm-field input,
.pm-field select,
.pm-field textarea {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}
.pm-field input:focus,
.pm-field select:focus { border-color: #2271b1; outline: none; box-shadow: 0 0 0 1px #2271b1; }

/* Medication table in prescription form */
.pm-med-table { border-collapse: collapse; margin-bottom: 12px; }
.pm-med-table th { background: #f6f7f7; font-size: 12px; padding: 8px 6px; }
.pm-med-table td { padding: 6px 4px; vertical-align: middle; }
.pm-med-table input,
.pm-med-table select { width: 100%; padding: 5px 6px; font-size: 12px; border: 1px solid #ddd; border-radius: 3px; box-sizing: border-box; }
.pm-med-table .med-subtotal { background: #f9f9f9; font-weight: bold; color: #1d6c21; }
.pm-med-table .med-name { margin-top: 4px; }
.pm-med-select { margin-bottom: 2px; }

/* Total row */
.pm-total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 12px 0 4px;
    font-size: 16px;
}
.pm-grand-total {
    font-size: 20px;
    font-weight: 700;
    color: #c0392b;
}

/* Form actions */
.pm-form-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }

/* Prescription list table */
.pm-table { border-radius: 6px; overflow: hidden; }
.pm-table th { background: #f0f6fc; }
.pm-price { font-weight: 600; color: #c0392b; }
.pm-actions { white-space: nowrap; }
.pm-btn-delete { color: #c0392b !important; border-color: #c0392b !important; }

/* Search */
.pm-search-form { margin: 16px 0; display: flex; gap: 8px; align-items: center; }
.pm-search-input { min-width: 280px; padding: 6px 10px; border: 1px solid #ccc; border-radius: 4px; }

/* Two-column layout (medications page) */
.pm-two-col { display: grid; grid-template-columns: 380px 1fr; gap: 20px; }
.pm-form-col, .pm-list-col {}

/* Medication list table */
.pm-med-list-table { font-size: 13px; }
.pm-inactive-row { opacity: .5; }
.pm-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pm-badge-active   { background: #d4edda; color: #155724; }
.pm-badge-inactive { background: #f8d7da; color: #721c24; }

/* Empty state */
.pm-empty { padding: 40px; text-align: center; color: #666; }

/* ── Print Styles ─────────────────────────────────────────── */
.pm-print-area {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
    max-width: 800px;
    margin-top: 20px;
}
.pm-rx-header { border-bottom: 2px solid #2271b1; padding-bottom: 12px; margin-bottom: 16px; }
.pm-rx-header h2 { margin: 0; color: #2271b1; font-size: 22px; }
.pm-rx-patient { background: #f8f9fa; border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; }
.pm-rx-patient-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 14px; }
.pm-rx-patient label { font-weight: 600; color: #555; margin-right: 6px; }
.pm-rx-items-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13px; }
.pm-rx-items-table th { background: #2271b1; color: #fff; padding: 8px 10px; text-align: left; }
.pm-rx-items-table td { padding: 7px 10px; border-bottom: 1px solid #eee; }
.pm-rx-items-table tr:nth-child(even) td { background: #f9f9f9; }
.pm-num { text-align: right; }
.pm-rx-items-table tfoot tr td { background: #f0f6fc; font-size: 15px; padding: 10px; }
.pm-grand-total { color: #c0392b; font-size: 16px !important; }
.pm-rx-notes { background: #fffde7; border-left: 4px solid #f1c40f; padding: 10px 14px; border-radius: 4px; margin-bottom: 20px; font-size: 13px; }
.pm-rx-footer { display: flex; justify-content: space-between; margin-top: 30px; }
.pm-doctor-signature-block { text-align: center; min-width: 220px; }
.pm-doctor-signature-img { display: block; max-width: 180px; max-height: 60px; width: auto; height: auto; object-fit: contain; margin: 4px auto 2px; }
.pm-doctor-signature-space { height: 52px; }
.pm-signature-line { margin: 3px 0 4px; }

.pm-view-actions { margin-bottom: 16px; display: flex; gap: 10px; }

/* Wider Prescription View screen layout */
.pm-view-wrap {
    max-width: none;
    width: calc(100% - 20px);
}
.pm-view-wrap .pm-print-area {
    max-width: 1180px;
    width: 100%;
    box-sizing: border-box;
}
.pm-view-wrap .pm-rx-items-table {
    table-layout: auto;
}
@media screen and (max-width: 782px) {
    .pm-view-wrap { width: auto; }
    .pm-view-wrap .pm-print-area { padding: 16px; overflow-x: auto; }
    .pm-view-wrap .pm-rx-patient-grid { grid-template-columns: 1fr; }
    .pm-view-wrap .pm-vitals-display { flex-wrap: wrap; }
}

@media print {
    .no-print, #adminmenuwrap, #wpadminbar, #wpfooter, .pm-view-actions { display: none !important; }
    .pm-print-area { border: none; padding: 0; box-shadow: none; }
    body { background: #fff !important; }
    #wpcontent, #wpbody-content { margin: 0 !important; padding: 0 !important; }
}

/* ── Live Search ──────────────────────────────────────────── */
.pm-live-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 20px;
    background: #fff;
    border: 2px solid #2271b1;
    border-radius: 8px;
    padding: 10px 16px;
    box-shadow: 0 2px 8px rgba(34,113,177,.1);
    max-width: 700px;
}
.pm-search-icon { font-size: 18px; flex-shrink: 0; }
.pm-live-search-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    font-size: 15px;
    padding: 2px 0;
    background: transparent;
    box-shadow: none !important;
}
.pm-search-badge {
    background: #2271b1;
    color: #fff;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 12px;
    white-space: nowrap;
}
.pm-clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #888;
    padding: 0 4px;
    line-height: 1;
}
.pm-clear-btn:hover { color: #c0392b; }
.pm-count-bar { color: #666; font-size: 13px; margin-bottom: 8px; }

/* ── Number with inline label (e.g. 2 lần/ngày) ─────────────── */
.pm-num-with-label {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pm-num-with-label input {
    width: 52px !important;
    flex-shrink: 0;
    text-align: center;
}
.pm-field-label {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    line-height: 1.2;
}

/* Qty auto field */
.pm-qty-display {
    background: #eaf4fb !important;
    color: #1a5276 !important;
    font-weight: 700 !important;
    text-align: center;
    cursor: default;
}

/* ── Patient List ─────────────────────────────────────────────── */
.pm-patient-table td { vertical-align: middle; }
.pm-rx-count-badge {
    display: inline-block;
    background: #e8f0fe;
    color: #2271b1;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}
.pm-rx-count-badge:hover { background: #2271b1; color: #fff; }

/* How to use field */
.med-howto { font-size: 11px !important; }

/* ── View prescription: column widths ────────────────────────── */
.pm-rx-items-table .col-no     { width: 4%;  text-align: center; }
.pm-rx-items-table .col-med    { width: 22%; }
.pm-rx-items-table .col-unit   { width: 7%;  text-align: center; }
.pm-rx-items-table .col-freq   { width: 8%;  text-align: center; }
.pm-rx-items-table .col-dose   { width: 9%;  text-align: center; }
.pm-rx-items-table .col-howto  { width: 18%; }
.pm-rx-items-table .col-days   { width: 7%;  text-align: center; }
.pm-rx-items-table .col-qty    { width: 7%;  text-align: center; }
.pm-rx-items-table .col-price  { width: 10%; text-align: right; }
.pm-rx-items-table .col-sub    { width: 10%; text-align: right; }

/* Hide price/subtotal/total on print */
@media print {
    .no-print-col { display: none !important; }
    .pm-rx-items-table .col-med  { width: 28%; }
    .pm-rx-items-table .col-howto{ width: 24%; }
}

/* ── Vitals fields in prescription edit ──────────────────────── */
.pm-vitals-grid { display: flex; flex-direction: row; gap: 14px; margin-bottom: 16px; }
.pm-vitals-grid .pm-vital-field { flex: 1; min-width: 0; }
.pm-vital-field { background: #f7f9fc; border: 1px solid #e0e7ef; border-radius:8px; padding:14px 16px; }
.pm-vital-field label { display:block; font-size:12px; font-weight:700; color:#555; margin-bottom:8px; }
.pm-vital-input-wrap { display:flex; align-items:center; gap:6px; }
.pm-vital-input-wrap input { flex:1; padding:7px 10px; border:1px solid #dde3ea; border-radius:5px; font-size:14px; font-weight:600; outline:none; }
.pm-vital-unit { font-size:11px; color:#888; white-space:nowrap; }

/* ── Vitals display in prescription view ─────────────────────── */
.pm-vitals-display { display: flex; flex-direction: row; gap: 12px; margin-bottom: 16px; flex-wrap: nowrap; }
.pm-vitals-display .pm-vital-badge { flex: 1; min-width: 0; }
.pm-vital-badge { background:#fff; border:1px solid #e0e7ef; border-radius:8px;
                  padding:10px 16px; display:flex; align-items:center; gap:10px; }
.pm-vital-badge .pm-vital-icon { font-size:18px; }
.pm-vital-badge .pm-vital-label { font-size:11px; color:#888; font-weight:600; margin-right:4px; }

/* Searchable medication picker */
.pm-med-select-hidden { display: none !important; }
.pm-med-search { width: 100%; box-sizing: border-box; }
.pm-med-results { position: absolute; z-index: 99999; width: min(420px, 96%); max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid #ccd0d4; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.12); margin-top: 2px; }
.med-row td:first-child { position: relative; }
.pm-med-result { display: block; width: 100%; padding: 8px 10px; border: 0; border-bottom: 1px solid #f0f0f1; background: #fff; text-align: left; cursor: pointer; }
.pm-med-result:hover, .pm-med-result:focus { background: #f6f7f7; }
.pm-med-result span { display: block; font-weight: 600; color: #1d2327; }
.pm-med-result small { display: block; color: #646970; margin-top: 2px; }
.pm-med-noresult { padding: 8px 10px; color: #646970; background: #fff; }


/* ── Mobile responsive hardening ───────────────────────────── */
.pm-med-table-wrap,
.pm-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
@media screen and (max-width: 782px) {
    .pm-grid-2,
    .pm-grid-3,
    .pm-two-col { grid-template-columns: 1fr !important; }
    .pm-card { padding: 14px; }
    .pm-form-actions,
    .pm-view-actions,
    .pm-live-search-wrap { flex-wrap: wrap; }
    .pm-live-search-wrap { max-width: 100%; }
    .pm-med-table,
    .pm-rx-items-table,
    .pm-table { min-width: 760px; }
    .pm-vitals-grid,
    .pm-vitals-display { flex-direction: column; flex-wrap: wrap; }
}

/* ── Strong mobile layout: convert plugin tables to readable cards ───────── */
@media screen and (max-width: 782px) {
    .pm-wrap {
        max-width: 100%;
        margin-right: 10px;
    }

    .pm-card,
    .pm-print-area {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 14px;
    }

    .pm-search-form,
    .pm-live-search-wrap,
    .pm-form-actions,
    .pm-view-actions,
    .pm-total-row {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .pm-search-input,
    .pm-live-search-input,
    .pm-form-actions .button,
    .pm-view-actions .button,
    .pm-view-actions a.button,
    .pm-view-actions button.button {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .pm-rx-patient-grid,
    .pm-grid-2,
    .pm-grid-3,
    .pm-two-col {
        display: grid;
        grid-template-columns: 1fr !important;
    }

    .pm-vitals-grid,
    .pm-vitals-display {
        flex-direction: column;
        gap: 8px;
    }

    .pm-vital-badge {
        align-items: flex-start;
    }

    .pm-table,
    .pm-table thead,
    .pm-table tbody,
    .pm-table tr,
    .pm-table td,
    .pm-rx-items-table,
    .pm-rx-items-table thead,
    .pm-rx-items-table tbody,
    .pm-rx-items-table tr,
    .pm-rx-items-table td,
    .pm-med-table,
    .pm-med-table thead,
    .pm-med-table tbody,
    .pm-med-table tr,
    .pm-med-table td {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        white-space: normal !important;
    }

    .pm-table,
    .pm-rx-items-table,
    .pm-med-table {
        border-collapse: separate;
        border-spacing: 0;
        font-size: 14px;
    }

    .pm-table thead,
    .pm-rx-items-table thead,
    .pm-med-table thead,
    .pm-rx-items-table tfoot {
        display: none;
    }

    .pm-table tr,
    .pm-rx-items-table tr,
    .pm-med-table tr {
        margin: 0 0 12px;
        border: 1px solid #dcdcde;
        border-radius: 10px;
        background: #fff;
        overflow: hidden;
        box-shadow: 0 1px 2px rgba(0,0,0,.03);
    }

    .pm-table td,
    .pm-rx-items-table td,
    .pm-med-table td,
    .pm-rx-items-table tr:nth-child(even) td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 9px 12px !important;
        border-bottom: 1px solid #f0f0f1;
        background: #fff !important;
        text-align: right !important;
    }

    .pm-table td:last-child,
    .pm-rx-items-table td:last-child,
    .pm-med-table td:last-child {
        border-bottom: 0;
    }

    .pm-table td::before,
    .pm-rx-items-table td::before,
    .pm-med-table td::before {
        content: attr(data-label);
        flex: 0 0 40%;
        max-width: 40%;
        color: #50575e;
        font-weight: 700;
        text-align: left;
    }

    .pm-table td[data-label="#"]::before,
    .pm-rx-items-table td[data-label="#"]::before {
        content: "STT";
    }

    .pm-med-table td {
        flex-direction: column;
        align-items: stretch;
        text-align: left !important;
    }

    .pm-med-table td::before {
        max-width: 100%;
        flex-basis: auto;
        margin-bottom: 4px;
    }

    .pm-med-table input,
    .pm-med-table select,
    .pm-med-table textarea,
    .pm-num-with-label {
        width: 100% !important;
        box-sizing: border-box;
    }

    .pm-num-with-label {
        display: flex;
        gap: 8px;
    }

    .pm-actions,
    .pm-actions[data-label] {
        white-space: normal;
        display: flex !important;
        flex-direction: column;
        gap: 8px;
    }

    .pm-actions::before {
        width: 100%;
        max-width: 100%;
        flex-basis: auto;
    }

    .pm-actions .button,
    .pm-med-table .button {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    .pm-rx-footer {
        display: block;
        text-align: center;
    }

    .pm-doctor-signature-block {
        min-width: 0;
        width: 100%;
    }
}

@media print {
    .pm-table td::before,
    .pm-rx-items-table td::before,
    .pm-med-table td::before {
        content: none !important;
    }
}

/* ── v1.5.0 final responsive polish ─────────────────────────── */
.pm-patient-search-wrap {
    max-width: 560px;
    width: 100%;
    box-sizing: border-box;
}
.pm-patient-search-form {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
}
.pm-patient-search-input {
    min-width: 0;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

@media screen and (max-width: 960px) {
    .pm-wrap {
        max-width: 100%;
    }
    .pm-two-col {
        grid-template-columns: 1fr !important;
    }
    .pm-live-search-wrap {
        max-width: 100%;
    }
}

@media screen and (max-width: 782px) {
    .pm-patient-search-wrap,
    .pm-live-search-wrap,
    .pm-search-form {
        padding: 10px;
        gap: 8px;
    }
    .pm-patient-search-form,
    .pm-search-form {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .pm-patient-search-form .button,
    .pm-search-form .button,
    .pm-search-form input,
    .pm-patient-search-input,
    .pm-live-search-input {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    .pm-search-icon {
        align-self: flex-start;
    }
    .pm-table td,
    .pm-rx-items-table td {
        text-align: left !important;
        flex-direction: column;
        gap: 4px;
    }
    .pm-table td::before,
    .pm-rx-items-table td::before {
        flex: none;
        max-width: 100%;
        width: 100%;
    }
    .pm-table td > *,
    .pm-rx-items-table td > * {
        max-width: 100%;
        word-break: break-word;
    }
}

@media screen and (max-width: 480px) {
    .wrap.pm-wrap {
        margin-left: 0;
        margin-right: 0;
    }
    .pm-card,
    .pm-print-area {
        padding: 12px;
        border-radius: 8px;
    }
    .pm-live-search-wrap {
        border-width: 1px;
        border-radius: 8px;
    }
    .pm-count-bar {
        line-height: 1.4;
    }
    .pm-table tr,
    .pm-rx-items-table tr,
    .pm-med-table tr {
        border-radius: 8px;
    }
    .pm-table td,
    .pm-rx-items-table td,
    .pm-med-table td {
        padding: 8px 10px !important;
    }
    .page-title-action {
        display: inline-block;
        margin-top: 8px;
    }
}


/* ── v1.5.1 All Prescriptions live-search responsive fix ───────────────── */
.pm-rx-search-wrap {
    width: 100%;
    max-width: 760px;
    box-sizing: border-box;
}
.pm-rx-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    width: 100%;
}
.pm-rx-search-input {
    min-width: 0;
}

@media screen and (max-width: 960px) {
    .pm-rx-search-wrap {
        max-width: 100%;
    }
}

@media screen and (max-width: 782px) {
    .pm-rx-search-wrap {
        align-items: stretch;
        width: 100%;
    }
    .pm-rx-search-field {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }
    .pm-rx-search-input {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 40px;
        padding: 8px 10px !important;
        box-sizing: border-box;
        background: #fff;
        border: 1px solid #c3c4c7 !important;
        border-radius: 6px;
    }
    .pm-rx-search-wrap .pm-search-badge {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        min-height: 32px;
        box-sizing: border-box;
        text-align: center;
    }
    .pm-rx-search-wrap .pm-clear-btn {
        width: 100%;
        min-height: 40px;
        box-sizing: border-box;
        border: 1px solid #c3c4c7;
        border-radius: 6px;
        background: #f6f7f7;
        color: #1d2327;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .pm-rx-search-wrap {
        padding: 10px;
    }
    .pm-rx-search-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
}

/* ── v1.5.4 Patient live search + prescription display limit ───────────── */
.pm-patient-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    width: 100%;
}
.pm-list-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    color: #50575e;
    font-size: 13px;
}
.pm-rx-limit-select {
    min-width: 110px;
}
.pm-list-controls-note {
    color: #646970;
}
.pm-patient-table th:nth-child(3),
.pm-patient-table td:nth-child(3) {
    text-align: center;
    width: 72px;
}
@media screen and (max-width: 782px) {
    .pm-patient-search-field,
    .pm-list-controls {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .pm-patient-search-field .pm-search-badge,
    .pm-patient-search-field .pm-clear-btn,
    .pm-rx-limit-select {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
    .pm-list-controls-note {
        line-height: 1.4;
    }
}

/* Frontend Doctor Dashboard */
body.pm-doctor-dashboard-page,
body.pm-doctor-dashboard-page #page,
body.pm-doctor-dashboard-page .site,
body.pm-doctor-dashboard-page .site-content,
body.pm-doctor-dashboard-page .site-main,
body.pm-doctor-dashboard-page .content-area,
body.pm-doctor-dashboard-page main,
body.pm-doctor-dashboard-page article,
body.pm-doctor-dashboard-page .entry,
body.pm-doctor-dashboard-page .entry-content,
body.pm-doctor-dashboard-page .wp-block-post-content,
body.pm-doctor-dashboard-page .inside-article,
body.pm-doctor-dashboard-page .ast-container,
body.pm-doctor-dashboard-page .container,
body.pm-doctor-dashboard-page .wrap {
    max-width: none !important;
}
body.pm-doctor-dashboard-page .entry-content,
body.pm-doctor-dashboard-page .wp-block-post-content {
    width: 100% !important;
    overflow: visible !important;
}
.pm-doctor-dashboard {
    width: min(1200px, calc(100vw - 32px)) !important;
    max-width: 1200px !important;
    margin: 28px auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 0;
    position: relative;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    box-sizing: border-box;
    color: #1e293b;
    font-size: 15px;
    line-height: 1.55;
    clear: both;
}
.pm-doctor-dashboard,
.pm-doctor-dashboard * {
    box-sizing: border-box;
}
.pm-doctor-dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 22px 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #dbe7f3;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
.pm-doctor-dashboard-header h1 {
    margin: 0 0 6px;
    font-size: clamp(23px, 2.3vw, 31px);
    line-height: 1.18;
    letter-spacing: -.02em;
    color: #0f172a;
}
.pm-doctor-dashboard-header p {
    margin: 0;
    color: #64748b;
    font-size: 14.5px;
}
.pm-doctor-dashboard .pm-doctor-logout {
    flex: 0 0 auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 10px;
    text-decoration: none;
}
.pm-doctor-dashboard-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
}
.pm-doctor-dashboard-menu a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 15px;
    border-radius: 11px;
    text-decoration: none;
    background: #fff;
    border: 1px solid #dbe3ef;
    color: #1e293b;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.pm-doctor-dashboard-menu a.active,
.pm-doctor-dashboard-menu a:hover,
.pm-doctor-dashboard-menu a:focus {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    box-shadow: 0 5px 14px rgba(34, 113, 177, .22);
    outline: none;
}
.pm-doctor-dashboard-content {
    width: 100%;
    max-width: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
.pm-doctor-dashboard-content .wrap,
.pm-doctor-dashboard-content .pm-wrap {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
}
.pm-doctor-dashboard-content h1,
.pm-doctor-dashboard-content .wp-heading-inline {
    font-size: clamp(22px, 2vw, 28px);
    line-height: 1.25;
    margin-top: 0;
}
.pm-doctor-dashboard .pm-card {
    border-radius: 14px;
    padding: 22px 24px;
}
.pm-doctor-dashboard .pm-card h2 {
    font-size: 16px;
    line-height: 1.3;
}
.pm-doctor-dashboard .pm-field label {
    font-size: 13.5px;
}
.pm-doctor-dashboard input,
.pm-doctor-dashboard select,
.pm-doctor-dashboard textarea {
    min-height: 38px;
    max-width: 100%;
}
.pm-doctor-dashboard textarea {
    line-height: 1.45;
}
.pm-doctor-dashboard .button,
.pm-doctor-dashboard .page-title-action {
    text-decoration: none;
    border-radius: 8px;
}
.pm-doctor-dashboard .pm-table,
.pm-doctor-dashboard .pm-rx-items-table {
    font-size: 13.5px;
}
.pm-doctor-dashboard .pm-table th,
.pm-doctor-dashboard .pm-table td {
    padding-top: 9px;
    padding-bottom: 9px;
}
.pm-doctor-dashboard .pm-med-table-wrap,
.pm-doctor-dashboard .pm-table-wrap,
.pm-doctor-dashboard .pm-rx-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pm-doctor-dashboard-message {
    max-width: 720px;
    margin: 32px auto;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 10px;
}
@media screen and (max-width: 960px) {
    .pm-doctor-dashboard {
        width: calc(100vw - 24px) !important;
        margin-top: 20px !important;
        margin-bottom: 20px !important;
        font-size: 14.5px;
    }
    .pm-doctor-dashboard-header {
        padding: 18px;
    }
    .pm-doctor-dashboard-content {
        padding: 16px;
    }
    .pm-doctor-dashboard .pm-card {
        padding: 18px;
    }
}
@media screen and (max-width: 700px) {
    .pm-doctor-dashboard {
        width: calc(100vw - 16px) !important;
        margin-top: 12px !important;
        margin-bottom: 12px !important;
        font-size: 14px;
    }
    .pm-doctor-dashboard-header {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
        padding: 16px;
        border-radius: 14px;
    }
    .pm-doctor-dashboard .pm-doctor-logout {
        width: 100%;
    }
    .pm-doctor-dashboard-menu {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px;
        border-radius: 14px;
    }
    .pm-doctor-dashboard-menu a {
        width: 100%;
        min-height: 42px;
        padding: 10px 8px;
        font-size: 13.5px;
    }
    .pm-doctor-dashboard-content {
        padding: 12px;
        border-radius: 14px;
    }
    .pm-doctor-dashboard-content h1,
    .pm-doctor-dashboard-content .wp-heading-inline {
        font-size: 22px;
    }
}
@media screen and (max-width: 420px) {
    .pm-doctor-dashboard {
        width: calc(100vw - 10px) !important;
    }
    .pm-doctor-dashboard-menu {
        grid-template-columns: 1fr;
    }
    .pm-doctor-dashboard-header h1 {
        font-size: 22px;
    }
}

/* Trash actions */
.pm-trash-wrap .pm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pm-trash-wrap .pm-card {
    margin-top: 18px;
}

/* Doctor Dashboard width refinement: fill available screen up to 1200px */
body.pm-doctor-dashboard-page .site,
body.pm-doctor-dashboard-page .site-main,
body.pm-doctor-dashboard-page .content-area,
body.pm-doctor-dashboard-page .entry-content,
body.pm-doctor-dashboard-page main,
body.pm-doctor-dashboard-page article {
    max-width: none;
}
body.pm-doctor-dashboard-page .entry-content > .pm-doctor-dashboard,
.pm-doctor-dashboard {
    width: min(1200px, calc(100vw - 28px));
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}
.pm-doctor-dashboard-content {
    width: 100%;
}
@media screen and (max-width: 960px) {
    body.pm-doctor-dashboard-page .entry-content > .pm-doctor-dashboard,
    .pm-doctor-dashboard {
        width: calc(100vw - 20px);
    }
}
@media screen and (max-width: 700px) {
    body.pm-doctor-dashboard-page .entry-content > .pm-doctor-dashboard,
    .pm-doctor-dashboard {
        width: calc(100vw - 12px);
        margin-top: 8px;
        margin-bottom: 8px;
    }
    .pm-doctor-dashboard-content {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ── v1.6.5 All Prescriptions compact layout + view total fix ─────────── */
@media screen and (min-width: 783px) {
    .pm-rx-list-table {
        table-layout: fixed;
        width: 100%;
    }
    .pm-rx-list-table .pm-col-rxno      { width: 10%; }
    .pm-rx-list-table .pm-col-patient   { width: 28%; }
    .pm-rx-list-table .pm-col-age       { width: 5%; }
    .pm-rx-list-table .pm-col-doctor    { width: 10%; }
    .pm-rx-list-table .pm-col-diagnosis { width: 15%; }
    .pm-rx-list-table .pm-col-price     { width: 10%; }
    .pm-rx-list-table .pm-col-date      { width: 11%; }
    .pm-rx-list-table .pm-col-actions   { width: 11%; }

    .pm-rx-list-table th,
    .pm-rx-list-table td {
        padding-left: 7px;
        padding-right: 7px;
        vertical-align: middle;
    }
    .pm-rx-list-table .pm-patient-name-cell {
        font-weight: 600;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
    .pm-rx-list-table .pm-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
        justify-content: flex-start;
        white-space: normal;
        min-width: 108px;
    }
    .pm-rx-list-table .pm-actions .button.pm-compact-action {
        min-height: 24px;
        line-height: 22px;
        padding: 0 5px;
        margin: 0;
        font-size: 11px;
        border-radius: 5px;
    }
}

.pm-rx-items-table tfoot .pm-total-row {
    display: table-row !important;
}
.pm-rx-items-table tfoot .pm-total-row td {
    white-space: nowrap;
    vertical-align: middle;
}
.pm-rx-items-table tfoot .pm-grand-total,
.pm-rx-items-table tfoot .pm-grand-total strong {
    white-space: nowrap;
    min-width: 140px;
    display: inline-block;
}


/* ── v1.6.6 compact action buttons and clearer Trash button ───────────── */
@media screen and (min-width: 783px) {
    .pm-med-list-table {
        table-layout: fixed;
        width: 100%;
    }
    .pm-med-list-table .pm-col-med-name     { width: 38%; }
    .pm-med-list-table .pm-col-med-category { width: 15%; }
    .pm-med-list-table .pm-col-med-unit     { width: 9%; }
    .pm-med-list-table .pm-col-med-price    { width: 12%; }
    .pm-med-list-table .pm-col-med-status   { width: 12%; }
    .pm-med-list-table .pm-col-med-actions  { width: 8%; }
    .pm-med-list-table th,
    .pm-med-list-table td {
        padding-left: 7px;
        padding-right: 7px;
        vertical-align: middle;
    }
    .pm-med-list-table td:not(:first-child) {
        white-space: nowrap;
    }
    .pm-med-list-table .pm-med-actions {
        white-space: nowrap;
        min-width: 58px;
    }
    .pm-mini-action {
        min-width: 24px !important;
        min-height: 22px !important;
        line-height: 20px !important;
        padding: 0 4px !important;
        margin: 0 1px !important;
        font-size: 12px !important;
        border-radius: 5px !important;
        text-align: center;
    }
    .pm-patient-table .pm-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
        min-width: 116px;
    }
    .pm-patient-action {
        min-height: 24px !important;
        line-height: 22px !important;
        padding: 0 7px !important;
        font-size: 11.5px !important;
        border-radius: 5px !important;
        margin: 0 !important;
    }
}
.pm-rx-list-table .pm-actions .pm-btn-delete {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
    box-shadow: none !important;
}
.pm-rx-list-table .pm-actions .pm-btn-delete:hover,
.pm-rx-list-table .pm-actions .pm-btn-delete:focus {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
    color: #ffffff !important;
}
