/* ELYSIAN Fertility Clinic ? Application Theme */
:root {
    --elysian-purple: #6b4c7a;
    --elysian-purple-dark: #523a5f;
    --elysian-purple-light: #9b7daa;
    --elysian-pink: #c97b9a;
    --elysian-bg: #f8f6fa;
    --elysian-white: #ffffff;
    --elysian-text: #2d2430;
    --elysian-muted: #6c5f72;
    --elysian-border: #e5dde8;
    --elysian-success: #2e7d5a;
    --elysian-danger: #b83b4a;
    --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--elysian-bg);
    color: var(--elysian-text);
    margin: 0;
    min-height: 100vh;
}

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

/* ?? Sidebar ?? */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--elysian-purple-dark), var(--elysian-purple));
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    align-self: flex-start;
    overflow: hidden;
    border-right: 0;
    z-index: 1100;
}

.sidebar-brand {
    background: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    height: 48px;
    min-height: 48px;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    text-align: center;
}

.clinic-logo {
    display: block;
    margin: 0 auto;
    object-fit: contain;
    max-width: 100%;
    height: auto;
}

/* Logo sizes ? compact & professional */
.clinic-logo-sidebar {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0;
}
.clinic-logo-login   { max-width: 115px; }
.clinic-logo-sm      { max-width: 90px; }
.clinic-logo-md      { max-width: 120px; }
.clinic-logo-receipt { max-width: 130px; }
.clinic-logo-print   { max-width: 160px; margin-bottom: 8px; }

.sidebar-nav {
    padding: 0.5rem 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: visible;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    margin: 0.1rem 0.5rem;
    border-radius: 6px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav a i { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.2);
    font-weight: 500;
}

.sidebar-nav-item.has-submenu {
    position: relative;
}
.sidebar-nav-item.has-submenu > a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    margin: 0.1rem 0.5rem;
    border-radius: 6px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.88rem;
}
.sidebar-nav-item.has-submenu > a .submenu-caret {
    margin-left: auto;
    width: auto;
    font-size: 0.75rem;
    opacity: 0.7;
}
.sidebar-nav-item.has-submenu:hover > a,
.sidebar-nav-item.has-submenu.active > a,
.sidebar-nav-item.has-submenu.is-open > a {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Reports flyout (right) ? solid, readable, always on top */
.sidebar-submenu,
body > .sidebar-submenu {
    display: none;
    position: fixed !important;
    left: var(--sidebar-width);
    top: 0;
    width: 250px;
    max-width: 250px;
    max-height: min(78vh, 580px);
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 0.55rem 0.35rem;
    background: linear-gradient(180deg, var(--elysian-purple-dark), var(--elysian-purple)) !important;
    background-image: linear-gradient(180deg, var(--elysian-purple-dark), var(--elysian-purple)) !important;
    opacity: 1 !important;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    z-index: 99999 !important;
    isolation: isolate;
}
.sidebar-nav-item.has-submenu.is-open > .sidebar-submenu,
body > .sidebar-submenu.is-visible {
    display: block !important;
}
.sidebar-submenu-heading,
body > .sidebar-submenu .sidebar-submenu-heading {
    display: block;
    padding: 0.42rem 0.7rem;
    margin: 0.35rem 0.25rem 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #fff !important;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: linear-gradient(135deg, #2e9b6a 0%, #248a5c 55%, #1e7a50 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}
.sidebar-submenu a,
body > .sidebar-submenu a {
    display: flex !important;
    align-items: center;
    gap: 0.55rem;
    width: auto;
    margin: 0.12rem 0.25rem !important;
    padding: 0.48rem 0.7rem !important;
    border-radius: 6px;
    color: #fff !important;
    text-decoration: none !important;
    font-size: 0.86rem !important;
    font-weight: 500;
    background: transparent;
    line-height: 1.25;
}
.sidebar-submenu a i,
body > .sidebar-submenu a i {
    color: rgba(255,255,255,0.9) !important;
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-submenu a span,
body > .sidebar-submenu a span {
    color: #fff !important;
}
.sidebar-submenu a:hover,
body > .sidebar-submenu a:hover {
    background: rgba(255,255,255,0.16) !important;
    color: #fff !important;
}
.sidebar-submenu a.active,
body > .sidebar-submenu a.active {
    background: rgba(255,255,255,0.24) !important;
    color: #fff !important;
    font-weight: 600;
}

.sidebar-nav a.sidebar-back-admin {
    margin-bottom: 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: linear-gradient(135deg, #2e9b6a 0%, #248a5c 55%, #1e7a50 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.sidebar-nav a.sidebar-back-admin i {
    color: #fff;
}
.sidebar-nav a.sidebar-back-admin:hover {
    background: linear-gradient(135deg, #36ad78 0%, #2e9b6a 55%, #248a5c 100%);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

/* Sidebar footer + logout */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    text-decoration: none;
    font-size: 0.82rem;
    transition: background 0.15s;
}

.btn-logout-sidebar:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.badge-role {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    color: #fff;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-size: 0.68rem;
    margin-top: 2px;
}

/* ?? Topbar ?? */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: linear-gradient(135deg, #6b4c7a 0%, #8d6aa0 58%, #c97b9a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    color: #fff;
    height: 48px;
    min-height: 48px;
    padding: 0.35rem 1.1rem;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.3rem 0.4rem;
    min-width: 0;
    justify-self: start;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
}

.topbar-center {
    text-align: center;
    justify-self: center;
    line-height: 1.2;
}

.topbar-center h2 {
    margin: 0;
    font-size: 1.05rem;
    color: #fff;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.2;
}

.topbar-subtitle {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.2;
}

.topbar-sep {
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
    line-height: 1;
}

.topbar-datetime {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin-top: 0;
    letter-spacing: 0.01em;
    white-space: nowrap;
    line-height: 1.2;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    justify-self: end;
}

.topbar-user {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.95);
    display: none;
    line-height: 1.2;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.65rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.15s;
    line-height: 1.2;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}

.btn-logout i { font-size: 1rem; }

@media (min-width: 768px) {
    .topbar-user { display: inline-flex; align-items: center; gap: 0.3rem; }
}

.page-body { padding: 1.25rem; flex: 1; }

/* ?? Cards & tables ?? */
.card {
    background: var(--elysian-white);
    border: 1px solid var(--elysian-border);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    font-weight: 600;
    color: var(--elysian-purple-dark);
    margin-bottom: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--elysian-border);
    font-size: 0.92rem;
}

.card-header i { margin-right: 0.35rem; color: var(--elysian-purple); }
.card-header .btn-elysian i,
.card-header .btn-elysian:hover i,
.card-header .btn-elysian:focus i {
    color: #fff;
}
.card-header .btn-outline-elysian i {
    color: inherit;
}
.card-header .btn-outline-elysian:hover i,
.card-header .btn-outline-elysian:focus i {
    color: #fff;
}

.store-header-actions {
    flex: 0 0 auto;
    width: auto;
    min-width: 280px;
    max-width: 420px;
    flex-wrap: nowrap;
}
.store-header-actions .form-control {
    min-width: 140px;
}
.store-header-actions .btn-elysian {
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    white-space: nowrap;
}

.store-scroll-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1040;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--elysian-purple, #5b3d6e);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(91, 61, 110, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.store-scroll-fab:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(91, 61, 110, 0.55);
}
.store-scroll-fab i {
    font-size: 1.35rem;
}
.store-page-tools {
    margin-bottom: 0.35rem;
}
.store-export-meta {
    display: none;
    margin: 0 0 0.5rem;
    padding: 0 0 0.4rem;
    border-bottom: 1px solid #d8d0e0;
}
.store-export-meta-inner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.store-export-logo {
    width: 42px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}
.store-export-meta-title {
    font-weight: 700;
    color: var(--elysian-purple-dark, #3d2949);
    font-size: 0.92rem;
    line-height: 1.15;
    margin: 0;
    letter-spacing: 0.03em;
}
.store-export-meta-sub {
    font-size: 0.74rem;
    color: #6c757d;
    margin: 0.1rem 0 0;
    line-height: 1.2;
}
#store_pdf_source.is-pdf-capture .store-export-meta {
    display: block;
}
#store_pdf_source.is-pdf-capture .no-print {
    display: none !important;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 6mm;
    }

    html, body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .store-export-meta {
        display: block !important;
        margin: 0 0 4px !important;
        padding: 0 0 3px !important;
        page-break-after: avoid;
        break-after: avoid;
    }
    #store_pdf_source {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .sidebar,
    .topbar,
    .no-print,
    .store-page-tools,
    .store-scroll-fab,
    .alert,
    .flash-auto-hide {
        display: none !important;
    }
    .app-shell,
    .main-content,
    .page-body {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
        margin: 0 !important;
    }
    .card-header {
        padding: 0.35rem 0.5rem !important;
        break-after: avoid;
        page-break-after: avoid;
    }
    .table-responsive {
        overflow: visible !important;
        width: 100% !important;
    }
    .table-elysian {
        width: 100% !important;
        table-layout: fixed;
        border-collapse: collapse;
        font-size: 7.5pt !important;
    }
    .table-elysian thead {
        display: table-header-group;
    }
    .table-elysian tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .table-elysian th,
    .table-elysian td {
        padding: 2px 3px !important;
        font-size: 7.5pt !important;
        line-height: 1.25 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        vertical-align: top;
        border: 1px solid #999 !important;
        color: #000 !important;
    }
    .table-elysian th {
        background: #e8e0ee !important;
        color: #000 !important;
        font-weight: 700 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .table-elysian .badge {
        border: 1px solid #666 !important;
        color: #000 !important;
        background: #f0f0f0 !important;
        font-weight: 600 !important;
        font-size: 7pt !important;
        padding: 1px 4px !important;
    }
    /* Store Summary wide table — all printable columns sized for landscape */
    #store-entries-table {
        table-layout: fixed !important;
        width: 100% !important;
        font-size: 7pt !important;
    }
    #store-entries-table th,
    #store-entries-table td {
        font-size: 7pt !important;
        padding: 2px 2px !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        hyphens: manual !important;
    }
    #store-entries-table th:nth-child(1),
    #store-entries-table td:nth-child(1) { width: 6.5%; }   /* Slip */
    #store-entries-table th:nth-child(2),
    #store-entries-table td:nth-child(2) { width: 6%; }     /* Date */
    #store-entries-table th:nth-child(3),
    #store-entries-table td:nth-child(3) { width: 10%; }    /* Item */
    #store-entries-table th:nth-child(4),
    #store-entries-table td:nth-child(4) { width: 8%; }     /* Spec */
    #store-entries-table th:nth-child(5),
    #store-entries-table td:nth-child(5) { width: 8%; }     /* Supplier */
    #store-entries-table th:nth-child(6),
    #store-entries-table td:nth-child(6) { width: 6%; }     /* Expiry */
    #store-entries-table th:nth-child(7),
    #store-entries-table td:nth-child(7) { width: 5.5%; }   /* Price */
    #store-entries-table th:nth-child(8),
    #store-entries-table td:nth-child(8) { width: 4%; }     /* Qty */
    #store-entries-table th:nth-child(9),
    #store-entries-table td:nth-child(9) { width: 5%; }     /* Used Qty */
    #store-entries-table th:nth-child(10),
    #store-entries-table td:nth-child(10) { width: 6%; }    /* Used Amt */
    #store-entries-table th:nth-child(11),
    #store-entries-table td:nth-child(11) { width: 5%; }    /* Remaining */
    #store-entries-table th:nth-child(12),
    #store-entries-table td:nth-child(12) { width: 7%; }    /* Status */
    #store-entries-table th:nth-child(13),
    #store-entries-table td:nth-child(13) { width: 5.5%; }  /* Total */
    #store-entries-table th:nth-child(14),
    #store-entries-table td:nth-child(14) { width: 8%; }    /* Note */
    #store-entries-table th:nth-child(15),
    #store-entries-table td:nth-child(15) { width: 8.5%; }  /* By */
    #store-entries-table th.no-print,
    #store-entries-table td.no-print {
        display: none !important;
        width: 0 !important;
        padding: 0 !important;
        border: none !important;
    }
}

.btn-elysian {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--elysian-purple);
    --bs-btn-border-color: var(--elysian-purple);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--elysian-purple-dark);
    --bs-btn-hover-border-color: var(--elysian-purple-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--elysian-purple-dark);
    --bs-btn-active-border-color: var(--elysian-purple-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--elysian-purple-light);
    --bs-btn-disabled-border-color: var(--elysian-purple-light);
    background: var(--elysian-purple);
    border: 1px solid var(--elysian-purple);
    color: #fff;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.88rem;
    font-weight: 600;
}

.btn-elysian:hover,
.btn-elysian:focus {
    background: var(--elysian-purple-dark);
    border-color: var(--elysian-purple-dark);
    color: #fff;
}

.btn-outline-elysian {
    --bs-btn-color: var(--elysian-purple);
    --bs-btn-bg: #f3e8f8;
    --bs-btn-border-color: var(--elysian-purple);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--elysian-purple);
    --bs-btn-hover-border-color: var(--elysian-purple);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--elysian-purple-dark);
    --bs-btn-active-border-color: var(--elysian-purple-dark);
    --bs-btn-disabled-color: var(--elysian-purple-light);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--elysian-purple-light);
    background: #f3e8f8;
    border: 1px solid var(--elysian-purple);
    color: var(--elysian-purple);
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-outline-elysian:hover,
.btn-outline-elysian:focus {
    background: var(--elysian-purple);
    border-color: var(--elysian-purple);
    color: #fff;
}

/* Purple search / filter inputs across all pages */
.page-body .form-control,
.page-body .form-select {
    border-color: #b48ec4;
    background-color: #f3e8f8;
    color: #3d2a48;
}

.page-body .form-control::placeholder {
    color: #8a6d98;
}

.page-body .form-control:focus,
.page-body .form-select:focus {
    border-color: #6b4c7a;
    box-shadow: 0 0 0 0.18rem rgba(107, 76, 122, 0.2);
    background-color: #efe0f5;
    color: #2d2430;
}

.page-body .form-label {
    color: #523a5f;
    font-weight: 600;
}

.page-body .card-header i {
    color: var(--elysian-purple);
}

.page-body .card-header .btn-elysian i,
.page-body .card-header .btn-elysian:hover i,
.page-body .card-header .btn-elysian:focus i {
    color: #fff;
}

/* Bootstrap modals must sit above sidebar (z-index 1100) and FABs */
.modal-backdrop {
    z-index: 20000 !important;
}
.modal {
    z-index: 20010 !important;
}

/* Keep Cancel in modals neutral */
.modal .btn-outline-secondary {
    --bs-btn-color: #6c757d;
    --bs-btn-border-color: #6c757d;
    --bs-btn-hover-bg: #6c757d;
    --bs-btn-hover-border-color: #6c757d;
    --bs-btn-hover-color: #fff;
}

/* Non-modal secondary outline ? purple (Print icons in tables, History, etc.) */
.page-body .btn-outline-secondary {
    --bs-btn-color: var(--elysian-purple);
    --bs-btn-bg: #f3e8f8;
    --bs-btn-border-color: var(--elysian-purple);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--elysian-purple);
    --bs-btn-hover-border-color: var(--elysian-purple);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--elysian-purple-dark);
    --bs-btn-active-border-color: var(--elysian-purple-dark);
    background: #f3e8f8;
    border-color: var(--elysian-purple);
    color: var(--elysian-purple);
    font-weight: 600;
}

.page-body .btn-outline-secondary:hover,
.page-body .btn-outline-secondary:focus {
    background: var(--elysian-purple);
    border-color: var(--elysian-purple);
    color: #fff;
}

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

.table-elysian th,
.table-elysian td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--elysian-border);
    text-align: left;
    font-size: 0.86rem;
}

.table-elysian th {
    background: linear-gradient(180deg, #6b4c7a, #523a5f);
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
}

.table-elysian th.col-sr-no,
.table-elysian td.col-sr-no,
.report-table th.col-sr-no,
.report-table td.col-sr-no {
    width: 3.25rem;
    min-width: 3.25rem;
    max-width: 4rem;
    text-align: center;
    white-space: nowrap;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

/* ?? Admin dashboard stats ?? */
.admin-welcome {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--elysian-border);
    border-radius: 10px;
}

.admin-welcome h3 {
    font-size: 1.1rem;
    margin: 0 0 0.2rem;
    color: var(--elysian-purple-dark);
}

.admin-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--elysian-white);
    border: 1px solid var(--elysian-border);
    border-radius: 10px;
    padding: 1rem;
    position: relative;
}

.stat-card .stat-icon {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    font-size: 1.25rem;
    opacity: 0.25;
    color: var(--elysian-purple);
}

.stat-card .value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--elysian-purple);
    line-height: 1.2;
}

.stat-card .label {
    font-size: 0.75rem;
    color: var(--elysian-muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-profit .profit-value { color: var(--elysian-success); }

.form-label { font-weight: 500; color: var(--elysian-purple-dark); margin-bottom: 0.3rem; font-size: 0.88rem; }

/* ?? Login page ?? */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f3eff5, #e8dff0);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
    border: 1px solid var(--elysian-border);
    text-align: center;
}

.login-logo-wrap {
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.78rem;
    color: var(--elysian-muted);
    margin-bottom: 1.25rem;
    letter-spacing: 0.3px;
}

.login-form { margin-top: 0.5rem; }

.test-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
}

.test-grid label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
}

/* ?? Patient register form (paper layout) ?? */
.patient-register-card .card-header {
    text-align: center;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.patient-register-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--elysian-border);
}

.patient-meta-field {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 220px;
}

.patient-meta-field label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--elysian-purple-dark);
    white-space: nowrap;
}

.patient-meta-field .form-control {
    max-width: 200px;
    border: 1px solid #c9b3d4;
    border-radius: 8px;
    background: #f8f1fb;
    min-height: 34px;
}

.patient-meta-field .form-control:focus {
    border-color: #6b4c7a;
    box-shadow: 0 0 0 0.15rem rgba(107, 76, 122, 0.18);
    background: #fff;
}

.patient-register-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    margin-bottom: 1rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5d5ea;
}

.patient-register-table th,
.patient-register-table td {
    border: 1px solid #eadff0;
    padding: 0.6rem 0.7rem;
    vertical-align: middle;
}

.patient-register-table th {
    font-weight: 700;
    text-align: center;
    font-size: 0.95rem;
}

/* Female column ? darker pink */
.patient-register-table th.col-female {
    background: linear-gradient(180deg, #d96a8c, #c24e74);
    color: #fff;
    border-color: #b84368;
}
.patient-register-table:has(th.col-female:first-child) tbody td:first-child {
    background: #f5c4d4;
    border-color: #d98aa3;
}
.patient-register-table:has(th.col-female:first-child) tbody td:first-child .field-label {
    color: #7a2945;
}

/* Male column ? darker purple */
.patient-register-table th.col-male {
    background: linear-gradient(180deg, #6b4c7a, #4f355c);
    color: #fff;
    border-color: #3f2a4a;
}
.patient-register-table:has(th.col-male:last-child) tbody td:last-child {
    background: #d4c0e0;
    border-color: #a88cbc;
}
.patient-register-table:has(th.col-male:last-child) tbody td:last-child .field-label {
    color: #3a2746;
}

.patient-register-table .field-label {
    display: inline-block;
    min-width: 7.5rem;
    font-weight: 700;
    font-size: 0.86rem;
    margin-bottom: 0;
    color: var(--elysian-text);
}

.patient-register-table .field-label-wide {
    min-width: 9.5rem;
}

.patient-register-table .field-label-wide + .form-control {
    width: calc(100% - 10rem);
}

/* Clear, prominent inputs */
.patient-register-table .form-control {
    display: inline-block;
    width: calc(100% - 8rem);
    min-width: 120px;
    min-height: 36px;
    border: 1px solid #c9b3d4;
    border-radius: 8px;
    padding: 0.35rem 0.55rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(82, 58, 95, 0.06);
    color: #2d2430;
    font-size: 0.9rem;
    font-weight: 500;
}

.patient-register-table:has(th.col-female:first-child) tbody td:first-child .form-control {
    border-color: #e5a8bb;
    background: #fff;
}

.patient-register-table:has(th.col-male:last-child) tbody td:last-child .form-control {
    border-color: #b48ec4;
    background: #fff;
}

.patient-register-table .form-control:focus {
    border-color: #6b4c7a;
    box-shadow: 0 0 0 0.18rem rgba(107, 76, 122, 0.2);
    background: #fff;
    outline: none;
}

.patient-register-table:has(th.col-female:first-child) tbody td:first-child .form-control:focus {
    border-color: #c97b9a;
    box-shadow: 0 0 0 0.18rem rgba(201, 123, 154, 0.25);
}

.patient-register-spacer {
    background: transparent !important;
    min-height: 2.6rem;
}

.patient-register-extra {
    border-top: 1px solid var(--elysian-border);
    padding-top: 0.85rem;
}

.patient-register-receptionist {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--elysian-border);
    font-size: 0.86rem;
}

.patient-photo-box {
    padding: 0.25rem 0;
}

.patient-photo-preview {
    width: 100%;
    max-width: 160px;
    min-height: 100px;
    border: 1px dashed var(--elysian-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #faf8fb;
}

.patient-photo-preview img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.patient-camera-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding-top: 75%;
    overflow: hidden;
    border-radius: 8px;
    background: #111;
}

.patient-camera-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

#cameraModal .modal-dialog {
    max-width: 480px;
    width: calc(100% - 1.5rem);
}

#cameraModal .modal-content,
#cameraModal .modal-body {
    overflow: hidden;
    max-width: 100%;
}

.patient-photo-display {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--elysian-border);
}

.patient-view-table td {
    font-size: 0.86rem;
    vertical-align: top;
}

.patient-view-value {
    display: inline;
    word-break: break-word;
}

.table-clickable tbody tr.patient-row-link {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.table-clickable tbody tr.patient-row-link:hover,
.table-clickable tbody tr.patient-row-link:focus-within {
    background-color: #f3eff5 !important;
}

.table-clickable tbody tr.patient-row-link:hover td {
    background-color: transparent;
}

.table-clickable .patient-row-link {
    cursor: pointer;
}

.table-clickable .patient-row-link:hover {
    background: #f3eff5;
}

.fee-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid var(--elysian-border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(45, 36, 48, 0.12);
    max-height: 260px;
    overflow-y: auto;
    margin-top: 4px;
}

/* Keep search wrapper above later siblings (tables / Save buttons) */
.position-relative:has(> .fee-search-dropdown) {
    z-index: 40;
}

.fee-search-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--elysian-border);
    cursor: pointer;
}

.fee-search-item:hover,
.fee-search-item.is-active {
    background: #f8f4fa;
}

.fee-search-item:last-child {
    border-bottom: none;
}

.fee-patient-card {
    background: #f8f4fa;
    border: 1px solid var(--elysian-border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}

.fee-patient-card-title {
    font-weight: 600;
    color: var(--elysian-purple-dark);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Pharmacy medicine expiry highlighting */
.medicine-row-expired,
.medicine-row-expired td,
.table-elysian tbody tr.medicine-row-expired:hover td {
    background-color: #f8d7da !important;
}

.medicine-row-expiring,
.medicine-row-expiring td,
.table-elysian tbody tr.medicine-row-expiring:hover td {
    background-color: #f8d7da !important;
}

.medicine-row-low-stock:not(.medicine-row-expired):not(.medicine-row-expiring) td,
.table-elysian tbody tr.medicine-row-low-stock:not(.medicine-row-expired):not(.medicine-row-expiring):hover td {
    background-color: #fff3cd !important;
}

.medicine-row-out-of-stock:not(.medicine-row-expired):not(.medicine-row-expiring):not(.medicine-row-low-stock) td,
.table-elysian tbody tr.medicine-row-out-of-stock:not(.medicine-row-expired):not(.medicine-row-expiring):not(.medicine-row-low-stock):hover td {
    background-color: #fde8e8 !important;
}

.medicine-row-out-of-stock td.medicine-stock-empty {
    background-color: #fde8e8 !important;
    color: #b42318;
}

.table-elysian tbody tr.medicine-row-out-of-stock:hover td.medicine-stock-empty {
    background-color: #fcd9d9 !important;
}

.fee-search-item.is-expired {
    background: #f8d7da !important;
    cursor: not-allowed;
    opacity: 0.95;
}

.fee-search-item.is-expired.is-active {
    background: #f1c2c7 !important;
}

@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        overflow: visible;
    }
    .sidebar-nav { overflow-y: visible; }
    .sidebar-brand .clinic-logo { max-width: 80px; }
    .topbar {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
        gap: 0.35rem;
        padding: 0.55rem 1rem;
        text-align: center;
    }
    .topbar-left,
    .topbar-center,
    .topbar-right {
        justify-self: center;
        justify-content: center;
        width: 100%;
    }
    .sidebar-brand {
        height: 48px;
        min-height: 48px;
    }
    .test-grid { grid-template-columns: 1fr; }
    .btn-logout span { display: none; }
    .patient-register-form { overflow-x: auto; }
    .patient-register-table { min-width: 620px; }
    .patient-meta-field { min-width: 100%; }
    .patient-meta-field .form-control { max-width: none; flex: 1; }
}

/* Page scroll FAB (doctor/store style: one circle, toggles up/down) */
.page-scroll-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1040;
}
.page-scroll-fab-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--elysian-purple, #5b3d6e);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(91, 61, 110, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}
.page-scroll-fab-btn:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(91, 61, 110, 0.55);
}
.page-scroll-fab-btn i {
    font-size: 1.35rem;
}
.admin-report-summary {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 8px 0;
    margin: 0 0 1rem;
}
.admin-report-summary td.admin-report-summary-item {
    vertical-align: top;
    width: auto;
}
.admin-report-summary-item .card {
    height: 100%;
    margin: 0;
}
@media print {
    .page-scroll-fab { display: none !important; }
    .admin-report-print-header {
        display: block !important;
        text-align: center !important;
        padding-top: 18mm !important;
        margin: 0 0 8px !important;
        border-bottom: 1.5px solid #000;
        padding-bottom: 6px !important;
    }
    .admin-report-print-logo {
        display: block !important;
        max-width: 184px !important;
        width: 184px !important;
        height: auto !important;
        margin: 0 auto 6px !important;
    }
    .admin-report-print-clinic {
        font-size: 13pt !important;
        font-weight: 800 !important;
        letter-spacing: 0.04em;
        margin: 0 0 2px;
    }
    .admin-report-print-title {
        font-size: 12pt !important;
        font-weight: 700 !important;
        margin: 0 0 2px;
    }
    .admin-report-print-meta {
        font-size: 9pt !important;
        color: #333 !important;
    }
    table.admin-report-summary {
        display: none !important;
    }
    table.admin-report-print-row {
        display: table !important;
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
    }
    table.admin-report-print-row tr {
        display: table-row !important;
    }
    table.admin-report-print-row td {
        display: table-cell !important;
        float: none !important;
        vertical-align: top !important;
        border: 1px solid #333 !important;
        padding: 6px 8px !important;
    }
}
.admin-report-print-header {
    display: none;
}
.admin-report-print-logo {
    display: none;
}
@media (max-width: 576px) {
    .page-scroll-fab { right: 0.85rem; bottom: 0.85rem; }
}

/* Admin ? staff registration form */
.user-register-card .card-header {
    font-weight: 600;
    background: var(--elysian-purple, #5b3d6e);
    color: #fff;
}
.user-register-form { padding: 1.25rem 1.5rem 1.5rem; }
.user-register-section {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(91, 61, 110, 0.12);
}
.user-register-section:last-of-type { border-bottom: none; }
.user-register-section-title {
    color: var(--elysian-purple, #5b3d6e);
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.8rem;
}
.user-register-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1.25rem;
}
.user-photo-preview-img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(91, 61, 110, 0.2);
}
@media (max-width: 768px) {
    .admin-users-header { flex-wrap: wrap; }
    .admin-users-toolbar { width: 100%; justify-content: flex-end; }
}

/* Admin dashboard ? clickable department balance rows */
.admin-dept-row { transition: background-color 0.15s ease; }
.admin-dept-row:hover { background-color: rgba(91, 61, 110, 0.08); }
.admin-dept-row:focus-visible { outline: 2px solid var(--elysian-purple, #5b3d6e); outline-offset: -2px; }
