/* =========================================================================
   CEMR POLISH ("polish and calm", DESIGN.md)
   Load last. Type, spacing and small details only: no new colours, no
   layout changes. Everything reads CEMR tokens, so Teal, Purple and dark
   mode follow. Login screens keep their own larger layout.
   ========================================================================= */

/* 1. One font. The Bootstrap 5.3 theme hardcodes system-ui on these
      selectors (no variable exists), so they are re-declared with the CEMR
      font. Icon fonts (.e-icons) are not in this list. */
.e-control,
.e-css,
.e-error,
input.e-input,
textarea.e-input,
.e-input-group,
.e-input-group.e-control-wrapper,
.e-input-group.e-disabled,
.e-input-group.e-control-wrapper.e-disabled,
.e-float-input,
.e-float-input.e-control-wrapper,
.e-float-input.e-disabled,
.e-float-input.e-control-wrapper.e-disabled,
.e-float-input.e-input-group.e-disabled,
.e-float-input.e-input-group.e-control-wrapper.e-disabled,
.e-spinner-pane .e-spinner-inner .e-spin-label,
.e-popup.e-ddl .e-dropdownbase.e-nodata,
.e-popup.e-mention .e-dropdownbase.e-nodata,
.e-dropdownbase .e-list-item,
.e-dropdownbase .e-list-group-item,
.e-fixed-head,
.e-multi-column.e-ddl.e-popup.e-popup-open .e-ddl-header,
.e-ddl.e-popup.e-multiselect-group .e-list-group-item,
.e-avatar,
.e-badge,
.e-btn,
.e-css.e-btn,
.e-card,
.e-card .e-card-actions .e-card-btn,
.e-card .e-card-actions a,
.e-checkbox-wrapper .e-label,
.e-css.e-checkbox-wrapper .e-label,
.e-tooltip-wrap .e-tip-content,
.e-control-wrapper.e-slider-container .e-scale,
.e-control-wrapper.e-slider-container .e-scale .e-tick .e-tick-value,
.e-contextmenu-wrapper ul.e-ul,
.e-contextmenu-container ul.e-ul,
.e-dashboardlayout.e-control .e-panel .e-panel-header,
.e-radio+label .e-label,
.e-switch-wrapper .e-switch-on,
.e-switch-wrapper .e-switch-off,
.e-css.e-switch-wrapper .e-switch-on,
.e-css.e-switch-wrapper .e-switch-off,
.e-listview,
/*! maskedtextbox layout */.e-control-wrapper.e-mask .e-maskedtextbox,
.e-upload.e-control-wrapper,
.e-bigger.e-small .e-upload.e-control-wrapper,
.e-tab .e-tab-header .e-toolbar-item .e-tab-text,
.e-tab .e-tab-header.e-vertical .e-hor-nav .e-popup-up-icon::before,
.e-tab .e-tab-header.e-vertical .e-hor-nav .e-popup-down-icon::before,
.e-tab-clone-element .e-tab-text,
.e-treeview.e-drag-item,
.e-menu-wrapper .e-menu-header,
.e-menu-container .e-menu-header,
.e-multi-select-wrapper input[type=text],
.e-multiselect.e-filled .e-multi-select-wrapper input[type=text],
.e-multi-select-wrapper .e-delim-values,
.e-multi-select-list-wrapper .e-selectall-parent .e-all-text,
.e-multi-select-wrapper .e-chips>.e-chipcontent,
.e-listbox-wrapper,
.e-listbox-container,
.e-listboxtool-wrapper,
.e-splitter.e-splitter-horizontal .e-pane,
.e-splitter.e-splitter-vertical .e-pane,
.e-grid,
.e-grid .e-row .e-input-group .e-input.e-field,
.e-grid .e-row .e-input-focus .e-input.e-field,
.e-bigger .e-grid .e-row .e-input-group .e-input.e-field,
.e-bigger .e-grid .e-row .e-input-focus .e-input.e-field,
.e-grid.e-bigger .e-row .e-input-group .e-input.e-field,
.e-grid.e-bigger .e-row .e-input-focus .e-input.e-field,
.e-colorpicker-popup.e-rte-dropdown .e-container.e-color-palette .e-clr-pal-rec-wpr .e-recent-clr-span,
.e-richtexteditor .e-linkheader,
.e-richtexteditor .e-audioheader,
.e-richtexteditor .e-videoheader,
.e-richtexteditor .e-video-url-wrap,
.e-rte-elements .e-linkheader,
.e-rte-elements .e-audioheader,
.e-rte-elements .e-videoheader,
.e-rte-elements .e-video-url-wrap,
.e-rte-img-dialog.e-dialog.e-device.e-dlg-modal .e-linkheader,
.e-rte-audio-dialog.e-dialog.e-device.e-dlg-modal .e-linkheader,
.e-rte-video-dialog.e-dialog.e-device.e-dlg-modal .e-linkheader,
.e-rte-import-dialog.e-dialog.e-device.e-dlg-modal .e-linkheader,
.e-dialog .e-img-uploadwrap .e-droptext,
.e-dialog .e-aud-uploadwrap .e-droptext,
.e-dialog .e-vid-uploadwrap .e-droptext,
.e-dialog .e-word-uploadwrap .e-droptext,
.e-dialog.e-device .e-vid-uploadwrap .e-droptext,
.e-rte-table-popup .e-rte-popup-header,
.e-inplaceeditor .e-editable-value-wrapper .e-editable-value,
.e-inplaceeditor .e-editable-value-container .e-editable-value,
.e-inplaceeditor-tip.e-tooltip-wrap .e-tip-content .e-editable-title,
.e-pv-redaction-property-panel-text,
.e-pv-redaction-page-mark-dialog,
.e-pivot-calc-dialog-div .e-treeview ul li .e-list-text,
.e-pivotfieldlist-container .e-adaptive-field-list-dialog .e-member-editor-container ul li .e-list-text,
.e-pivotfieldlist-container .e-member-editor-dialog .e-member-editor-container ul li .e-list-text,
.e-pivotfieldlist-container .e-member-editor-dialog .e-select-all-container ul li .e-list-text,
.e-button-drag-clone,
.e-pivotfieldlist-container,
.e-pivotfieldlist-container .e-field-list-container .e-field-table .e-field-list ul li .e-list-text,
.e-pivotfieldlist-container.e-rtl .e-field-table .e-field-list ul li .e-list-text,
.e-pivotfieldlist-container.e-device .e-adaptive-container .e-content .e-pivot-calc-outer-div .e-radio-wrapper .e-label,
.e-pivotview .e-member-editor-dialog .e-select-all-container ul li .e-list-text,
.e-pivotview .e-member-editor-dialog .e-member-editor-container ul li .e-list-text,
.e-pivottooltip p,
.e-query-builder .e-summary-text,
.e-message,
.e-blockeditor .e-block-container-wrapper {
    font-family: var(--cemr-font, "IBM Plex Sans", Arial, sans-serif);
}

.e-chart svg text {
    font-family: var(--cemr-font, "IBM Plex Sans", Arial, sans-serif) !important;
}

/* 2. Typography: crisp rendering, figures that line up, a calmer hierarchy. */
body {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.e-grid .e-rowcell,
.e-grid .e-summarycell,
td {
    font-variant-numeric: tabular-nums;
}

.page-title {
    font-size: 20px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}

:is(h3, h4, h5, .card-title) {
    letter-spacing: -0.005em;
}

label,
.form-label {
    font-weight: 600 !important;
}

/* Grid headers are quieter so the data reads first. */
.e-grid .e-headercell .e-headertext,
.e-grid .e-headercelldiv {
    font-size: 13px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #48494e);
}

/* 3. One button language: Bootstrap buttons match Syncfusion buttons
      (32px, 14px text, 4px corners). Small, large and link buttons keep
      their own size. */
.btn:not(.btn-sm, .btn-lg, .btn-link):not(.login-layout .btn) {
    --bs-btn-font-size: 14px;
    --bs-btn-padding-y: 5px;
    --bs-btn-padding-x: 14px;
    min-height: 32px !important;
    font-size: 14px !important;
    font-weight: 500;
}

.btn:not(.btn-link):not(.login-layout .btn) {
    border-radius: 4px !important;
}

/* 4. Cards: one radius, hairline border, flat at rest (DESIGN.md: no
      resting shadows). */
.card:not(.login-layout .card) {
    border-radius: 10px !important;
    border: 1px solid var(--md-sys-color-outline-variant, #cbcdd0) !important;
    box-shadow: none !important;
}

.card > .card-header:first-child {
    border-radius: 10px 10px 0 0;
}

/* 5. Breathing room around page content. */
.content {
    padding: 16px clamp(12px, 2vw, 24px) !important;
}

/* 6. Empty grids: centred and calm instead of a bare left-aligned line. */
.e-grid .e-emptyrow td {
    text-align: center !important;
    padding: 40px 16px !important;
    color: var(--md-sys-color-on-surface-variant, #48494e) !important;
}

.e-grid .e-emptyrow td:has(.cemr-empty, .cemr-skeleton-list) {
    padding: 0 !important;
    text-align: left !important;
}

/* 7. Small, smooth feedback; off for users who reduce motion. */
@media (prefers-reduced-motion: no-preference) {
    :is(.btn, .e-btn, .card, .e-grid .e-row, a) {
        transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
    }
}

.e-grid .e-row:hover .e-rowcell {
    background-color: var(--cemr-ui-hover, rgba(0, 0, 0, .03)) !important;
}

/* 8. Loading placeholders: grey shapes where content will appear, instead
      of zeros or a spinner. A slow shimmer runs only if motion is allowed. */
.cemr-skeleton {
    display: block;
    border-radius: 4px;
    background: color-mix(in srgb, var(--md-sys-color-on-surface, #1c1d1f) 8%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
    .cemr-skeleton,
    .stats-section-wrapper.is-loading :is(.admin-stat-main h2, .clinic-stat .stat-body h3) {
        animation: cemr-skeleton-pulse 1.4s ease-in-out infinite;
    }
}

@keyframes cemr-skeleton-pulse {
    50% { opacity: .55; }
}

.cemr-skeleton-list {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.cemr-skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cemr-skeleton-avatar {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.cemr-skeleton-lines {
    display: grid;
    flex: 1;
    gap: 6px;
}

.cemr-skeleton-line {
    height: 12px;
    width: 100%;
}

.cemr-skeleton-line.short {
    width: 40%;
}

/* KPI tiles while their first numbers load: each value becomes a placeholder
   bar and the trend badges and mini charts are hidden, so a "0" or "-100%"
   never flashes. The selector mirrors the dashboard's own !important value
   rule in app-theme.css so this one wins while loading. */
html body .cemr-dashboard-page .stats-section-wrapper.is-loading :is(.admin-stat-main h2, .clinic-stat .stat-body h3) {
    width: 72px;
    min-height: 1.1em;
    color: transparent !important;
    background: color-mix(in srgb, var(--md-sys-color-on-surface, #1c1d1f) 8%, transparent) !important;
    border-radius: 4px;
}

html body .cemr-dashboard-page .stats-section-wrapper.is-loading :is(.admin-stat-main h2, .clinic-stat .stat-body h3) *,
html body .stats-section-wrapper.is-loading :is(.growth, .wave-chart, .mini-chart, .stat-body span, .admin-stat-side small) {
    visibility: hidden !important;
}

/* 9. Empty states: say what is empty and what to do next. */
.cemr-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px 16px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant, #48494e);
}

.cemr-empty-icon {
    font-size: 28px;
    margin-bottom: 4px;
    color: var(--md-sys-color-outline, #73767a);
}

.cemr-empty-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1c1d1f);
}

.cemr-empty-hint {
    margin: 0 0 8px;
    max-width: 36ch;
    font-size: 13px;
}

/* 10. Dashboard KPI tiles: drop the decorative diagonal shape. */
.admin-stat-card .admin-stat-bg {
    display: none;
}

/* 11. Page headers: one pattern on every page. Title, one-line description,
   actions on the right, sitting on the page surface rather than in a box. */
html.cemr-theme body :is(.cemr-page-header, .pharmacy-page-header) {
    min-height: 0 !important;
    margin: 0 0 16px !important;
    padding: 4px 0 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

html.cemr-theme body :is(.cemr-page-header .page-title, .cemr-page-title, .pharmacy-page-header :is(h1, h2), .control-section h2.head) {
    color: var(--md-sys-color-on-surface) !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

html.cemr-theme body :is(.cemr-page-header .page-title, .cemr-page-title, .pharmacy-page-header :is(h1, h2)) {
    margin: 0 !important;
}

html.cemr-theme body :is(.cemr-page-subtitle, .pharmacy-page-header p) {
    margin: 2px 0 0 !important;
    color: var(--md-sys-color-on-surface-variant) !important;
    font-size: 13px !important;
}

html.cemr-theme body :is(.cemr-page-title-icon, .pharmacy-title-icon) {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
}

/* About 70 master pages (Doctor, Role, Species, Store...) sat in a 2/3-width
   column after an empty spacer column. Hide the spacer so they use the full width
   like every other page. */
html.cemr-theme .row > [class*="col-"]:empty:has(+ .control-section),
html.cemr-theme .row > .control-section + [class*="col-"]:empty {
    display: none;
}

html.cemr-theme .row > [class*="col-"]:empty + .control-section {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
}

/* The grid sits directly in a .row, whose negative margins pushed it past the title. */
html.cemr-theme .control-section > .content-wrapper > .row,
html.cemr-theme .control-section > .content-wrapper > .row > * {
    padding-inline: 0;
}

html.cemr-theme .control-section > .content-wrapper > .row {
    margin-inline: 0;
}

html.cemr-theme body .control-section h2.head {
    margin: 4px 0 16px !important;
    padding: 0 !important;
}

/* 12. Grids: lighter chrome so the data reads first. */

/* Toolbar on the content surface; only the column header stays tinted. */
html.cemr-theme body .e-grid > .e-toolbar,
html.cemr-theme body .e-grid > .e-toolbar .e-toolbar-items {
    background: var(--color-sf-content-bg-color) !important;
}

/* Filter row: compact fields that still keep a 3:1 outline (WCAG 1.4.11). */
html.cemr-theme body .e-grid .e-filterbarcell {
    padding: 4px 4px !important;
}

html.cemr-theme body .e-grid .e-filterbarcell :is(.e-input-group, .e-input-group.e-control-wrapper) {
    min-height: 28px !important;
    height: 28px !important;
}

html.cemr-theme body .e-grid .e-filterbarcell :is(input.e-input, .e-input-group input.e-input) {
    min-height: 26px !important;
    height: 26px !important;
    font-size: 13px !important;
}

/* Pager: the current page is filled, the rest stay quiet. */
html.cemr-theme body .e-pager .e-numericitem.e-currentitem,
html.cemr-theme body .e-pager .e-numericitem.e-currentitem:hover {
    background: var(--color-sf-primary) !important;
    color: var(--color-sf-primary-text-color) !important;
    border-color: var(--color-sf-primary) !important;
    border-radius: 4px;
    font-weight: 600;
}

/* Toolbar buttons take the toolbar colour at rest; theme hover and focus still apply. */
html.cemr-theme body .e-grid > .e-toolbar .e-tbar-btn:not(:hover, :focus, :active) {
    background: transparent !important;
}

/* 13. Forms: calm section headers, even rhythm, readable read-only fields. */

/* Section headers sit on the card surface with a hairline, not a tinted band. */
html.cemr-theme body :is(#addPatientForm, .cemr-form-page) .card-header {
    background: var(--cemr-ui-surface) !important;
    border-bottom: 1px solid var(--cemr-ui-border) !important;
}

/* Field wrappers: 4px instead of 8px above and below; the label sits in the space above the field. */
html.cemr-theme body :is(#addPatientForm, .cemr-form-page) .txt-full-width.pt-2.pb-2 {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

/* Labels of disabled and read-only fields stay readable; the grey field already says "not editable". */
html.cemr-theme body :is(.e-input-group, .e-float-input).e-disabled .e-float-text.e-label-top {
    color: var(--md-sys-color-on-surface-variant) !important;
    opacity: 1 !important;
}

/* 14. App shell: quiet top-bar icons, one type scale in the sidebar. */

/* Top-bar icon buttons are borderless at rest and tint on hover, so the
   search box and the account button carry the weight. */
html.cemr-theme body .main-wrapper > .header :is(.btn-icon, .back-button, .cemr-theme-trigger, .cemr-theme-toggle) {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

html.cemr-theme body .main-wrapper > .header :is(.btn-icon, .back-button, .cemr-theme-trigger, .cemr-theme-toggle):is(:hover, .active) {
    background: var(--cemr-ui-hover) !important;
    border-color: transparent !important;
}

/* Sidebar: main items 14px, sub-items 13px regular; the current page is bold. */
html.cemr-theme body #navbar-menu-container > ul > li > ul > li > a,
html.cemr-theme body #navbar-menu-container > ul > li > ul > li > a span {
    font-size: 14px !important;
}

html.cemr-theme body #navbar-menu-container li.submenu > ul > li a,
html.cemr-theme body #navbar-menu-container li.submenu > ul > li a span {
    font-size: 13px !important;
    font-weight: 400 !important;
}

html.cemr-theme body #navbar-menu-container li.submenu > ul > li a.active,
html.cemr-theme body #navbar-menu-container li.submenu > ul > li a.active span {
    font-weight: 600 !important;
}

/* 15. Dialogs: even padding and a firmer title. Button order lives in markup:
   Cancel on the left, the main action on the right. */
html.cemr-theme body .e-dialog .e-dlg-header-content {
    padding: 14px 16px !important;
}

html.cemr-theme body .e-dialog .e-dlg-header {
    font-weight: 600 !important;
}

html.cemr-theme body .e-dialog .e-footer-content {
    padding: 12px 16px !important;
}

/* 16. Grids with a right-frozen Actions column: Syncfusion pins the header
   cell but not its filter cell, so ordinary filter boxes scrolled out
   beside it. Pin that cell too and leave it empty; Actions isn't filterable. */
html.cemr-theme body .e-grid:has(.e-headercell.e-rightfreeze) .e-filterbar > .e-filterbarcell:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--color-sf-content-bg-color-alt1, var(--color-sf-content-bg-color)) !important;
    border-left: 1px solid var(--color-sf-border-light, var(--color-sf-border)) !important;
}

html.cemr-theme body .e-grid:has(.e-headercell.e-rightfreeze) .e-filterbar > .e-filterbarcell:last-child > * {
    visibility: hidden;
}

/* 17. A grid's own border is its frame. A card that only wraps a grid adds
   no second frame or padding (Patients, CaptureITPro Patients). */
html.cemr-theme body .card:has(> .card-body:only-child > .e-grid:only-child) {
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

html.cemr-theme body .card:has(> .card-body:only-child > .e-grid:only-child) > .card-body {
    padding: 0 !important;
}

/* The left frozen-column divider uses the focus colour by default; make it a
   neutral line like the right one. */
html.cemr-theme body .e-grid .e-leftfreeze.e-freezeleftborder {
    border-right-color: var(--color-sf-border-light, var(--color-sf-border)) !important;
}

/* 18. Page-header actions are one height: Bootstrap buttons match the 32px
   Syncfusion buttons beside them (icons at 16px fit inside). */
html.cemr-theme body :is(.cemr-page-header, .pharmacy-page-header) .btn:not(.btn-sm, .btn-lg, .btn-link) {
    height: 32px !important;
    min-height: 32px !important;
    padding-block: 0 !important;
    display: inline-flex !important;
    align-items: center;
}

/* Pharmacy's own .pharmacy-btn (38px, 6-7px corners) follows the same button
   language as Bootstrap and Syncfusion buttons: 32px tall, 4px corners. */
html.cemr-theme body .pharmacy-btn {
    height: 32px !important;
    min-height: 32px !important;
    padding-inline: 14px !important;
    border-radius: 4px !important;
    font-size: 14px !important;
}

/* 19. Dashboard: flat surfaces, one button style, nothing hidden off-edge. */

/* The page sits on the plain background (no teal glow in the corner). */
html.cemr-theme body .cemr-dashboard-page {
    background: none !important;
}

/* Quick actions sit in an even grid instead of scrolling off the right edge.
   One primary (New Appointment); every other action is the same outline button. */
html.cemr-theme body .cemr-dashboard-page .topbar.modern-actionbar {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    overflow: visible !important;
    gap: 8px !important;
    padding: 0 0 12px !important;
    margin-bottom: 16px !important;
    background: var(--cemr-background, var(--md-sys-color-background)) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

@container cemr-dashboard (min-width: 1100px) {
    html.cemr-theme body .cemr-dashboard-page .topbar.modern-actionbar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

html.cemr-theme body .cemr-dashboard-page .revenue-period-ddl {
    font-size: 13px;
}

html.cemr-theme body .cemr-dashboard-page .topbar.modern-actionbar .action-btn {
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 12px !important;
    gap: 8px !important;
    font-size: 13px !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}

html.cemr-theme body .cemr-dashboard-page .topbar.modern-actionbar .action-btn i {
    font-size: 18px !important;
}

html.cemr-theme body .cemr-dashboard-page .topbar.modern-actionbar .btn-patient:not(:hover) {
    background: var(--dash-surface) !important;
}

/* KPI tiles: flat, compact, no decorative sparklines (they carried no data). */
html.cemr-theme body .cemr-dashboard-page :is(.admin-stat-card, .clinic-stat) {
    min-height: 0 !important;
    padding: 16px !important;
    border-radius: 12px !important;
    background: var(--dash-surface) !important;
    box-shadow: none !important;
}

html.cemr-theme body .cemr-dashboard-page :is(.admin-stat-card, .clinic-stat):hover {
    transform: none !important;
}

html.cemr-theme body .cemr-dashboard-page :is(.admin-stat-bg, .wave-chart, .mini-chart) {
    display: none !important;
}

html.cemr-theme body .cemr-dashboard-page :is(.admin-stat-icon, .clinic-stat .stat-ico) {
    width: 36px !important;
    height: 36px !important;
}

/* Cards and their headers sit on the plain surface. */
html.cemr-theme body .cemr-dashboard-page .dash-grid > .card {
    background: var(--dash-surface) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}

html.cemr-theme body .cemr-dashboard-page .dash-grid > .card > .ch {
    background: var(--dash-surface) !important;
}

/* Cards scroll inside a fixed height; show the scrollbar so a cut-off row
   reads as "more below" (it was transparent). */
html.cemr-theme body .cemr-dashboard-page :is(.dash-grid > .card, .dashboard-scroll-area) {
    scrollbar-width: thin !important;
    scrollbar-color: var(--color-sf-border, #c5c6c9) transparent !important;
}

/* Header links meet the 24px target size; plain labels look like labels. */
html.cemr-theme body .cemr-dashboard-page .ch-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding-inline: 4px;
}

html.cemr-theme body .cemr-dashboard-page .ch-meta {
    font-size: 12px;
    font-weight: 500;
    color: var(--dash-muted, var(--md-sys-color-on-surface-variant));
}

/* Per-card refresh buttons appear on hover or keyboard focus (always on
   touch screens, and while spinning). */
@media (hover: hover) {
    html.cemr-theme body .cemr-dashboard-page .dash-grid > .card .card-refresh-btn:not(.spinning) {
        opacity: 0;
        transition: opacity .15s ease;
    }

    html.cemr-theme body .cemr-dashboard-page .dash-grid > .card:is(:hover, :focus-within) .card-refresh-btn {
        opacity: 1;
    }
}

/* This Week: all seven days fit the card. */
html.cemr-theme body .cemr-dashboard-page .cemr-week-calendar-card .cal-week {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 6px !important;
    overflow: visible !important;
}

html.cemr-theme body .cemr-dashboard-page .cemr-week-calendar-card .cal-day {
    min-height: 52px;
    padding: 8px 2px !important;
}

html.cemr-theme body .cemr-dashboard-page .cemr-week-calendar-card .cal-day:hover {
    transform: none;
}

/* Doctor availability says it in words as well as colour (WCAG 1.4.1). */
html.cemr-theme body .cemr-dashboard-page .avail-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--dash-muted, var(--md-sys-color-on-surface-variant));
}

/* 20. Colour swatches in master grids (were read-only text inputs). */
html.cemr-theme body .cemr-color-swatch {
    display: inline-block;
    width: 48px;
    height: 20px;
    vertical-align: middle;
    border: 1px solid var(--color-sf-border, #cbcdd0);
    border-radius: 4px;
}

/* 21. Header patient search is a Syncfusion textbox inside the rounded search
   container: the container keeps the border and focus ring, the textbox stays flat. */
html.cemr-theme body .global-search .global-search-input.e-input-group,
html.cemr-theme body .global-search .global-search-input.e-input-group.e-input-focus {
    flex: 1 1 0%;
    min-width: 0;
    margin: 0;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}
html.cemr-theme body .global-search .global-search-input.e-input-group input.e-input {
    padding-left: 0;
    text-overflow: ellipsis;
}

/* 22. A Syncfusion field inside a Bootstrap .input-group is the group's middle
   field (dose steppers, search boxes): it fills the space, joins its neighbours
   without a double border, and honours text-center. */
html.cemr-theme body .input-group > .e-input-group {
    flex: 1 1 auto;
    width: 1% !important;
    min-width: 0;
    margin: 0 !important;
}
html.cemr-theme body .input-group > .e-input-group:not(:first-child) {
    margin-left: -1px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}
html.cemr-theme body .input-group > .e-input-group:not(:last-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
html.cemr-theme body .e-input-group.text-center input.e-input {
    text-align: center;
}

/* 23. Consultation dose steppers: the Syncfusion numeric field is the small
   borderless value between the - and + buttons, as the native field was
   (the .stepper pill keeps the border and the active tint). */
html.cemr-theme body .stepper > .e-input-group.step-input {
    flex: 0 0 auto;
    width: 36px !important;
    min-width: 0;
    height: 26px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}
html.cemr-theme body .stepper--days > .e-input-group.step-input {
    width: 40px !important;
}
html.cemr-theme body .stepper > .e-input-group.step-input input.e-input {
    height: 26px;
    min-height: 0;
    padding: 0 !important;
    text-align: center;
    font-size: 0.9rem;
    background: transparent !important;
}

/* Duration unit: the old native-select padding would push the text down. */
html.cemr-theme body .e-input-group.dur-unit-sel {
    height: 28px;
    padding: 0 !important;
    font-size: 12px;
}
html.cemr-theme body .e-input-group.dur-unit-sel input.e-input {
    height: 26px;
    min-height: 0;
    font-size: 12px;
}

/* 24. Card titles in dark mode: app.css fixes .card .card-title to #0f172a
   (slate-900), invisible on dark cards (Consultation "Do's & Don'ts"). */
html.cemr-theme-dark body .card .card-title {
    color: var(--md-sys-color-on-surface);
}

/* 25. Report findings lists (Advance report, RTF report) hard-code a white
   background, so their light text vanished in dark mode. */
html.cemr-theme-dark body :is(.commentlist-container, .dialogue-commentlist-container) {
    background-color: var(--md-sys-color-surface-container-low) !important;
    color: var(--md-sys-color-on-surface);
}
html.cemr-theme-dark body .commentlist-item {
    border-bottom-color: var(--md-sys-color-outline-variant) !important;
    color: var(--md-sys-color-on-surface);
}
html.cemr-theme-dark body .commentlist-item:hover {
    background-color: var(--md-sys-color-surface-container-high) !important;
}

/* 26. Bootstrap .btn-secondary is the neutral button (Cancel, Close) in light
   mode too: app.css painted it in the primary colour, so Cancel and Save
   looked the same. Same tokens as the dark-mode rule in cemr-dark-pages.css. */
html.cemr-theme:not(.cemr-theme-dark) body .btn.btn-secondary {
    background-color: var(--md-sys-color-surface-container-high) !important;
    border: 1px solid var(--md-sys-color-outline) !important;
    color: var(--md-sys-color-on-surface) !important;
}
html.cemr-theme:not(.cemr-theme-dark) body .btn.btn-secondary:is(:hover, :focus-visible, :active, .active) {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, var(--md-sys-color-surface)) !important;
    border-color: var(--md-sys-color-outline) !important;
    color: var(--md-sys-color-on-surface) !important;
}

/* 27. Appointment / doctor schedule editor: the read-only token number box
   hard-codes a near-white fill, so it showed as a white block in dark mode. */
html.cemr-theme-dark body .token-number-display {
    background-color: var(--md-sys-color-surface-container-high) !important;
    border-color: var(--md-sys-color-outline-variant) !important;
    color: var(--md-sys-color-on-surface) !important;
}

/* 28. Consultation patient header: the accordion is painted in the primary
   colour with white text, but the Syncfusion theme gives an expanded item's
   header a pale tint, so the white title and patient details dropped to
   1.3:1 once the panel was opened. Keep the expanded header the same as the
   collapsed one. */
html.cemr-theme body .e-accordion .e-acrdn-item:has(.patient-details-top) > .e-acrdn-header {
    background-color: var(--md-sys-color-primary) !important;
}
html.cemr-theme body .e-accordion .e-acrdn-item:has(.patient-details-top) > .e-acrdn-header:is(:hover, :focus, :focus-visible, :active) {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 88%, #000) !important;
}
html.cemr-theme body .e-accordion .e-acrdn-item:has(.patient-details-top) > .e-acrdn-header .e-toggle-icon .e-icons {
    color: #fff !important;
}

/* 29. Consultation row components (complaint, diagnosis, allergy,
   immunisation, investigation): Syncfusion inputs take color:inherit, and
   these rows inherit the slate #585C7B that app.css gives .card, so in dark
   mode the entered values read at 2.6:1. Give the rows, and Syncfusion
   fields inside cards, the surface text colour in dark mode. */
html.cemr-theme-dark body :is(.ar-row, .imr-row, .ccr-row, .dxr-row, .invr-row),
html.cemr-theme-dark body .card :is(.e-input-group, .e-float-input) {
    color: var(--md-sys-color-on-surface);
}
/* Consultation borders in dark mode: app.css paints .border #e2e8f0 with
   !important, so the existing dark rule never applied and the topic strip
   kept a bright outline; the complaint footer line had the same light grey. */
html.cemr-theme-dark:has(.topics-section) body .border:not([class*="border-"]) {
    border-color: var(--md-sys-color-outline-variant) !important;
}
html.cemr-theme-dark body .cc-complaint-footer {
    border-top-color: var(--md-sys-color-outline-variant);
}

/* 30. IPD doctor note vitals and blood sugar: the unit box (.dn-input-unit-group)
   draws the field border, so the Syncfusion field inside it drops its own
   border; focus and validation errors show on the unit box instead. */
html.cemr-theme body .dn-input-unit-group .e-input-group {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    margin: 0 !important;
}
html.cemr-theme body .dn-input-unit-group .e-input-group::before,
html.cemr-theme body .dn-input-unit-group .e-input-group::after {
    display: none !important;
}
html.cemr-theme body .dn-input-unit-group:has(.e-input-group.e-error) {
    border-color: var(--ipd-danger, #dc2626) !important;
}
html.cemr-theme body .dn-bp-inputs .e-input-group input.e-input {
    text-align: center;
}

/* 31. Search fields with a leading icon (IPD investigations, medication
   orders, medication return, pharmacy worklist).
   - .search-box draws the border and holds the icon: the Syncfusion field
     inside drops its own border.
   - Bootstrap .input-group with an icon addon: the Syncfusion field joins the
     addon as one control (no gap, shared border, square inner corners). */
html.cemr-theme body .search-box > .e-input-group {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}
html.cemr-theme body .search-box > .e-input-group::before,
html.cemr-theme body .search-box > .e-input-group::after {
    display: none !important;
}
html.cemr-theme body .input-group > .input-group-text + .e-input-group {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    margin: 0 0 0 -1px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}
html.cemr-theme body .input-group > .input-group-text:has(+ .e-input-group) {
    background-color: var(--md-sys-color-surface) !important;
    border-color: var(--md-sys-color-outline);
    color: var(--md-sys-color-on-surface-variant);
}

/* 32. Vital chart side cards: headings keep the icon and title together on
   the left, with any count badge at the right (ipd.css spread them with
   space-between, so "Extremes" sat at the right edge). */
html.cemr-theme body .vitals-sidebar .ipd-card > h3 {
    justify-content: flex-start;
}
html.cemr-theme body .vitals-sidebar .ipd-card > h3 > .badge {
    margin-left: auto;
}

/* 33. Grid filter bar: Syncfusion draws a disabled filter box under columns
   that cannot be filtered (Actions / buttons columns). It looked like a live
   field, so hide it; the cell keeps its size. */
html.cemr-theme body .e-grid .e-filterbar .e-filterbarcell input.e-input[disabled] {
    visibility: hidden;
}

/* 34. IPD bordered tables (discharge clearances): cell lines use the soft
   outline like the ledger table beside it, not the strong field outline. */
html.cemr-theme body .ipd-page-container .table-bordered > :not(caption) > * > * {
    border-color: var(--md-sys-color-outline-variant);
}

/* 35. IPD disabled buttons read as unavailable, not as faded primaries: flat
   neutral fill, muted text. Approved clearance buttons (disabled on purpose,
   shown as a status) keep their success colour. Tooltips still show. */
html.cemr-theme body .ipd-page-container :is(.e-btn, .btn):is(:disabled, .e-disabled, .disabled):not(.e-success) {
    background: var(--md-sys-color-surface-container-high) !important;
    border-color: var(--md-sys-color-outline-variant) !important;
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 50%, transparent) !important;
    opacity: 1;
    box-shadow: none !important;
    cursor: not-allowed;
}

/* 36. Bed Board vacant cards: tariff beside the ready label on one line; the
   "Cleaned & Sanitized" line repeats what the Vacant status already says. */
html.cemr-theme body .vacant-state-structured {
    min-height: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 12px;
    row-gap: 4px;
    padding: 2px 0;
}
html.cemr-theme body .vacant-state-structured .vacant-sanitized-line {
    display: none;
}

/* 37. Empty-grid message shown once loading has finished. */
.cemr-grid-empty {
    color: var(--md-sys-color-on-surface-variant);
    font-size: var(--cemr-font-size-sm, 13px);
}

/* 38. Dark mode: outlined danger buttons use the light danger tone so their
   text stays readable on the dark surface (was 3.75:1). */
html.cemr-theme-dark body .ipd-page-container .e-btn.e-outline.e-danger:not(:disabled):not(.e-disabled):not(:hover) {
    color: var(--ipd-danger);
    border-color: var(--ipd-danger);
}

/* 39. Soft alerts (IPD billing readiness, discharge balance due): a quiet
   amber strip instead of a loud red box. The amount itself keeps its red. */
html.cemr-theme body .cemr-soft-alert {
    background: var(--ipd-warning-bg);
    border: 1px solid color-mix(in srgb, var(--ipd-warning) 35%, transparent);
    border-radius: 8px;
    color: var(--md-sys-color-on-surface);
    box-shadow: none;
}
html.cemr-theme body .cemr-soft-alert > .fa {
    color: var(--ipd-warning);
    font-size: 16px;
}
html.cemr-theme body .cemr-soft-alert-badge {
    background: transparent;
    color: var(--ipd-warning);
    border: 1px solid var(--ipd-warning);
    font-weight: 600;
}
html.cemr-theme body .cemr-soft-alert-details > summary {
    cursor: pointer;
    color: var(--ipd-primary-text, var(--md-sys-color-primary));
    font-weight: 600;
    width: max-content;
}
html.cemr-theme body .cemr-soft-alert-table {
    background: var(--md-sys-color-surface);
    border-color: var(--md-sys-color-outline-variant) !important;
}

/* 40. IPD patient screens: title row, patient banner and tabs sit closer so
   content starts higher. Only the patient frame (header followed by the
   banner); the app-wide 56px page header stays elsewhere. */
html.cemr-theme body .ipd-page-container .ipd-header:has(+ .ipd-patient-banner) {
    min-height: 0;
    margin-bottom: 6px;
    padding-bottom: 0;
}
html.cemr-theme body .ipd-page-container .ipd-patient-banner + .ipd-tabs {
    padding-top: 4px;
    padding-bottom: 4px;
    margin-bottom: 12px;
}

/* 41. Consultation rows, light mode: the secondary/placeholder variables were
   only defined for dark mode, so labels fell back to #888-#bbb (1.6-3.5:1).
   Light now uses the same tokens as dark. Taper, AF and the dose separators
   get readable tones too. */
html.cemr-theme:not(.cemr-theme-dark) {
    --e-content-secondary-color: var(--md-sys-color-on-surface-variant);
    --e-content-placeholder-color: var(--md-sys-color-on-surface-variant);
}
html.cemr-theme:not(.cemr-theme-dark):has(.topics-section) .taper-toggle:not(.taper-toggle--on):not(:hover) {
    color: var(--md-sys-color-on-surface-variant);
}
html.cemr-theme:not(.cemr-theme-dark):has(.topics-section) .dose-dot {
    color: var(--md-sys-color-on-surface-variant);
}
html.cemr-theme:not(.cemr-theme-dark):has(.topics-section) .bfaf-btn.af:not(.on) {
    color: #a33a00;
}
html.cemr-theme:not(.cemr-theme-dark):has(.topics-section) .bfaf-btn.af.on {
    background: #b34000;
    border-color: #b34000;
}

/* 42. App-wide legacy colours from app.css that fail contrast.
   - .card / .card-body text was #585C7B in both themes (2.8:1 on dark cards).
   - .text-muted was #88898c (3.5:1 on white); now the muted token IPD uses.
   - .text-danger was #E82646 (4.2:1); light mode gets a deeper red of the
     same hue. Dark mode already has its own danger tone. */
html.cemr-theme-dark body .card,
html.cemr-theme-dark body .card:not([class*="card-bg-"]) .card-body {
    color: var(--md-sys-color-on-surface);
}
/* Dark mode grid pager: other page numbers used the dark primary (2.6:1). */
html.cemr-theme-dark body .e-pager .e-numericitem:not(.e-currentitem) {
    color: var(--md-sys-color-on-surface);
}
html.cemr-theme body .text-muted {
    color: var(--md-sys-color-on-surface-variant) !important;
}
html.cemr-theme:not(.cemr-theme-dark) body .text-danger:not([class*="bg-"]) {
    color: #c8102e !important;
}

/* 43. Consultation patient card: "View More..." sat in the 60px photo column
   and wrapped onto two lines. One compact line, centred under the photo. */
html.cemr-theme body .avatar.avatar-xl a.btn[href*="ViewMore"] {
    white-space: nowrap;
    width: max-content;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 10px;
    font-size: 12px;
    line-height: 1.4;
}

/* 44. Outline primary buttons (report viewer Print, IPD quick patient,
   pharmacy audit details) showed Syncfusion's default indigo; teal instead. */
html.cemr-theme body .e-btn.e-outline.e-primary:not(:disabled):not(.e-disabled):not(:hover):not(.e-active) {
    color: var(--cemr-primary-text, var(--md-sys-color-primary));
    border-color: var(--md-sys-color-primary);
    background: transparent;
}
html.cemr-theme body .e-btn.e-outline.e-primary:not(:disabled):not(.e-disabled):is(:hover, .e-active) {
    color: var(--md-sys-color-on-primary, #fff);
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-primary);
}

/* 45. Report viewer toolbar. WhatsApp keeps its brand green but as an outline
   like Email (white on #25D366 was 1.98:1); the dialog's solid WhatsApp
   button gets dark text. Dark mode: readable Print Without Header and Email,
   and the viewer's own light page bar keeps dark "of N" text. */
html.cemr-theme body .rv-toolbar .e-btn.btn-wa:not(:hover) {
    background: transparent !important;
    color: #15803d !important;
    border-color: #25D366 !important;
}
html.cemr-theme body .btn-wa:not(.e-outline),
html.cemr-theme body .rv-toolbar .e-btn.btn-wa:hover {
    background: #25D366 !important;
    border-color: #25D366 !important;
    color: #0b2e18 !important;
}
html.cemr-theme-dark body .rv-toolbar .e-btn.btn-wa:not(:hover) {
    color: #25D366 !important;
}
html.cemr-theme-dark body .rv-toolbar .e-btn.e-outline:not(.e-primary):not(.e-success):not(.btn-wa):not(:disabled):not(:hover) {
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-outline);
}
html.cemr-theme-dark body .rv-toolbar .e-btn.e-outline.e-success:not(:disabled):not(:hover) {
    color: color-mix(in srgb, #15803d 45%, #ffffff);
    border-color: color-mix(in srgb, #15803d 60%, #ffffff);
}
html.cemr-theme-dark body [id$="_toolbarContainer"].e-toolbar .e-toolbar-item.e-template span:not([class*="e-icons"]) {
    color: inherit !important;
}

/* 46. Report viewer Email / WhatsApp dialogs: labels used a fixed slate
   (1.58:1 in dark mode) and single-line fields were 30px, not 32px. */
html.cemr-theme body .rv-field label {
    color: var(--md-sys-color-on-surface-variant);
}
html.cemr-theme body .rv-field .e-input-group:not(.e-multi-line-input) {
    min-height: 32px;
}
/* The Bold Reports stylesheet repaints these dialogs light (#f9fafb) even in
   dark mode; give them the normal dark dialog surface. */
html.cemr-theme-dark body .e-dialog:has(.rv-dialog-body),
html.cemr-theme-dark body .e-dialog:has(.rv-dialog-body) :is(.e-dlg-header-content, .e-dlg-content, .e-footer-content) {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}
html.cemr-theme-dark body .e-dialog:has(.rv-dialog-body) :is(.e-dlg-header, .e-checkbox-wrapper .e-label) {
    color: var(--md-sys-color-on-surface) !important;
}
html.cemr-theme body .e-dialog:has(.rv-dialog-body) .e-input-group.e-input-focus {
    border-color: var(--md-sys-color-primary) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent) !important;
}
html.cemr-theme-dark body .e-dialog:has(.rv-dialog-body) .e-input-group {
    background: var(--md-sys-color-surface) !important;
    border-color: var(--md-sys-color-outline) !important;
}
html.cemr-theme-dark body .e-dialog:has(.rv-dialog-body) .e-input-group :is(input, textarea) {
    background: transparent !important;
    color: var(--md-sys-color-on-surface) !important;
}
html.cemr-theme-dark body .e-dialog:has(.rv-dialog-body) .e-footer-content .e-btn:not(.e-primary):not(.btn-wa) {
    background: var(--md-sys-color-surface-container) !important;
    border-color: var(--md-sys-color-outline-variant) !important;
    color: var(--md-sys-color-on-surface) !important;
}

/* 47. Appointment calendars. Event text colour now follows each doctor's
   colour (set per event); the faded 0.88 opacity pushed it under 4.5:1.
   Dark mode: active view, today's date and the time marker used the dark
   primary (2.6:1). */
html.cemr-theme body .e-schedule .e-appointment :is(.appt-location, .appt-starttime, .appt-endtime) {
    opacity: 1;
}
html.cemr-theme-dark body .e-schedule :is(.e-toolbar .e-active-view .e-tbar-btn-text, .e-header-day.e-current-day, .e-current-day .e-header-day, .e-current-day .e-header-date, .e-header-date.e-current-day, .e-current-time) {
    color: var(--cemr-primary-text, var(--md-sys-color-primary)) !important;
}
/* Billing required-field star (#d94242 was 4.37:1 on white). */
html.cemr-theme:not(.cemr-theme-dark) body .required-star {
    color: #c8102e;
}

/* 48. More legacy text colours.
   - .text-warning was #EAB300 app-wide (1.92:1 on white): light mode gets a
     deeper amber of the same hue; dark mode keeps the bright one.
   - Inline teal #0f766e (pharmacy audit metrics) had no dark-mode tone.
   - POS / sales-return shortcut hints (#64748b, 4.34:1). */
html.cemr-theme:not(.cemr-theme-dark) body .text-warning:not([class*="bg-"]):not(.spinner-border) {
    color: #9a6700 !important;
}
html.cemr-theme-dark body [style*="color: #0f766e"]:not([style*="background"]) {
    color: color-mix(in srgb, #0f766e 45%, #ffffff) !important;
}
html.cemr-theme:not(.cemr-theme-dark) body .pos-search-kbd {
    color: var(--md-sys-color-on-surface-variant);
}

/* 49. About page hero: a generic paragraph colour rule turned the hero copy
   grey on teal (1:1). Keep it on-primary, as the hero intends. */
html.cemr-theme body .hero :is(.hero-main, .hero-sub) {
    color: var(--md-sys-color-on-primary);
}

/* 50. Fitted grids (GridStandard.FitColumnsAsync, class "cemr-grid-fit"): auto-fit sets each table to the
   sum of its column widths. Let the tables fill the grid so spare width spreads across the fitted columns. */
.e-grid.cemr-grid-fit :is(.e-gridheader, .e-gridcontent) .e-table {
    min-width: 100%;
}

/* 51. Header account: the signed-in name is a quiet label (it was a teal split button whose only menu item
   was Logout), and Log out is a direct icon button that asks first (Header.razor). */
html.cemr-theme .header-user .header-account {
    display: flex;
    align-items: center;
    gap: 4px;
}

html.cemr-theme .header-user .header-account-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px 0 10px;
    border-radius: 8px;
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
}

html.cemr-theme .header-user .header-account-name i {
    font-size: 18px;
    color: var(--cemr-primary-text, var(--md-sys-color-primary));
}

html.cemr-theme .header-user .header-account-text {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 52. Grid toolbars: Update and Cancel only matter while a row is being edited. Hide them while they are
   disabled instead of showing two greyed-out buttons on every master page. */
.e-grid .e-toolbar .e-toolbar-item.e-overlay:is([id$="_update"], [id$="_cancel"]) {
    display: none;
}

/* 53. Pharmacy page headers: same 40px icon tile and title size as the other page headers. */
html.cemr-theme body .pharmacy-page-header .pharmacy-title-icon {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 18px;
}

/* 54. Grid empty message: the empty row spans the whole table, so on wide grids its centred text sat under the
   pinned Actions column ("No records t"). Pin the message to the left edge of the visible area. */
.e-grid .e-emptyrow td {
    text-align: left !important;
}

.e-grid .e-emptyrow td > * {
    position: sticky;
    left: 12px;
    display: inline-block;
}

/* 55. Bootstrap hover tables in dark mode: Bootstrap 5.1 colours a hovered row's cells #212529, so plain cells
   went dark-on-dark (e.g. Current Order Batch: Dose, Duration, Qty, PRN vanished). Keep theme text and use a
   light hover tint instead. Light mode is unchanged. */
html.cemr-theme-dark .table {
    --bs-table-hover-color: var(--md-sys-color-on-surface);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
}

/* 56. Syncfusion tabs in dark mode: hovered tab text used the raw brand teal (--color-sf-primary, about 2.8:1 on
   the dark page). Use the readable primary text colour instead, as the rest of dark mode does. */
html.cemr-theme-dark .e-tab .e-tab-header .e-toolbar-item .e-tab-wrap:hover :is(.e-tab-text, .e-tab-icon) {
    color: var(--cemr-primary-text, var(--md-sys-color-primary));
}

/* 57. Toasts (ToastComponent, bottom right): Syncfusion pads the first title/content line 48px for an icon laid
   over the text, but here the icon sits beside it, so the text started ~62px after the icon. Keep a 10px gap. */
body .e-toast-container .e-toast.e-toast-header-icon .e-toast-message :is(.e-toast-title:first-child, .e-toast-content) {
    padding-left: 0; /* :first-child inside :is() outranks Syncfusion's rules; the line under a title lines up too */
}

.e-toast-container .e-toast .e-toast-icon {
    margin-right: 10px;
}

/* 58. Code panels (<pre class="bg-light text-dark">, e.g. Pharmacy Audit Trail snapshots) in dark mode: bg-light stayed
   #f8f9fa while text-dark turned light, so the JSON was pale grey on white. Use the dark surface and theme text. */
html.cemr-theme-dark pre.bg-light {
    background-color: var(--md-sys-color-surface-container-high) !important;
    border-color: var(--md-sys-color-outline-variant) !important;
    color: var(--md-sys-color-on-surface) !important;
}

/* 59. Native <select> option lists in dark mode: selects with a transparent background (POS store and GST mode)
   opened a white option list in light theme text, so unselected options were near-white on white.
   Give the options the dark surface and theme text. */
html.cemr-theme-dark select option,
html.cemr-theme-dark select optgroup {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}
