:root {
    --nav: #0e1d31;
    --blue: #1f5f99;
    --blue2: #2b6fae;
    --bg: #f5f7fa;
    --text: #162235;
    --muted: #6d7d91;
    --line: #dfe5ec;
    --white: #fff;
    --green: #1e9b6b;
    --red: #d9534f;
    --amber: #b57900
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    color: var(--text);
    background: var(--bg)
}

button,
input,
select,
textarea {
    font: inherit
}

.app {
    display: flex;
    min-height: 100vh
}

.side {
    width: 280px;
    background: var(--nav);
    color: #fff;
    padding: 18px 14px;
    position: fixed;
    inset: 0 auto 0 0;
    overflow: auto
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 22px
}

.logo {
    width: 46px;
    height: 46px;
    border-radius: 9px;
    background: #183b63;
    display: grid;
    place-items: center;
    font-size: 24px
}

.brand b {
    font-size: 19px
}

.brand small {
    display: block;
    letter-spacing: 2px;
    color: #88a4c1;
    font-size: 9px;
    margin-top: 4px
}

.org {
    border: 1px solid #30445d;
    border-radius: 10px;
    padding: 13px;
    margin: 4px 0 20px;
    background: #14263d
}

.org small {
    color: #79d3ad;
    letter-spacing: 1.4px
}

.nav a {
    display: block;
    color: #c7d3e0;
    text-decoration: none;
    padding: 12px 13px;
    border-radius: 8px;
    margin: 4px 0;
    cursor: pointer
}

.nav a.active,
.nav a:hover {
    background: #1d3656;
    color: #fff
}

.section {
    font-size: 10px;
    letter-spacing: 1.4px;
    color: #71869d;
    margin: 22px 13px 7px
}

.main {
    margin-left: 280px;
    flex: 1
}

.top {
    height: 72px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 4
}

.search {
    width: 490px;
    background: #f2f5f8;
    border-radius: 9px;
    padding: 11px 15px;
    color: #718198
}

.user {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 600
}

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #edf0f4;
    display: grid;
    place-items: center
}

.content {
    padding: 30px 42px;
    max-width: 1550px
}

.eyebrow {
    font-size: 12px;
    color: #0096C7;
    letter-spacing: .7px;
    font-weight: 700
}

.eyebrow span {
    color: var(--text-muted, #64748B);
}

.head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px
}

.head h1 {
    font-size: 30px;
    margin: 8px 0
}

.head p {
    color: var(--muted);
    margin: 0 0 24px
}

.greetings,
.patient-page-title {
    font-size: 26px;
    letter-spacing: -0.25px;
    font-weight: 600;
    color: var(--gray-900, #111);
    margin-bottom: 4px;
}

.btn {
    border: 0;
    background: var(--blue);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer
}

.btn:hover {
    background: var(--blue2)
}

.btn.secondary {
    background: #fff;
    color: #23405e;
    border: 1px solid #cfd8e3
}

.btn.danger {
    background: #fff;
    color: #b33a35;
    border: 1px solid #e5b4b1
}

.btn.green {
    background: var(--green)
}


.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden
}

.card {
    padding: 22px;
    border-right: 1px solid var(--line)
}

.card:last-child {
    border: 0
}

.card small {
    color: var(--muted)
}

.card strong {
    display: block;
    font-size: 28px;
    margin: 10px 0 2px
}

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-top: 25px;
    padding: 22px
}

.panel h2 {
    font-size: 18px;
    margin: 0 0 16px
}

.table {
    width: 100%;
    border-collapse: collapse
}

.table th,
.table td {
    text-align: left;
    padding: 13px 10px;
    border-bottom: 1px solid #edf0f3;
    font-size: 14px;
    vertical-align: top
}

.table th {
    color: #718198;
    font-size: 12px
}

.pill {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 20px;
    background: #eaf6f1;
    color: #17845b;
    font-size: 11px;
    font-weight: 700
}

.pill.blue {
    background: #edf4fb;
    color: #1f5f99
}

.pill.amber {
    background: #fff5dc;
    color: #986a00
}

.pill.red {
    background: #fdeceb;
    color: #b23b35
}

.grid2 {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 22px
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px
}

.searchbox {
    display: flex;
    gap: 10px;
    margin-bottom: 15px
}

.input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    background: #fff
}

.formgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

.formgrid .full {
    grid-column: 1/-1
}

label {
    font-size: 12px;
    color: #66788d;
    font-weight: 700;
    display: block;
    margin-bottom: 6px
}

.modal {
    position: fixed;
    inset: 0;
    background: #0c182633;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10
}

.modal.open {
    display: flex
}

.modalbox {
    background: #fff;
    border-radius: 14px;
    width: min(820px, 94vw);
    max-height: 92vh;
    overflow: auto;
    padding: 24px
}

.modalhead {
    display: flex;
    justify-content: space-between;
    align-items: center
}

.modalhead h2 {
    margin: 0
}

.viewer {
    height: 650px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6
}

.viewer iframe {
    width: 100%;
    height: 100%;
    border: 0
}

.muted {
    color: var(--muted)
}

.row-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    flex-wrap: wrap
}

.tab {
    border: 0;
    background: none;
    padding: 11px 15px;
    color: #6a7a8d;
    font-weight: 700;
    cursor: pointer
}

.tab.active {
    color: var(--blue);
    border-bottom: 2px solid var(--blue)
}

.patient-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px
}

.tag {
    font-size: 11px;
    color: #58718c
}

.empty {
    padding: 30px;
    text-align: center;
    color: var(--muted)
}

.notice {
    position: fixed;
    top: 82px;
    right: 28px;
    z-index: 20;
    max-width: 540px;
    padding: 12px 16px;
    border-radius: 8px;
    background: #fff1f0;
    color: #9e2d28;
    border: 1px solid #efc0bd;
    box-shadow: 0 5px 20px #15253b1a;
    font-weight: 600;
    display: none
}

.notice.success {
    background: #edf9f4;
    color: #167a57;
    border-color: #b8e5d2
}

.statline {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f3
}

.statline:last-child {
    border: 0
}

.receipt {
    width: 100%;
    max-width: 760px;
    margin: auto;
    background: #fff;
    padding: 34px;
    border: 1px solid #ddd
}

.medicine-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px
}

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #f4f6f8
}

.loginbox {
    width: min(540px, 92vw);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 34px;
    box-shadow: 0 10px 35px #18283d12
}

.loginbrand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px
}

.loginbrand .logo {
    color: #8ac8ff
}

.rolecards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0 18px
}

.role {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    text-align: left
}

.role.active {
    border-color: var(--blue);
    background: #edf4fb
}

.hide {
    display: none !important
}

.compounder-mobile {
    display: none
}

.mobile-bottom {
    display: none
}

/* =========================================================
   BRAND
========================================================= */

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 9px;

    background: #0096C7;
    color: #FFFFFF;

    font-size: 1rem;
    font-weight: 700;
}


/* Product name */

.brand-text {
    min-width: 0;
}

.brand-name {
    color: var(--text-color, #acb6cc);

    font-size: 1rem;
    font-weight: 750;
    line-height: 1.15;

    letter-spacing: -0.02em;
}

.brand-accent {
    color: #0096C7;
}


/* Company label */

.brand-company {
    margin-top: 3px;

    color: var(--text-muted, #64748B);

    font-size: 0.58rem;
    font-weight: 700;

    line-height: 1;

    letter-spacing: 0.105em;
}

/* =========================================================
   PATIENTS PAGE
========================================================= */

.patient-page-title {
    margin: 0;

    color: var(--text-color, #111827);

    font-size: 1.45rem;
    font-weight: 750;
    line-height: 1.2;

    letter-spacing: -0.025em;
}


.patient-panel {
    margin-top: 18px;
}


/* ---------------------------------------------------------
   SEARCH
--------------------------------------------------------- */

.patient-search {
    display: flex;
    align-items: center;

    gap: 10px;

    margin-bottom: 18px;
}

.patient-search .input {
    flex: 1;
    min-width: 0;
}

.patient-search .btn {
    flex: 0 0 auto;

    min-height: 40px;

    padding: 8px 15px;

    font-size: 0.79rem;
    font-weight: 650;

    border-radius: 8px;
}

@media(max-width:900px) {
    .side {
        width: 220px
    }

    .main {
        margin-left: 220px
    }

    .cards {
        grid-template-columns: 1fr 1fr
    }

    .grid2,
    .grid3 {
        grid-template-columns: 1fr
    }

    .search {
        width: 300px
    }
}

@media(max-width:650px) {
    .side {
        display: none
    }

    .main {
        margin-left: 0
    }

    .content {
        padding: 16px 12px 82px
    }

    .top {
        padding: 0 12px;
        height: 62px
    }

    .search {
        display: none
    }

    .cards {
        grid-template-columns: 1fr 1fr
    }

    .card {
        padding: 14px
    }

    .card strong {
        font-size: 23px
    }

    .formgrid {
        grid-template-columns: 1fr
    }

    .formgrid .full {
        grid-column: auto
    }

    .medicine-row {
        grid-template-columns: 1fr 1fr
    }

    .medicine-row .medname {
        grid-column: 1/-1
    }

    .medicine-row button {
        grid-column: 1/-1
    }

    .compounder-desktop {
        display: none !important
    }

    .compounder-mobile {
        display: block
    }

    .mobile-bottom {
        position: fixed;
        display: flex;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid var(--line);
        z-index: 8;
        padding: 7px 5px;
        justify-content: space-around
    }

    .mobile-bottom button {
        border: 0;
        background: none;
        color: #536a82;
        font-size: 11px;
        font-weight: 700;
        padding: 6px
    }

    .mobile-bottom button.active {
        color: var(--blue)
    }

    .modalbox {
        width: calc(100vw - 20px);
        padding: 18px
    }

    .viewer {
        height: 70vh
    }

    .table {
        font-size: 12px
    }

    .table th,
    .table td {
        padding: 9px 7px
    }

    .head {
        align-items: flex-start
    }

    .head h1 {
        font-size: 25px
    }

    .row-actions .btn {
        padding: 9px 11px
    }

    .compounder-card {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 14px;
        margin-bottom: 12px
    }

    .compounder-card h3 {
        margin: 0 0 5px
    }

    .compounder-card .mini {
        display: flex;
        justify-content: space-between;
        padding: 7px 0;
        border-bottom: 1px solid #edf0f3
    }

    .compounder-card .mini:last-child {
        border-bottom: 0
    }
}

@media print {

    .side,
    .top,
    .no-print {
        display: none !important
    }

    .main {
        margin: 0
    }

    .content {
        padding: 0
    }

    .panel {
        border: 0
    }

    .receipt {
        border: 0
    }
}

/* =========================================================
   MODALS
========================================================= */

.modalhead {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 14px;

    margin-bottom: 14px;

    padding-bottom: 14px;

    border-bottom: 1px solid var(--line, #e5e7eb);
}

.modalhead h2 {
    margin: 0;

    color: var(--text-color, #111827);

    font-size: 1.12rem;
    font-weight: 750;
    line-height: 1.2;
}


/* ---------------------------------------------------------
   DOCTOR INSTRUCTION MODAL
--------------------------------------------------------- */

.instruction-modal {
    width: 100%;
}

.instruction-intro {
    margin: 0 0 18px;

    color: var(--muted, #718198);

    font-size: 0.79rem;
    line-height: 1.5;
}


/* ---------------------------------------------------------
   FORM
--------------------------------------------------------- */

.instruction-modal .formgrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 14px;
}

.instruction-modal .formgrid .full {
    grid-column: 1 / -1;
}

.instruction-modal label {
    display: block;

    margin-bottom: 5px;

    color: var(--text-color, #111827);

    font-size: 0.76rem;
    font-weight: 650;
}

.instruction-modal .input {
    width: 100%;
    min-width: 0;

    box-sizing: border-box;
}


/* ---------------------------------------------------------
   MEDICINES
--------------------------------------------------------- */

.medicine-section {
    margin-top: 4px;
}

.medicine-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 10px;
}

.medicine-section-title {
    color: var(--text-color, #111827);

    font-size: 0.82rem;
    font-weight: 700;
}


/* Medicine row */

.medicine-row {
    display: grid;

    grid-template-columns:
        minmax(160px, 1.5fr) minmax(100px, 1fr) minmax(100px, 1fr) minmax(100px, 1fr) minmax(80px, 0.7fr) auto;

    gap: 8px;

    align-items: center;

    margin-bottom: 9px;
    padding: 10px;

    border: 1px solid var(--line, #e5e7eb);
    border-radius: 10px;

    background: var(--surface-soft, #f8fafc);
}


/* Remove */

.medicine-row .btn.danger {
    min-height: 38px !important;

    padding: 7px 10px !important;

    font-size: 0.72rem !important;

    white-space: nowrap;
}


/* Add medicine */

.modal-add-medicine {
    margin-top: 5px;

    min-height: 38px !important;

    padding: 7px 11px !important;

    font-size: 0.74rem !important;
}


/* ---------------------------------------------------------
   MODAL FOOTER
--------------------------------------------------------- */

.instruction-actions {
    display: flex;
    justify-content: flex-end;

    margin-top: 18px;
    padding-top: 14px;

    border-top: 1px solid var(--line, #e5e7eb);
}

.instruction-submit {
    min-height: 42px !important;

    padding: 9px 15px !important;

    font-size: 0.78rem !important;
    font-weight: 650 !important;
}


/* ---------------------------------------------------------
   MOBILE
--------------------------------------------------------- */

@media (max-width: 768px) {

    .modalhead {
        gap: 10px;
        padding-bottom: 12px;
    }

    .modalhead h2 {
        font-size: 1rem;
    }


    /* Modal content */

    .instruction-modal {
        width: 100%;
        min-width: 0;
    }

    .instruction-intro {
        font-size: 0.76rem;
        line-height: 1.45;
    }


    /* Form */

    .instruction-modal .formgrid {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .instruction-modal .formgrid .full {
        grid-column: auto;
    }


    /* -----------------------------------------------------
       MEDICINE ROW
    ----------------------------------------------------- */

    .medicine-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));

        gap: 8px;

        padding: 10px;
    }

    .medicine-row .imedname {
        grid-column: 1 / -1;
    }

    .medicine-row .imedpot,
    .medicine-row .imeddose,
    .medicine-row .imedfreq,
    .medicine-row .imedqty {
        width: 100%;
        min-width: 0;
    }

    .medicine-row .btn.danger {
        grid-column: 1 / -1;

        width: 100% !important;
    }


    /* Add medicine */

    .modal-add-medicine {
        width: 100% !important;
    }


    /* Submit */

    .instruction-actions {
        margin-top: 14px;
        padding-top: 12px;
    }

    .instruction-submit {
        width: 100% !important;
    }

}

.loginbox .error {
    margin: 10px 0;
    padding: 10px;
    border-radius: 8px;
    background: #fff1f0;
    color: #9e2d28;
    border: 1px solid #efc0bd
}

.logoutbtn {
    margin-left: 8px;
    padding: 7px 10px
}

.header-action {
    width: auto !important;

    min-height: 38px !important;

    padding: 8px 13px !important;

    font-size: 0.78rem !important;
    font-weight: 650 !important;

    line-height: 1.2 !important;

    white-space: nowrap;

    border-radius: 8px !important;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    margin-bottom: 6px;
}

.table-scroll::-webkit-scrollbar {
    height: 6px;
}

.table-scroll::-webkit-scrollbar-track {
    background: #f1f4f8;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: #c5d0de;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ab0c9;
}

/* Ensure all tables take 100% width across full screen on desktop/tablet */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table-scroll .table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
}

/* =========================================================
   PAYMENTS
========================================================= */

.payments-panel {
    margin-top: 18px;
}


/* ---------------------------------------------------------
   TABLE
--------------------------------------------------------- */

.payment-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.payment-table {
    width: 100%;
    min-width: 900px;

    table-layout: auto;
}

.payment-table th,
.payment-table td {
    white-space: nowrap;
}


/* ---------------------------------------------------------
   RECEIPT
--------------------------------------------------------- */

.receipt-number {
    color: var(--text-color, #111827);

    font-size: 0.82rem;
    font-weight: 650;

    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}


/* ---------------------------------------------------------
   AMOUNT
--------------------------------------------------------- */

.payment-amount {
    color: var(--text-color, #111827);

    font-size: 0.88rem;
    font-weight: 750;
}


/* ---------------------------------------------------------
   PAYMENT MODE
--------------------------------------------------------- */

.payment-mode {
    display: inline-flex;
    align-items: center;

    min-width: 48px;
    justify-content: center;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 0.7rem;
    font-weight: 700;
}

.payment-mode.upi {
    background: rgba(37, 99, 235, 0.10);
    color: #2563EB;
}

.payment-mode.cash {
    background: rgba(72, 187, 120, 0.11);
    color: #2F855A;
}


/* ---------------------------------------------------------
   ACTION
--------------------------------------------------------- */

.payment-action {
    min-height: 34px !important;

    padding: 6px 10px !important;

    font-size: 0.73rem !important;
    white-space: nowrap;
}

/* =========================================================
   USERS & ACCESS
========================================================= */

.users-panel {
    margin-top: 18px;

    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.users-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.users-table {
    width: 100%;
    min-width: 760px;

    table-layout: auto;
}

.users-table th,
.users-table td {
    white-space: nowrap;
}

.user-email {
    color: var(--muted);
    font-size: 0.82rem;
}

.role-pill {
    display: inline-flex;
    align-items: center;

    padding: 4px 8px;

    border-radius: 999px;

    background: rgba(0, 150, 199, 0.09);
    color: #0096C7;

    font-size: 0.7rem;
    font-weight: 700;
}

.user-action {
    min-height: 34px !important;

    padding: 6px 10px !important;

    font-size: 0.73rem !important;
    white-space: nowrap;
}

/* =========================================================
   PRESCRIPTIONS
========================================================= */

.prescriptions-panel {
    margin-top: 18px;

    width: 100%;
    max-width: 100%;

    box-sizing: border-box;
}

.prescriptions-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.prescription-table {
    width: 100%;
    min-width: 900px;

    table-layout: auto;
}


/* ---------------------------------------------------------
   CELLS
--------------------------------------------------------- */

.prescription-table th,
.prescription-table td {
    white-space: nowrap;
}

.prescription-title {
    min-width: 220px;
    max-width: 320px;

    white-space: normal !important;

    line-height: 1.4;
}


/* ---------------------------------------------------------
   ACTIONS
--------------------------------------------------------- */

.prescription-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.prescription-action {
    min-height: 34px !important;

    padding: 6px 10px !important;

    font-size: 0.72rem !important;

    white-space: nowrap;
}

@media (max-width: 768px) {

    .prescriptions-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box;

        overflow: visible !important;
    }

    .prescriptions-table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box;

        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    .prescription-table {
        display: table !important;

        width: 920px !important;
        min-width: 920px !important;
        max-width: none !important;

        table-layout: auto !important;
    }

    .prescription-table th,
    .prescription-table td {
        white-space: nowrap !important;
    }

    .prescription-table .prescription-title {
        white-space: normal !important;

        min-width: 220px;
        max-width: 320px;
    }

}

/* =========================================================
   APPOINTMENTS
========================================================= */

.appointments-panel {
    margin-top: 18px;

    width: 100%;
    max-width: 100%;

    box-sizing: border-box;
}

.appointments-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.appointments-table {
    width: 100%;
    min-width: 820px;

    table-layout: auto;
}

.appointments-table th,
.appointments-table td {
    white-space: nowrap;
}


/* Time */

.appointment-time {
    color: var(--text-color, #111827);

    font-size: 0.82rem;
    font-weight: 650;
}


/* Actions */

.appointment-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.appointment-action {
    min-height: 34px !important;

    padding: 6px 10px !important;

    font-size: 0.72rem !important;

    white-space: nowrap;
}

@media (max-width: 768px) {

    .appointments-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box;

        overflow: visible !important;
    }

    .appointments-table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box;

        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    .appointments-table {
        display: table !important;

        width: 820px !important;
        min-width: 820px !important;
        max-width: none !important;

        table-layout: auto !important;
    }

    .appointments-table th,
    .appointments-table td {
        white-space: nowrap !important;
    }

}

/* =========================================================
   APPOINTMENT MODAL
========================================================= */

.appointment-modal {
    width: 100%;
    min-width: 0;
}


/* ---------------------------------------------------------
   MODAL SUBTITLE
--------------------------------------------------------- */

.modal-subtitle {
    margin-top: 4px;

    color: var(--muted, #718198);

    font-size: 0.76rem;
    line-height: 1.4;
}


/* ---------------------------------------------------------
   FORM
--------------------------------------------------------- */

.appointment-formgrid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 14px;
}

.appointment-formgrid .full {
    grid-column: 1 / -1;
}

.appointment-formgrid label {
    display: block;

    margin-bottom: 5px;

    color: var(--text-color, #111827);

    font-size: 0.76rem;
    font-weight: 650;
}

.appointment-formgrid .input {
    width: 100%;
    min-width: 0;

    box-sizing: border-box;
}


/* ---------------------------------------------------------
   ACTIONS
--------------------------------------------------------- */

.appointment-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 8px;

    margin-top: 18px;
    padding-top: 14px;

    border-top: 1px solid var(--line, #e5e7eb);
}

.appointment-actions .btn {
    min-height: 40px !important;

    padding: 8px 13px !important;

    font-size: 0.77rem !important;
}


/* ---------------------------------------------------------
   MOBILE
--------------------------------------------------------- */

@media (max-width: 768px) {

    .appointment-modal {
        width: 100%;
        min-width: 0;
    }

    .appointment-formgrid {
        grid-template-columns: 1fr;

        gap: 11px;
    }

    .appointment-formgrid .full {
        grid-column: auto;
    }


    .appointment-actions {
        flex-direction: column-reverse;

        align-items: stretch;

        gap: 8px;

        margin-top: 14px;
        padding-top: 12px;
    }

    .appointment-actions .btn {
        width: 100% !important;
    }

}

/* =========================================================
   CHANGE PASSWORD
========================================================= */

.password-modal {
    width: 100%;
    min-width: 0;
}

.password-form {
    display: grid;
    gap: 14px;
}

.password-form label {
    display: block;

    margin-bottom: 5px;

    color: var(--text-color, #111827);

    font-size: 0.76rem;
    font-weight: 650;
}

.password-form .input {
    width: 100%;
    min-width: 0;

    box-sizing: border-box;
}

.password-hint {
    margin-top: 10px;

    color: var(--muted, #718198);

    font-size: 0.74rem;
    line-height: 1.45;
}

.password-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 8px;

    margin-top: 18px;
    padding-top: 14px;

    border-top: 1px solid var(--line, #e5e7eb);
}

.password-actions .btn {
    min-height: 40px !important;

    padding: 8px 13px !important;

    font-size: 0.77rem !important;
}


@media (max-width: 768px) {

    .password-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .password-actions .btn {
        width: 100% !important;
    }

}

/* =========================================================
   SETTINGS - SECURITY
========================================================= */

.security-section {
    margin-top: 28px;
}

.settings-section-header {
    margin-bottom: 12px;
}

.settings-section-header h2 {
    margin: 0;

    color: var(--text-color, #111827);

    font-size: 1rem;
    font-weight: 750;
}

.security-card {
    display: flex;
    align-items: center;

    gap: 13px;

    padding: 16px 18px;

    border: 1px solid var(--line, #e5e7eb);
    border-radius: 12px;

    background: var(--surface, #ffffff);
}

.security-icon {
    width: 36px;
    height: 36px;

    flex: 0 0 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: rgba(0, 150, 199, 0.09);
    color: #0096C7;

    font-size: 0.9rem;
}

.security-content {
    flex: 1;
    min-width: 0;
}

.security-title {
    color: var(--text-color, #111827);

    font-size: 0.83rem;
    font-weight: 700;
}

.security-description {
    margin-top: 3px;

    color: var(--muted, #718198);

    font-size: 0.74rem;
}

.security-button {
    flex: 0 0 auto;

    min-height: 36px !important;

    padding: 7px 11px !important;

    font-size: 0.74rem !important;
}


@media (max-width: 768px) {

    .security-card {
        align-items: flex-start;

        flex-wrap: wrap;
    }

    .security-content {
        flex: 1 1 calc(100% - 55px);
    }

    .security-button {
        width: 100% !important;
        margin-top: 4px;
    }

}

@media (max-width: 768px) {

    .users-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box;

        overflow: visible !important;
    }

    .users-table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box;

        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    .users-table {
        display: table !important;

        width: 760px !important;
        min-width: 760px !important;
        max-width: none !important;

        table-layout: auto !important;
    }

    .users-table th,
    .users-table td {
        white-space: nowrap !important;
    }
}

/* =========================================================
   AUDIT LOG
========================================================= */

.audit-panel {
    margin-top: 18px;

    width: 100%;
    max-width: 100%;

    box-sizing: border-box;
}

.audit-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.audit-table {
    width: 100%;
    min-width: 820px;

    table-layout: auto;
}

.audit-table th,
.audit-table td {
    vertical-align: top;
}

.audit-table th,
.audit-table td {
    white-space: nowrap;
}


/* ---------------------------------------------------------
   DATE
--------------------------------------------------------- */

.audit-date {
    color: var(--muted);

    font-size: 0.78rem;
    white-space: nowrap;
}


/* ---------------------------------------------------------
   USER
--------------------------------------------------------- */

.audit-user {
    color: var(--text-color, #111827);

    font-size: 0.82rem;
    font-weight: 650;
}


/* ---------------------------------------------------------
   ACTION
--------------------------------------------------------- */

.audit-action {
    display: inline-flex;
    align-items: center;

    padding: 5px 8px;

    border-radius: 7px;

    background: rgba(0, 150, 199, 0.09);
    color: #0096C7;

    font-size: 0.7rem;
    font-weight: 700;
}


/* ---------------------------------------------------------
   DETAILS
--------------------------------------------------------- */

.audit-details {
    min-width: 300px;
    max-width: 500px;

    color: var(--text-color, #111827);

    font-size: 0.8rem;
    line-height: 1.45;

    white-space: normal;
}

@media (max-width: 768px) {

    .audit-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box;

        overflow: visible !important;
    }

    .audit-table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box;

        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    .audit-table {
        display: table !important;

        width: 820px !important;
        min-width: 820px !important;
        max-width: none !important;

        table-layout: auto !important;
    }

    .audit-table th,
    .audit-table td {
        white-space: nowrap !important;
    }

    .audit-table .audit-details {
        white-space: normal !important;
        min-width: 300px;
        max-width: 500px;
    }
}

@media (max-width: 768px) {

    /* Prevent horizontal overflow */

    .upload-p {
        max-width: 400px;
        font-size: 10px;
    }

    html,
    body {
        overflow-x: hidden;
    }



    .tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .tabs::-webkit-scrollbar {
        height: 4px;
    }

    .tabs::-webkit-scrollbar-thumb {
        background: #cfd8e3;
        border-radius: 4px;
    }

    .patient-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-action {
        min-height: 36px !important;
        padding: 7px 11px !important;

        font-size: 0.74rem !important;
    }


    /* -----------------------------------------------------
       MAIN CONTENT
    ----------------------------------------------------- */


    .head-description {
        font-size: 14px;
    }


    /* -----------------------------------------
       SEARCH
    ----------------------------------------- */

    .top {
        position: relative;

        width: 100%;
        max-width: 100%;
        min-width: 0;

        height: 52px;

        box-sizing: border-box;

        display: flex;
        align-items: center;
        justify-content: space-between;

        padding: 8px 10px;

        margin: 0;
    }


    /* -----------------------------------------
       USER BAR
    ----------------------------------------- */
    .top .user {
        grid-area: user;

        position: static !important;

        width: 100%;
        max-width: 100%;
        min-width: 0;

        box-sizing: border-box;

        display: flex;
        flex-direction: row;

        align-items: center;
        justify-content: flex-end;

        gap: 7px;

        padding: 0;
    }

    .top .search {
        display: none;
    }


    /* Avatar */

    .top .avatar {
        display: none;
    }


    /* Username */

    .top #currentUser {
        display: none;
    }


    /* Switch user */

    .top #switchUser {
        flex: 0 0 auto;
        position: fixed;
        margin-left: 0 !important;

        padding: 6px 9px !important;

        min-height: 32px !important;

        font-size: 0.68rem !important;
        line-height: 1 !important;

        white-space: nowrap;

        border-radius: 8px !important;
    }


    /* -----------------------------------------------------
       KPI CARDS
    ----------------------------------------------------- */

    .cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        width: 100%;
        box-sizing: border-box;
    }



    .main {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin-left: 0 !important;
        flex: 1 1 auto !important;

        box-sizing: border-box !important;
    }

    /* Mobile content width */
    .content {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        padding: 14px !important;

        box-sizing: border-box !important;
    }

    /* Patient panel */
    .patient-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box !important;
        overflow: visible !important;
    }

    /* Search */
    .patient-search {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;

        box-sizing: border-box !important;
    }

    .patient-search .input,
    .patient-search .btn {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box !important;
    }

    /* Patient table mount */
    #pt {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow: visible !important;
        box-sizing: border-box !important;
    }

    /*
       THIS is the horizontal scrolling viewport.
    */
    #pt .table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box !important;

        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
    }

    /*
       Deliberately make the table wider than the phone.
       The wrapper above will scroll it.
    */
    #pt .table-scroll .patient-table {
        display: table !important;

        width: 760px !important;
        min-width: 760px !important;
        max-width: none !important;

        table-layout: auto !important;

        border-collapse: collapse !important;
    }

    /* Prevent columns from collapsing */
    #pt .patient-table th,
    #pt .patient-table td {
        white-space: nowrap !important;
    }

    #pt .patient-table .btn.secondary {
        padding: 0;
        font-size: 10px;
        /* boder: none; */
    }


    /* -----------------------------------------------------
       QUICK WORKFLOW
    ----------------------------------------------------- */

    .row-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .row-actions .btn {
        width: 100%;
    }


    /* -----------------------------------------------------
       TOUCH TARGETS
    ----------------------------------------------------- */

    button,
    .btn,
    input,
    select,
    textarea {
        min-height: 44px;
    }


    /* -----------------------------------------------------
       TYPOGRAPHY
    ----------------------------------------------------- */

    .content h1 {
        font-size: 1.55rem;
        line-height: 1.2;
    }

    .content h2 {
        font-size: 1.05rem;
    }


    /* -----------------------------------------------------
       KPI NUMBERS
    ----------------------------------------------------- */

    .card strong {
        font-size: 1.65rem;
    }

    /* =========================================================
   RESPONSIVE PAGE HEADER
========================================================= */

    .head {
        width: 100%;
        box-sizing: border-box;

        display: flex;
        flex-direction: column;

        align-items: stretch;
        justify-content: flex-start;

        gap: 12px;

        margin-bottom: 14px;
        overflow-x: auto;
    }


    /* Title section */

    .head>div:first-child {
        width: 100%;
        min-width: 0;
    }


    /* Page title */

    .head h1 {
        margin: 5px 0 6px;

        font-size: 1.45rem;
        line-height: 1.2;

        letter-spacing: -0.025em;
    }


    /* Subtitle */

    .head p {
        margin: 0;

        font-size: 0.8rem;
        line-height: 1.45;
    }


    /* Action wrapper */

    .head>div:last-child {
        width: 100%;
        min-width: 0;
    }


    /* Header action */

    .head .header-action {
        width: 100% !important;

        min-height: 38px !important;

        padding: 8px 12px !important;

        font-size: 0.75rem !important;
    }

    .payments-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;

        box-sizing: border-box;

        overflow: visible !important;
    }

    .payment-table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box;

        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    .payment-table {
        display: table !important;

        width: 920px !important;
        min-width: 920px !important;
        max-width: none !important;

        table-layout: auto !important;
    }

    .payment-table th,
    .payment-table td {
        white-space: nowrap !important;
    }

}


/* ---------------------------------------------------------
   SMALL PHONES
   --------------------------------------------------------- */

@media (max-width: 480px) {

    .content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .panel {
        padding: 14px;
        border-radius: 12px;
    }

    .card {
        padding: 15px;
        border-radius: 12px;
    }

    .user {
        justify-content: space-between;
    }

    .user #currentUser {
        max-width: 160px;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .head {
        gap: 10px;
    }

    .head h1 {
        font-size: 1.3rem;
    }

    .head p {
        font-size: 0.76rem;
    }

}

/* =========================================================
   MOBILE NAVIGATION
========================================================= */

.mobile-menu-btn {
    display: none;
}


/* Drawer */

.mobile-menu {
    display: none;
}

.mobile-menu-overlay {
    display: none;
}

/* =========================================================
   CONSULTATIONS
========================================================= */

.consultation-panel {
    margin-top: 18px;
}

.consultation-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.consultation-table {
    width: 100%;
    min-width: 900px;

    table-layout: auto;
}

.consultation-table th,
.consultation-table td {
    white-space: nowrap;
}

.consultation-diagnosis {
    white-space: normal !important;

    min-width: 280px;
    max-width: 360px;

    line-height: 1.45;
}

.consultation-diagnosis .muted {
    display: inline-block;
    margin-top: 4px;

    color: var(--muted);
    font-size: 0.78rem;
}

.consultation-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.consultation-actions .btn {
    min-height: 34px !important;

    padding: 6px 10px !important;

    font-size: 0.73rem !important;

    white-space: nowrap;
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 768px) {

    /* -----------------------------
       Hamburger
    ----------------------------- */
    .mobile-menu-btn {
        display: flex;

        width: 34px;
        height: 34px;

        align-items: center;
        justify-content: center;

        flex: 0 0 auto;

        padding: 0;

        border: none;
        border-radius: 8px;

        background: transparent;
        color: var(--text-color, #111827);

        font-size: 1.1rem;

        cursor: pointer;
    }


    .mobile-menu-btn:hover {
        background: rgba(100, 116, 139, 0.10);
    }


    /* -----------------------------
       Overlay
    ----------------------------- */

    .mobile-menu-overlay {
        position: fixed;

        inset: 0;

        z-index: 9998;

        background: rgba(15, 23, 42, 0.40);

        opacity: 0;
        visibility: hidden;

        transition:
            opacity 0.2s ease,
            visibility 0.2s ease;
    }


    .mobile-menu-overlay.open {
        opacity: 1;
        visibility: visible;
    }


    /* -----------------------------
       Drawer
    ----------------------------- */

    .mobile-menu {
        position: fixed;

        top: 0;
        left: 0;
        bottom: 0;

        z-index: 9999;

        width: min(300px, 82vw);

        display: flex;
        flex-direction: column;

        background: var(--surface, #ffffff);

        border-right: 1px solid var(--line, #e5e7eb);

        box-shadow: 12px 0 35px rgba(15, 23, 42, 0.15);

        transform: translateX(-100%);

        transition: transform 0.22s ease;

        overflow-y: auto;
    }


    .mobile-menu.open {
        transform: translateX(0);
    }


    /* -----------------------------
       Drawer header
    ----------------------------- */

    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;

        padding: 18px 16px;

        border-bottom: 1px solid var(--line, #e5e7eb);
    }


    .mobile-menu-title {
        color: var(--text-color, #111827);

        font-size: 1rem;
        font-weight: 750;
    }


    .mobile-menu-subtitle {
        margin-top: 3px;

        color: var(--muted, #718198);

        font-size: 0.72rem;
    }


    .mobile-menu-close {
        width: 32px;
        height: 32px;

        border: 0;
        border-radius: 8px;

        background: transparent;

        color: var(--muted, #718198);

        font-size: 1.35rem;

        cursor: pointer;
    }


    .mobile-menu-close:hover {
        background: rgba(100, 116, 139, 0.10);
    }


    /* -----------------------------
       Menu body
    ----------------------------- */

    .mobile-menu-body {
        padding: 10px;
    }


    .mobile-menu-group {
        margin-top: 14px;
        margin-bottom: 6px;

        padding: 7px 9px;

        color: var(--muted, #718198);

        font-size: 0.66rem;
        font-weight: 750;

        text-transform: uppercase;
        letter-spacing: 0.07em;
    }


    .mobile-menu-item {
        width: 100%;

        display: flex;
        align-items: center;

        gap: 10px;

        padding: 11px 10px;

        border: 0;
        border-radius: 9px;

        background: transparent;

        color: var(--text-color, #111827);

        font-size: 0.84rem;
        font-weight: 550;

        text-align: left;

        cursor: pointer;
    }


    .mobile-menu-item:hover {
        background: rgba(100, 116, 139, 0.08);
    }


    .mobile-menu-item.active {
        background: rgba(0, 150, 199, 0.10);

        color: #0096C7;

        font-weight: 650;
    }


    .mobile-menu-icon {
        width: 25px;

        text-align: center;

        font-size: 0.95rem;
    }


    /* -----------------------------
       Bottom navigation
    ----------------------------- */

    .mobile-bottom {
        position: fixed;

        left: 0;
        right: 0;
        bottom: 0;

        z-index: 9990;

        display: grid;
        grid-template-columns: repeat(4, 1fr);

        padding:
            7px 6px calc(7px + env(safe-area-inset-bottom));

        background: var(--surface, #ffffff);

        border-top: 1px solid var(--line, #e5e7eb);

        box-shadow: 0 -5px 18px rgba(15, 23, 42, 0.08);
    }


    .mobile-bottom button {
        min-height: 48px;

        border: 0;
        border-radius: 9px;

        background: transparent;

        color: var(--muted, #718198);

        font-size: 0.64rem;
        font-weight: 600;

        line-height: 1.35;

        cursor: pointer;
    }


    .mobile-bottom button:hover,
    .mobile-bottom button.active {
        background: rgba(0, 150, 199, 0.08);

        color: #0096C7;
    }


    /* Make room for fixed bottom bar */
    .main {
        padding-bottom: 76px;
    }

    .consultation-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        box-sizing: border-box;

        overflow: visible !important;
    }

    .consultation-table-scroll {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        box-sizing: border-box;

        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    .consultation-table {
        display: table !important;

        width: 920px !important;
        min-width: 920px !important;
        max-width: none !important;

        table-layout: auto !important;
    }

    .consultation-table th,
    .consultation-table td {
        white-space: nowrap !important;
    }

    .consultation-table .consultation-diagnosis {
        white-space: normal !important;

        min-width: 280px;
        max-width: 360px;
    }


}

/* =========================================================
   XipherDrConsult v3.0 Mobile-First UX
   ========================================================= */
.mobile-account-btn,
.mobile-account-sheet {
    display: none
}

.avatar {
    cursor: pointer
}

@media (max-width: 768px) {
    body {
        background: #f5f7fa;
        overflow-x: hidden
    }

    .side {
        display: none !important
    }

    .app {
        display: block;
        min-height: 100vh
    }

    .main {
        margin-left: 0;
        padding-bottom: 88px;
        min-width: 0
    }

    .top {
        height: 62px;
        padding: 0 14px;
        position: sticky;
        top: 0;
        z-index: 1000;
        gap: 10px
    }

    .mobile-menu-btn {
        display: grid !important;
        place-items: center;
        width: 42px;
        height: 42px;
        border: 0;
        background: transparent;
        color: var(--text);
        font-size: 24px;
        border-radius: 10px
    }

    .mobile-menu-btn:active {
        background: #eef3f8
    }


    .user {
        gap: 6px;
        margin-left: auto
    }

    .desktop-user-name,
    .desktop-switch {
        display: none !important
    }

    .mobile-account-btn {
        display: grid;
        width: 34px;
        height: 34px;
        place-items: center;
        border: 0;
        background: #eef3f8;
        color: #23405e;
        border-radius: 50%;
        font-weight: 800
    }

    .avatar {
        width: 34px;
        height: 34px;
        font-size: 12px
    }

    .content {
        padding: 18px 14px 28px;
        max-width: none
    }

    .head {
        display: block;
        margin-bottom: 18px
    }

    .head h1 {
        font-size: 24px;
        line-height: 1.15;
        margin: 5px 0 6px
    }

    .head p {
        font-size: 13px;
        margin-bottom: 12px
    }

    .head>div:last-child {
        margin-top: 12px
    }

    .head>div:last-child .btn {
        width: 100%
    }

    .cards {
        grid-template-columns: 1fr 1fr;
        border-radius: 12px
    }

    .card {
        padding: 15px;
        border-right: 1px solid var(--line);
        border-bottom: 1px solid var(--line)
    }

    .card:nth-child(2n) {
        border-right: 0
    }

    .card:nth-last-child(-n+2) {
        border-bottom: 0
    }

    .card strong {
        font-size: 24px
    }

    .panel {
        margin-top: 14px;
        border-radius: 12px;
        padding: 14px
    }

    .grid2 {
        grid-template-columns: 1fr !important;
        gap: 12px
    }

    .formgrid {
        grid-template-columns: 1fr !important;
        gap: 12px
    }

    .formgrid .full {
        grid-column: auto !important
    }

    .row-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px
    }

    .row-actions .btn {
        width: 100%;
        min-height: 46px
    }

    .btn {
        min-height: 46px;
        padding: 11px 14px
    }

    .input,
    select.input,
    textarea.input {
        min-height: 46px;
        font-size: 16px
    }

    textarea.input {
        padding-top: 11px
    }

    .tabs {
        display: flex;
        overflow-x: auto;
        gap: 7px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch
    }

    .tabs .tab {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 9px 13px
    }

    .patient-title {
        display: block
    }

    .patient-title .row-actions {
        margin-top: 12px
    }

    .patient-title .row-actions .btn {
        width: 100%
    }

    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch
    }

    table.table:not(.mobile-card-table) {
        min-width: 640px
    }

    table.mobile-card-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        border: 0;
        background: transparent
    }

    table.mobile-card-table thead {
        display: none
    }

    table.mobile-card-table tbody,
    table.mobile-card-table tr,
    table.mobile-card-table td {
        display: block;
        width: 100%
    }

    table.mobile-card-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
        margin: 0 0 10px;
        padding: 9px 12px;
        box-shadow: 0 2px 8px rgba(15, 23, 42, .04)
    }

    table.mobile-card-table td {
        border: 0 !important;
        border-bottom: 1px solid #edf1f5 !important;
        padding: 9px 0;
        text-align: left;
        white-space: normal !important
    }

    table.mobile-card-table td:last-child {
        border-bottom: 0 !important;
        padding-bottom: 2px
    }

    table.mobile-card-table td:before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: .65px;
        color: #7b8a9d;
        font-weight: 700;
        margin-bottom: 3px
    }

    table.mobile-card-table td[colspan] {
        text-align: center
    }

    table.mobile-card-table td[colspan]:before {
        display: none
    }

    table.mobile-card-table .btn {
        width: auto;
        min-height: 42px;
        margin: 3px 5px 3px 0
    }

    .medicine-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 9px !important;
        padding: 12px !important;
        border-radius: 12px !important
    }

    .medicine-row .btn {
        width: 100%
    }

    .mobile-bottom {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9990;
        padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--line);
        box-shadow: 0 -5px 18px rgba(15, 23, 42, .08)
    }

    .mobile-bottom-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 54px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: #718198;
        font-size: 10px;
        font-weight: 700
    }

    .mobile-bottom-item.active {
        background: rgba(0, 150, 199, .09);
        color: #007da8
    }

    .bottom-icon {
        font-size: 18px;
        line-height: 1
    }

    .mobile-menu {
        width: min(86vw, 360px);
        z-index: 10001
    }

    .mobile-menu-body {
        padding-bottom: 20px
    }

    .mobile-menu-item {
        min-height: 48px
    }

    .modal {
        align-items: flex-end !important
    }

    .modalbox {
        width: 100% !important;
        max-width: none !important;
        max-height: 92vh;
        overflow: auto;
        border-radius: 18px 18px 0 0 !important;
        padding: 18px !important;
        margin: 0 !important
    }

    .modalhead {
        position: sticky;
        top: -5px;
        background: #fff;
        padding: 4px 0 12px;
        z-index: 2
    }

    .viewer iframe {
        min-height: 65vh !important
    }

    .login {
        padding: 16px !important
    }

    .loginbox {
        width: 100% !important;
        max-width: 430px !important;
        padding: 22px !important;
        border-radius: 16px !important
    }

    .loginbox .btn {
        min-height: 50px
    }

    .notice {
        left: 12px !important;
        right: 12px !important;
        bottom: 94px !important;
        top: auto !important
    }

    .mobile-account-sheet {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 11000;
        visibility: hidden;
        pointer-events: none
    }

    .mobile-account-sheet.open {
        visibility: visible;
        pointer-events: auto
    }

    .account-sheet-backdrop {
        position: absolute;
        inset: 0;
        border: 0;
        background: rgba(10, 25, 43, .42);
        opacity: 0;
        transition: opacity .18s
    }

    .mobile-account-sheet.open .account-sheet-backdrop {
        opacity: 1
    }

    .account-sheet-panel {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        border-radius: 20px 20px 0 0;
        padding: 9px 16px calc(16px + env(safe-area-inset-bottom));
        transform: translateY(105%);
        transition: transform .22s;
        box-shadow: 0 -10px 30px rgba(15, 23, 42, .18)
    }

    .mobile-account-sheet.open .account-sheet-panel {
        transform: translateY(0)
    }

    .account-sheet-handle {
        width: 42px;
        height: 4px;
        background: #d5dce5;
        border-radius: 4px;
        margin: 3px auto 15px
    }

    .account-sheet-head {
        display: flex;
        align-items: center;
        gap: 11px;
        padding: 3px 0 14px;
        border-bottom: 1px solid var(--line)
    }

    .account-sheet-head .large {
        width: 42px;
        height: 42px
    }

    .account-sheet-head strong {
        display: block;
        font-size: 15px
    }

    .account-sheet-head span {
        display: block;
        color: var(--muted);
        font-size: 12px;
        margin-top: 2px
    }

    .sheet-close {
        margin-left: auto;
        border: 0;
        background: #f1f4f7;
        border-radius: 50%;
        width: 34px;
        height: 34px;
        font-size: 22px;
        color: #506176
    }

    .account-action {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 52px;
        border: 0;
        border-bottom: 1px solid #edf1f5;
        background: #fff;
        text-align: left;
        font-weight: 700;
        color: #26384d;
        font-size: 14px
    }

    .account-action:last-child {
        border-bottom: 0
    }

    .danger-action {
        color: #b33a35
    }
}

@media (min-width:769px) {

    .mobile-menu-btn,
    .mobile-bottom,
    .mobile-account-btn,
    .mobile-account-sheet {
        display: none !important
    }
}

/* =========================================================
   MOBILE-FIRST FORM + NAVIGATION FIXES
   v3.0.1
========================================================= */
.mobile-bottom {
    transition: transform .22s ease, opacity .18s ease;
}

.mobile-bottom.mobile-bottom-hidden {
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
}

body.modal-open {
    overflow: hidden;
}

.patient-form-modal {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
}

.patient-form-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mobile-back-btn {
    display: none;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: 0;
    border-radius: 10px;
    background: #f1f4f7;
    color: var(--text-color, #111827);
    font-size: 24px;
    line-height: 1;
}

.modal-subtitle {
    margin-top: 3px;
    color: var(--muted, #718198);
    font-size: .78rem;
    line-height: 1.35;
}

.patient-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.patient-form-body {
    min-height: 0;
    overflow: auto;
    padding: 2px 2px 12px;
    -webkit-overflow-scrolling: touch;
}

.patient-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 0 0;
    margin-top: 6px;
    border-top: 1px solid var(--line, #e5e7eb);
    background: #fff;
}

.patient-save-btn:disabled {
    opacity: .65;
    cursor: wait;
}

.mobile-back-btn {
    display: none;
}

/* Prevent body & html from scrolling when modal is active */
body.modal-open,
html:has(body.modal-open) {
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none;
}

@media (max-width: 768px) {
    .patient-form-modal {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        background: #ffffff;
        z-index: 10000;
        overflow: hidden;
    }

    .patient-form-head {
        flex-shrink: 0;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border, #eee);
        background: #fff;
    }

    .patient-form {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        /* Keeps inner scrolling functional */
        overflow: hidden;
    }

    /* Form body scrolls, padded at bottom so content isn't covered */
    .patient-form-body {
        flex: 1;
        overflow-y: auto;
        padding: 14px 16px 20px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* Prevents scroll chaining to body */
    }

    .patient-form .formgrid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Actions fixed permanently to the bottom of the viewport */
    .patient-form-actions {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        display: flex;
        gap: 10px;
        padding: 10px 16px;
        /* Increase 10px to 20px (or whatever offset you need) */
        padding-bottom: max(20px, calc(10px + env(safe-area-inset-bottom)));
        border-top: 1px solid var(--border, #eee);
        background: #ffffff;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
        z-index: 10;
    }

    .patient-form-actions .btn {
        flex: 1;
        height: 42px !important;
        font-size: 14px !important;
        font-weight: 600;
        border-radius: 8px;
    }
}

@media (max-width: 768px) {

    .patient-title {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 14px;
    }

    .patient-title-info {
        min-width: 0;
    }

    .patient-title h1 {
        margin: 3px 0 5px;
        font-size: 23px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .patient-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 10px;
        font-size: 12px;
        line-height: 1.5;
    }

    .patient-meta span {
        overflow-wrap: anywhere;
    }

    .patient-record-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .patient-record-actions .btn {
        min-height: 38px;
        height: 38px;
        padding: 6px 12px;
        font-size: 13px;
        border-radius: 8px;
    }
}

@media (max-width: 768px) {

    /* Patient tab headings */
    .patient-tab-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 14px;
    }

    .patient-tab-head h2 {
        margin: 0;
        font-size: 17px;
        line-height: 1.25;
    }

    .patient-tab-head p {
        margin: 4px 0 0;
        font-size: 12px;
        line-height: 1.45;
    }

    .patient-tab-head .btn {
        flex: 0 0 auto;
        min-height: 36px;
        height: 36px;
        padding: 6px 10px;
        font-size: 12px;
        white-space: nowrap;
    }


    /* Overview */
    .patient-overview-grid {
        grid-template-columns: 1fr !important;
        gap: 18px;
    }

    .patient-overview-grid h2 {
        font-size: 17px;
        margin-bottom: 9px;
    }


    /* Quick actions */
    .patient-quick-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .patient-quick-actions .btn {
        width: 100%;
        min-height: 38px;
        height: 38px;
        padding: 6px 8px;
        font-size: 12px;
        border-radius: 8px;
    }


    /* Patient record tables */
    #patienttab .table-scroll {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
        scrollbar-width: thin;
    }

    #patienttab .table-scroll table {
        display: table;
        max-width: none;
        table-layout: auto;
    }

    .patient-info-table {
        width: 100%;
        min-width: 0 !important;
        table-layout: fixed;
    }

    .patient-info-table td:first-child {
        width: 34%;
        white-space: nowrap;
    }

    .patient-info-table td:last-child {
        width: 66%;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    #patienttab .table-scroll:has(.patient-info-table) {
        overflow-x: hidden;
    }

    .patient-timeline-table {
        width: 760px;
        min-width: 760px;
    }

    .patient-scanned-table {
        width: 620px;
        min-width: 620px;
    }

    .patient-consultations-table {
        width: 620px;
        min-width: 620px;
    }

    .patient-payments-table {
        width: 700px;
        min-width: 700px;
    }


    /* Smaller table text */
    #patienttab .table th,
    #patienttab .table td {
        font-size: 12px;
        padding: 9px 10px;
    }


    /* Consultation / prescription forms */
    .patient-subform .formgrid {
        grid-template-columns: 1fr 1fr !important;
        gap: 11px;
    }

    .patient-subform .formgrid>.full {
        grid-column: 1 / -1 !important;
    }

    .patient-subform label {
        display: block;
        margin-bottom: 5px;
        font-size: 12px;
    }

    .patient-subform .input {
        width: 100%;
        min-height: 40px;
        height: 40px;
        padding: 7px 9px;
        font-size: 14px;
        box-sizing: border-box;
        border-radius: 8px;
    }

    .patient-subform textarea.input {
        min-height: 82px;
        height: auto;
    }

    .patient-form-submit {
        margin-top: 12px;
        min-height: 38px;
        height: 38px;
        padding: 6px 12px;
        font-size: 13px;
        border-radius: 8px;
    }

    .add-medicine-btn {
        margin-top: 7px;
        min-height: 36px;
        height: 36px;
        padding: 6px 10px;
        font-size: 12px;
    }


    /* Previous consultation section */
    .patient-history {
        margin-top: 22px;
    }

    .patient-history h3 {
        font-size: 15px;
        margin-bottom: 9px;
    }
}

@media (max-width: 380px) {

    .patient-subform .formgrid {
        grid-template-columns: 1fr !important;
    }

    .patient-subform .formgrid>.full {
        grid-column: auto !important;
    }
}

.doctor-instruction-modal {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.doctor-instruction-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    z-index: 2;
}

.doctor-instruction-form {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.doctor-instruction-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 18px;
    -webkit-overflow-scrolling: touch;
}

.doctor-instruction-actions {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    z-index: 2;
}

.doctor-instruction-modal {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

.doctor-instruction-form {
    min-height: 0;
    flex: 1;

    display: flex;
    flex-direction: column;
}

.doctor-instruction-body {
    min-height: 0;
    flex: 1;

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.doctor-instruction-actions {
    flex: 0 0 auto;

    display: flex;
    justify-content: flex-end;
    gap: 8px;

    padding: 10px 18px;
    border-top: 1px solid var(--border);

    background: var(--surface);
}

@media (max-width: 768px) {

    .doctor-instruction-modal {
        width: 100%;
        max-width: none;

        height: 100dvh;
        max-height: 100dvh;

        border-radius: 0;
    }

    .doctor-instruction-head {
        flex: 0 0 auto;
        margin-top: 5px;
        padding: 11px 14px;
    }

    .doctor-instruction-body {
        padding: 12px 14px;
    }

    .doctor-instruction-actions {
        flex: 0 0 auto;

        display: grid;
        grid-template-columns: 90px 1fr;

        padding: 9px 14px;
        padding-bottom: calc(9px + env(safe-area-inset-bottom));
    }

    .doctor-instruction-actions .btn {
        width: 100%;
        min-height: 37px;
        height: 37px;

        padding: 6px 10px;
        font-size: 12px;
    }
}


/* Pagination CSS */


.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 2px 2px;
}

.pagination-info {
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
}

.pagination-info strong {
    color: var(--text-color, inherit);
    font-weight: 600;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 4px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    background: var(--card-bg, transparent);
    color: var(--text-color, inherit);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pagination-btn:hover:not(:disabled):not(.is-active) {
    background: var(--hover-bg, rgba(127, 127, 127, 0.1));
}

.pagination-btn.is-active {
    background: var(--primary, #2563eb);
    border-color: var(--primary, #2563eb);
    color: #fff;
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    color: var(--text-secondary, #6b7280);
}

@media (max-width: 600px) {
    .pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .pagination-controls {
        justify-content: flex-start;
        width: 100%;
    }

    .pagination-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 7px;
    }
}