/*!
 * Doctorino HMS - design system (v3 "Indigo Clinical")
 * ---------------------------------------------------------------------------
 * Professional blue/indigo clinical UI. Built to sit on top of Bootstrap 4 /
 * SB Admin 2 and replace the previous theme entirely.
 *
 * Contract kept intact so no Blade view needs to change to keep working:
 *   - every --hms-* custom property below
 *   - every .hms-* component/utility class
 *   - the shell ids/classes used by the JS layer:
 *       #page-top, #wrapper, #content-wrapper, #content, #accordionSidebar,
 *       .sidebar, .hms-sidebar, .hms-topbar, .hms-backdrop, .scroll-to-top,
 *       .hms-nav-trigger, .hms-chevron, .hms-nav-ext, body.hms-sidebar-open
 * ---------------------------------------------------------------------------
 */

/* ============================================================== tokens ==== */

:root {
    /* brand ---------------------------------------------------------------- */
    --hms-primary: #4f46e5;
    --hms-primary-hover: #4338ca;
    --hms-primary-active: #3730a3;
    --hms-primary-soft: #eef2ff;
    --hms-primary-border: #c7d2fe;
    --hms-primary-text: #4338ca;
    --hms-ring: rgba(79, 70, 229, 0.24);

    /* accent + status ------------------------------------------------------ */
    --hms-info: #0ea5e9;
    --hms-info-soft: #e0f2fe;
    --hms-info-text: #0369a1;
    --hms-success: #059669;
    --hms-success-soft: #d1fae5;
    --hms-success-text: #047857;
    --hms-warning: #d97706;
    --hms-warning-soft: #fef3c7;
    --hms-warning-text: #b45309;
    --hms-danger: #dc2626;
    --hms-danger-hover: #b91c1c;
    --hms-danger-soft: #fee2e2;
    --hms-danger-text: #b91c1c;
    --hms-purple: #7c3aed;
    --hms-purple-soft: #ede9fe;
    --hms-teal: #0d9488;
    --hms-teal-soft: #ccfbf1;

    /* neutral surfaces ----------------------------------------------------- */
    --hms-canvas: #f4f6fb;
    --hms-surface: #ffffff;
    --hms-surface-alt: #f8fafc;
    --hms-surface-sunken: #eef1f7;
    --hms-border: #e5e8f0;
    --hms-border-strong: #d3d8e4;
    --hms-text: #1e2130;
    --hms-text-muted: #64748b;
    --hms-text-subtle: #94a3b8;

    /* sidebar (deep indigo) ------------------------------------------------ */
    --hms-sidebar-bg: #1e1b4b;
    --hms-sidebar-bg-2: #312e81;
    --hms-sidebar-border: rgba(255, 255, 255, 0.08);
    --hms-sidebar-hover: rgba(255, 255, 255, 0.08);
    --hms-sidebar-text: #c7cbf0;
    --hms-sidebar-text-strong: #ffffff;
    --hms-sidebar-active: #6366f1;
    --hms-sidebar-w: 268px;
    --hms-topbar-h: 68px;

    /* shape ---------------------------------------------------------------- */
    --hms-radius-sm: 6px;
    --hms-radius: 10px;
    --hms-radius-lg: 16px;
    --hms-radius-pill: 999px;

    /* elevation ------------------------------------------------------------ */
    --hms-shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --hms-shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --hms-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
    --hms-shadow-lg: 0 18px 40px rgba(16, 24, 40, 0.16);

    /* type + motion -------------------------------------------------------- */
    --hms-font: "Inter", "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --hms-font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
    --hms-transition: 140ms ease;

    /* bootstrap bridge (used by sb-admin-2 utilities) ----------------------- */
    --blue: #4f46e5;
    --indigo: #4f46e5;
    --purple: #7c3aed;
    --pink: #db2777;
    --red: #dc2626;
    --orange: #ea580c;
    --yellow: #d97706;
    --green: #059669;
    --teal: #0d9488;
    --cyan: #0ea5e9;
    --primary: #4f46e5;
    --gray: #64748b;
    --gray-dark: #1e2130;
    --secondary: #64748b;
    --success: #059669;
    --info: #0ea5e9;
    --warning: #d97706;
    --danger: #dc2626;
    --light: #f4f6fb;
    --dark: #1e2130;
}

/* ================================================================ base ==== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--hms-font);
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--hms-text);
    background-color: var(--hms-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body,
#wrapper,
#content-wrapper,
#content {
    background-color: var(--hms-canvas);
}

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    font-weight: 700;
    color: var(--hms-text);
    letter-spacing: -0.01em;
}

h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.5rem; }
h3, .h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: 0.875rem; }

p { margin-top: 0; margin-bottom: 1rem; }

a {
    color: var(--hms-primary);
    text-decoration: none;
    transition: color var(--hms-transition);
}

a:hover,
a:focus {
    color: var(--hms-primary-hover);
    text-decoration: none;
}

hr {
    border: 0;
    border-top: 1px solid var(--hms-border);
    margin: 1rem 0;
}

code, pre, .hms-mono, .hms-font-mono {
    font-family: var(--hms-font-mono);
    font-size: 0.85em;
}

.hms-font { font-family: var(--hms-font) !important; }
.hms-html { font-size: 100%; }

[hidden] { display: none !important; }

::selection {
    background: var(--hms-primary);
    color: #fff;
}

/* ------------------------------------------------------------ scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #c2c9d8;
    border: 2px solid var(--hms-canvas);
    border-radius: var(--hms-radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: #a7b0c4; }

.sidebar ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-color: transparent;
}

/* ---------------------------------------------------------------- focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--hms-primary);
    outline-offset: 2px;
    border-radius: var(--hms-radius-sm);
}

/* ============================================================== layout ==== */

#wrapper {
    display: flex;
    width: 100%;
}

#content-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

#content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.hms-container {
    width: 100%;
    padding: 4px 22px 28px;
    flex: 1 0 auto;
}

#content-wrapper {
    transition: padding var(--hms-transition);
}

/* ============================================================== sidebar ==== */

.hms-sidebar {
    width: var(--hms-sidebar-w);
    min-width: var(--hms-sidebar-w);
    min-height: 100vh;
    background: linear-gradient(185deg, var(--hms-sidebar-bg-2) 0%, var(--hms-sidebar-bg) 60%, #15123a 100%);
    padding: 0 0 1.25rem;
    position: relative;
    z-index: 1030;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.25) transparent;
}

.hms-sidebar .nav-item {
    position: relative;
    list-style: none;
}

.hms-sidebar .nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* auto, not 100%: a full-width block plus the 0.65rem side margins pushed
       every row 10.4px past the rail and gave the sidebar a horizontal scroll. */
    width: auto;
    padding: 0.7rem 1.15rem;
    margin: 0.1rem 0.65rem;
    border-radius: var(--hms-radius-sm);
    color: var(--hms-sidebar-text);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    transition: background var(--hms-transition), color var(--hms-transition);
}

.hms-sidebar .nav-item .nav-link i,
.hms-sidebar .nav-item .nav-link .fas,
.hms-sidebar .nav-item .nav-link .far {
    flex: 0 0 1.15rem;
    width: 1.15rem;
    text-align: center;
    font-size: 0.95rem;
    color: inherit;
}

.hms-sidebar .nav-item .nav-link span {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    word-break: break-word;
}

.hms-sidebar .nav-item .nav-link:hover,
.hms-sidebar .nav-item .nav-link:focus {
    color: var(--hms-sidebar-text-strong);
    background: var(--hms-sidebar-hover);
}

.hms-sidebar .nav-item.active > .nav-link,
.hms-sidebar .nav-item > .nav-link.hms-active {
    color: var(--hms-sidebar-text-strong);
    background: var(--hms-sidebar-active);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

.hms-sidebar .nav-item.active > .nav-link i,
.hms-sidebar .nav-item > .nav-link.hms-active i {
    color: #fff;
}

/* brand */
.hms-sidebar > li:first-child {
    margin-bottom: 0.25rem;
}

.hms-sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--hms-topbar-h);
    padding: 0 1.35rem;
    color: var(--hms-sidebar-text-strong);
    text-decoration: none;
}

.hms-sidebar .sidebar-brand:hover { color: #fff; }

.hms-sidebar .sidebar-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--hms-radius);
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.45);
}

.hms-sidebar .sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.15;
    text-transform: none;
}

.hms-sidebar .sidebar-brand-text sup {
    font-size: 0.6em;
    font-weight: 700;
    color: #a5b4fc;
    top: -0.35em;
}

/* headings + dividers */
.hms-sidebar > li.sidebar-heading,
.hms-sidebar .sidebar-heading {
    padding: 1.1rem 1.5rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(199, 203, 240, 0.62);
}

.hms-sidebar .sidebar-divider {
    border: 0;
    border-top: 1px solid var(--hms-sidebar-border);
    margin: 0.6rem 1.35rem;
}

.hms-sidebar li > .sidebar-divider { margin: 0.6rem 1.35rem !important; }

/* submenu ------------------------------------------------------------------
   sb-admin-2 owns these at high specificity and its defaults are wrong for a
   dark rail:
     .sidebar .nav-item .collapse .collapse-inner                     (0,4,0)
         -> min-width:10rem + a light elevation box-shadow
     .sidebar .nav-item .collapse .collapse-inner .collapse-item      (0,5,0)
         -> color:#3a3b45 (near-black) + white-space:nowrap
     ... .collapse-item:hover / :active / .active                    (0,6,0)
         -> background-color:#eaecf4 / #dddfeb (light grey) + color:#4e73df
   Left alone the labels are near-black on near-black and every hover flashes
   white. theme.css loads after sb-admin-2.min.css, so matching the full
   prefix (0,6,0) and winning on order is enough to take these over. */
.hms-sidebar .collapse {
    position: relative;
}

.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner,
.hms-sidebar.sidebar-dark .nav-item .collapsing .collapse-inner {
    position: relative;
    margin: 0 0 0 1.7rem;
    padding: 0.25rem 0.55rem 0.4rem;
    /* Explicit surface rather than `transparent`: an expanded branch has to read
       as part of the dark rail no matter what paints behind it. */
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    box-shadow: none;
    min-width: 0;
}

/* the rail the branch hangs from. 18px lines the rail up with the node: the
   panel's 1px border + 0.55rem padding pushes each item 9.8px in, and the node
   is 9px from the item edge, so 18px from the panel's padding box. */
.hms-sidebar .collapse .collapse-inner::before {
    content: "";
    position: absolute;
    left: 18px;
    top: -0.3rem;
    bottom: 0.85rem;
    width: 1px;
    background: linear-gradient(180deg, rgba(199, 203, 240, 0.3), rgba(199, 203, 240, 0.08));
}

.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner .collapse-item,
.hms-sidebar.sidebar-dark .nav-item .collapsing .collapse-inner .collapse-item {
    display: block;
    position: relative;
    margin: 0.05rem 0;
    padding: 0.48rem 0.8rem 0.48rem 1.95rem;
    border-radius: 7px;
    color: var(--hms-sidebar-text);
    font-size: 0.83rem;
    font-weight: 500;
    line-height: 1.3;
    text-decoration: none;
    white-space: normal;
    word-break: break-word;
    transition: background var(--hms-transition), color var(--hms-transition);
}

/* node sitting on the rail */
.hms-sidebar .collapse .collapse-item::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--hms-sidebar-bg);
    box-shadow: 0 0 0 1.5px rgba(199, 203, 240, 0.45);
    transition: background var(--hms-transition), box-shadow var(--hms-transition), transform var(--hms-transition);
}

.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner .collapse-item:hover,
.hms-sidebar.sidebar-dark .nav-item .collapsing .collapse-inner .collapse-item:hover {
    color: var(--hms-sidebar-text-strong);
    background: var(--hms-sidebar-hover);
}

.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner .collapse-item:active {
    color: var(--hms-sidebar-text-strong);
    background: rgba(255, 255, 255, 0.12);
}

.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner .collapse-item:focus-visible {
    outline: 2px solid var(--hms-primary);
    outline-offset: -2px;
    color: var(--hms-sidebar-text-strong);
}

.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner .collapse-item.hms-active,
.hms-sidebar.sidebar-dark .nav-item .collapsing .collapse-inner .collapse-item.hms-active {
    color: #fff;
    font-weight: 600;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.32), rgba(99, 102, 241, 0.08));
}

/* markActiveNav() sets `active` alongside `hms-active`; keep sb-admin's
   light-blue accent from repainting an item we already styled. */
.hms-sidebar.sidebar-dark .nav-item .collapse .collapse-inner .collapse-item.active {
    color: #fff;
    font-weight: 600;
}

.hms-sidebar .collapse .collapse-item.hms-active::before {
    background: var(--hms-sidebar-active);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
    transform: scale(1.15);
}

/* Keep the parent row lit while one of its children is the current page, so the
   branch you are inside never collapses back to an inert header. */
.hms-sidebar .nav-item:has(> .collapse .collapse-item.hms-active) > .nav-link {
    color: var(--hms-sidebar-text-strong);
    background: rgba(255, 255, 255, 0.06);
}

/* chevron + external-link affordances */
.hms-sidebar .hms-chevron {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.55;
    transition: transform var(--hms-transition), opacity var(--hms-transition);
}

.hms-sidebar .nav-link.hms-nav-trigger.collapsed .hms-chevron { transform: rotate(0deg); }
.hms-sidebar .nav-link.hms-nav-trigger:not(.collapsed) .hms-chevron { transform: rotate(90deg); opacity: 0.95; }

.hms-sidebar .nav-link.hms-nav-trigger.dropdown-toggle::after { display: none; }

/* sb-admin-2 draws its own collapse glyph via
     .sidebar-dark .nav-item .nav-link[data-toggle=collapse]::after { content:'\f107' }
   (and '\f105' when collapsed) at specificity (0,4,0). Every hms-nav-trigger
   also ships an explicit <i class="hms-chevron"> so it can rotate, so each row
   painted two chevrons - the ">>" in the sidebar. Suppress the vendor one.
   Needs the full .sidebar-dark .nav-item prefix to outrank it. */
.hms-sidebar.sidebar-dark .nav-item .nav-link[data-toggle="collapse"]::after { content: none; }

.hms-sidebar .hms-nav-ext {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 0.62rem;
    opacity: 0.5;
}

.hms-sidebar .nav-link:hover .hms-nav-ext { opacity: 0.95; }

/* toggle button parked at the sidebar foot */
#sidebarToggle {
    width: 34px;
    height: 34px;
    border: 1px solid var(--hms-sidebar-border);
    background: rgba(255, 255, 255, 0.06);
    position: relative;
}

#sidebarToggle::after {
    content: "\f100";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.72rem;
    color: var(--hms-sidebar-text);
}

#sidebarToggle:hover { background: rgba(255, 255, 255, 0.14); }
#sidebarToggle:focus { outline: none; box-shadow: 0 0 0 3px var(--hms-ring); }

/* desktop collapse of the whole rail */
body.sidebar-toggled .hms-sidebar { width: 0; min-width: 0; opacity: 0; }

/* =============================================================== topbar ==== */

.hms-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--hms-topbar-h);
    margin: 0 0 18px !important;
    padding: 0.65rem 1.35rem;
    background: var(--hms-surface);
    border-bottom: 1px solid var(--hms-border);
    box-shadow: none;
    transition: box-shadow var(--hms-transition), background var(--hms-transition);
}

.hms-topbar.hms-scrolled {
    box-shadow: var(--hms-shadow-sm);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: saturate(180%) blur(8px);
}

.hms-topbar-head {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.hms-topbar-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--hms-text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hms-topbar .navbar-nav {
    flex-direction: row;
    align-items: center;
}

.hms-topbar-actions { gap: 0.35rem; }

.hms-topbar .nav-link.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--hms-radius-sm);
    color: var(--hms-text-muted);
    transition: background var(--hms-transition), color var(--hms-transition);
}

.hms-topbar .nav-link.dropdown-toggle:hover {
    background: var(--hms-surface-sunken);
    color: var(--hms-primary);
}

.hms-topbar .nav-link.dropdown-toggle::after { display: none; }

.hms-topbar .dropdown-menu {
    min-width: 230px;
    padding: 0.4rem;
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
    box-shadow: var(--hms-shadow-lg);
    margin-top: 0.5rem;
}

.hms-topbar .dropdown-header {
    padding: 0.5rem 0.75rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
}

.hms-topbar .dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.75rem;
    border-radius: var(--hms-radius-sm);
    color: var(--hms-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--hms-transition), color var(--hms-transition);
}

.hms-topbar .dropdown-item:hover,
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background: var(--hms-primary-soft);
    color: var(--hms-primary-text);
}

.dropdown-item.active,
.dropdown-item:active {
    background: var(--hms-primary);
    color: #fff;
}

.hms-topbar .dropdown-divider,
.dropdown-divider {
    border-top: 1px solid var(--hms-border);
    margin: 0.35rem 0;
}

.hms-topbar .img-profile,
.hms-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--hms-border);
}

.hms-user-meta {
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    margin-right: 0.4rem;
}

.hms-user-name { font-size: 0.85rem; font-weight: 700; color: var(--hms-text); }
.hms-user-role {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
}

.hms-dropdown-user {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.75rem;
    gap: 0.15rem;
}

.hms-dropdown-user .hms-user-meta { align-items: flex-start; margin: 0; }

/* quick create ------------------------------------------------------------ */
.hms-create-btn {
    background: var(--hms-primary);
    color: #fff !important;
    padding: 0.45rem 0.7rem !important;
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.35);
}

.hms-create-btn:hover,
.hms-create-btn:focus {
    background: var(--hms-primary-hover);
    color: #fff !important;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.45);
}

/* table search ------------------------------------------------------------ */
.hms-topbar-search .input-group { width: 260px; }

.hms-search-input {
    height: 40px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    background: var(--hms-surface-alt);
    border: 1px solid var(--hms-border);
    border-left: 0;
    border-radius: 0 var(--hms-radius-sm) var(--hms-radius-sm) 0;
    color: var(--hms-text);
    transition: border-color var(--hms-transition), box-shadow var(--hms-transition), background var(--hms-transition);
}

.hms-search-input:focus {
    background: #fff;
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px var(--hms-ring);
    outline: none;
}

.hms-search-prepend {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 0.7rem;
    background: var(--hms-surface-alt);
    border: 1px solid var(--hms-border);
    border-right: 0;
    border-radius: var(--hms-radius-sm) 0 0 var(--hms-radius-sm);
    color: var(--hms-text-subtle);
}

.hms-search-field { position: relative; }

/* round ghost button (mobile toggle) */
.hms-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius-sm);
    background: var(--hms-surface);
    color: var(--hms-text-muted);
    cursor: pointer;
    transition: background var(--hms-transition), color var(--hms-transition), border-color var(--hms-transition);
}

.hms-icon-btn:hover,
.hms-icon-btn:focus-visible {
    background: var(--hms-primary-soft);
    color: var(--hms-primary);
    border-color: var(--hms-primary-border);
}

/* breadcrumb -------------------------------------------------------------- */
.hms-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    margin: 0.15rem 0 0;
    list-style: none;
    background: transparent;
    font-size: 0.78rem;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
    border-radius: 0;
}

.hms-breadcrumb .breadcrumb-item { color: var(--hms-text-subtle); }
.hms-breadcrumb .breadcrumb-item.active { color: var(--hms-text-muted); font-weight: 600; }

.breadcrumb-item + .breadcrumb-item::before,
.hms-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 0.4rem;
    color: var(--hms-text-subtle);
}

.breadcrumb-item.active { color: var(--hms-text-muted); }

/* =============================================================== footer ==== */

.hms-footer {
    margin-top: auto;
    background: var(--hms-surface) !important;
    border-top: 1px solid var(--hms-border);
    padding: 0.9rem 0;
    font-size: 0.8rem;
    color: var(--hms-text-muted);
}

.hms-footer .copyright {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.hms-footer .copyright a { color: var(--hms-primary); font-weight: 600; }

.sticky-footer { flex-shrink: 0; }

/* ================================================================ cards ==== */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--hms-surface);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
    box-shadow: var(--hms-shadow-xs);
    margin-bottom: 22px;
    transition: box-shadow var(--hms-transition), transform var(--hms-transition), border-color var(--hms-transition);
}

.card-header {
    padding: 1rem 1.25rem;
    background: var(--hms-surface);
    border-bottom: 1px solid var(--hms-border);
    border-radius: var(--hms-radius) var(--hms-radius) 0 0 !important;
}

.card-header:first-child {
    border-radius: var(--hms-radius) var(--hms-radius) 0 0;
}

.card-body { padding: 1.25rem; }
.card-footer {
    padding: 0.9rem 1.25rem;
    background: var(--hms-surface-alt);
    border-top: 1px solid var(--hms-border);
    border-radius: 0 0 var(--hms-radius) var(--hms-radius) !important;
}

.card .h5 { font-weight: 700; }

.card-header h5,
.card-header h6,
.card-header .h5,
.card-header .h6,
.card-header .m-0 {
    margin: 0;
    font-weight: 700;
    color: var(--hms-text);
}

.card-header .text-primary { color: var(--hms-primary) !important; }

/* legacy coloured left rails -> soft tinted card */
.card.border-left-primary,
.card.border-left-success,
.card.border-left-info,
.card.border-left-warning,
.card.border-left-danger,
.card.border-left-secondary {
    border-left: 4px solid var(--hms-primary) !important;
}

.card.border-left-success { border-left-color: var(--hms-success) !important; }
.card.border-left-info { border-left-color: var(--hms-info) !important; }
.card.border-left-warning { border-left-color: var(--hms-warning) !important; }
.card.border-left-danger { border-left-color: var(--hms-danger) !important; }
.card.border-left-secondary { border-left-color: var(--hms-text-subtle) !important; }

.card.border-left-primary:hover,
.card.border-left-success:hover,
.card.border-left-info:hover,
.card.border-left-warning:hover,
.card.border-left-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--hms-shadow);
}

/* legacy dashboard tiles --------------------------------------------------- */
.first-row > [class*="col-"] > .card {
    height: 100%;
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
}

.first-row .card .card-body { padding: 1.15rem 1.25rem; }

.first-row .card .h5,
.card .h5 {
    font-weight: 800;
    color: var(--hms-text);
    letter-spacing: -0.01em;
}

.first-row .card .text-uppercase,
.first-row .card .text-xs,
.card .text-uppercase.font-weight-bold,
.card .text-xs.font-weight-bold {
    font-size: 0.7rem;
    font-weight: 800 !important;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
}

.card .text-uppercase { color: var(--hms-text-subtle); }

.first-row .col-auto > i.fa-2x,
.first-row .col-auto > i.fas.fa-2x,
.first-row .col-auto > i.fa-2x.fa-fw {
    font-size: 1.6rem;
    opacity: 0.9;
}

.first-row .card.border-left-primary .col-auto > i.fa-2x { color: var(--hms-primary); }
.first-row .card.border-left-success .col-auto > i.fa-2x { color: var(--hms-success); }
.first-row .card.border-left-info .col-auto > i.fa-2x { color: var(--hms-info); }
.first-row .card.border-left-warning .col-auto > i.fa-2x { color: var(--hms-warning); }
.first-row .card.border-left-danger .col-auto > i.fa-2x { color: var(--hms-danger); }

/* ============================================================ stat cards ==== */

.hms-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 1.15rem 1.25rem;
    background: var(--hms-surface);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
    box-shadow: var(--hms-shadow-xs);
    transition: box-shadow var(--hms-transition), transform var(--hms-transition);
}

.hms-stat:hover { transform: translateY(-2px); box-shadow: var(--hms-shadow); }

.hms-stat--link { cursor: pointer; }

.hms-stat__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: var(--hms-radius);
    font-size: 1.3rem;
    background: var(--hms-primary-soft);
    color: var(--hms-primary);
}

.hms-stat__body { min-width: 0; flex: 1 1 auto; }

.hms-stat__label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
    margin-bottom: 0.15rem;
}

.hms-stat__value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--hms-text);
    letter-spacing: -0.02em;
}

.hms-stat__value a { color: inherit; }
.hms-stat__value a:hover { color: var(--hms-primary); }
.hms-stat__meta { font-size: 0.78rem; color: var(--hms-text-muted); margin-top: 0.15rem; }

.hms-stat--success .hms-stat__icon { background: var(--hms-success-soft); color: var(--hms-success-text); }
.hms-stat--info .hms-stat__icon { background: var(--hms-info-soft); color: var(--hms-info-text); }
.hms-stat--warning .hms-stat__icon { background: var(--hms-warning-soft); color: var(--hms-warning-text); }
.hms-stat--danger .hms-stat__icon { background: var(--hms-danger-soft); color: var(--hms-danger-text); }
.hms-stat--muted .hms-stat__icon { background: var(--hms-surface-sunken); color: var(--hms-text-muted); }

/* split metric card -------------------------------------------------------- */
.hms-split {
    height: 100%;
    padding: 1.15rem 1.25rem;
    background: var(--hms-surface);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
    box-shadow: var(--hms-shadow-xs);
}

.hms-split__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.hms-split__item {
    padding: 0.6rem 0.75rem;
    background: var(--hms-surface-alt);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius-sm);
}

.hms-split__item--end { text-align: right; }

.hms-split__label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
}

.hms-split__title { font-size: 0.85rem; font-weight: 700; color: var(--hms-text); }
.hms-split__value { font-size: 1.35rem; font-weight: 800; color: var(--hms-text); }
.hms-split__value a { color: inherit; }
.hms-split__value a:hover { color: var(--hms-primary); }

.hms-split--success .hms-split__item { background: var(--hms-success-soft); border-color: transparent; }
.hms-split--info .hms-split__item { background: var(--hms-info-soft); border-color: transparent; }

/* page heading ------------------------------------------------------------- */
.hms-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.25rem 0 1.25rem;
}

.hms-page-head__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hms-page-head__actions > * + * { margin-left: 0.15rem; }

.hms-page-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--hms-text);
}

.hms-page-sub { margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--hms-text-muted); }

.hms-kicker {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--hms-primary);
}

/* live dot ---------------------------------------------------------------- */
.hms-live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hms-success);
    box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5);
    animation: hms-pulse-soft 2s infinite;
}

/* ============================================================= buttons ==== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-family: var(--hms-font);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    border: 1px solid transparent;
    border-radius: var(--hms-radius-sm);
    cursor: pointer;
    transition: background var(--hms-transition), color var(--hms-transition), border-color var(--hms-transition), box-shadow var(--hms-transition), transform var(--hms-transition);
}

.btn i, .btn .fas, .btn .far, .btn .fa { font-size: 0.9em; }

.btn:active { transform: translateY(1px); }

.btn:focus,
.btn:focus-visible,
.btn.focus,
.btn:active:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--hms-ring);
}

.btn-primary {
    background: var(--hms-primary);
    border-color: var(--hms-primary);
    color: #fff;
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: var(--hms-primary-hover);
    border-color: var(--hms-primary-hover);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: var(--hms-border-strong);
    color: var(--hms-text);
}

.btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active {
    background: var(--hms-surface-sunken);
    border-color: var(--hms-border-strong);
    color: var(--hms-text);
}

.btn-success { background: var(--hms-success); border-color: var(--hms-success); color: #fff; }
.btn-success:hover, .btn-success:focus, .btn-success:active { background: #047857; border-color: #047857; color: #fff; }

.btn-danger { background: var(--hms-danger); border-color: var(--hms-danger); color: #fff; }
.btn-danger:hover, .btn-danger:focus, .btn-danger:active { background: var(--hms-danger-hover); border-color: var(--hms-danger-hover); color: #fff; }

.btn-warning { background: var(--hms-warning); border-color: var(--hms-warning); color: #fff; }
.btn-warning:hover, .btn-warning:focus, .btn-warning:active { background: var(--hms-warning-text); border-color: var(--hms-warning-text); color: #fff; }

.btn-info { background: var(--hms-info); border-color: var(--hms-info); color: #fff; }
.btn-info:hover, .btn-info:focus, .btn-info:active { background: #0284c7; border-color: #0284c7; color: #fff; }

.btn-dark { background: var(--hms-text); border-color: var(--hms-text); color: #fff; }
.btn-dark:hover, .btn-dark:focus { background: #11131f; border-color: #11131f; color: #fff; }

.btn-light { background: var(--hms-surface-alt); border-color: var(--hms-border); color: var(--hms-text); }
.btn-light:hover, .btn-light:focus { background: var(--hms-surface-sunken); color: var(--hms-text); }

.btn-outline-primary { background: transparent; border-color: var(--hms-primary-border); color: var(--hms-primary-text); }
.btn-outline-primary:hover, .btn-outline-primary:focus { background: var(--hms-primary); border-color: var(--hms-primary); color: #fff; }

.btn-outline-secondary { background: transparent; border-color: var(--hms-border-strong); color: var(--hms-text-muted); }
.btn-outline-secondary:hover, .btn-outline-secondary:focus { background: var(--hms-surface-sunken); border-color: var(--hms-border-strong); color: var(--hms-text); }

.btn-outline-success { background: transparent; border-color: #6ee7b7; color: var(--hms-success-text); }
.btn-outline-success:hover { background: var(--hms-success); border-color: var(--hms-success); color: #fff; }

.btn-outline-danger { background: transparent; border-color: #fca5a5; color: var(--hms-danger-text); }
.btn-outline-danger:hover { background: var(--hms-danger); border-color: var(--hms-danger); color: #fff; }

.btn-link { background: transparent; border-color: transparent; color: var(--hms-primary); box-shadow: none; }
.btn-link:hover { color: var(--hms-primary-hover); text-decoration: underline; background: transparent; }

.btn-sm, .btn-block-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 0.95rem; }

.btn-block { display: flex; width: 100%; }

.btn.disabled, .btn:disabled, fieldset:disabled .btn {
    opacity: 0.6;
    pointer-events: none;
    box-shadow: none;
}

.btn-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

.btn-circle.btn-sm { width: 32px; height: 32px; }

.btn-user {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--hms-radius-pill);
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    border: 1px solid var(--hms-border);
    background: #fff;
    color: var(--hms-text);
}

.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-radius: var(--hms-radius-sm) 0 0 var(--hms-radius-sm); }
.btn-group > .btn:last-child { border-radius: 0 var(--hms-radius-sm) var(--hms-radius-sm) 0; }

/* loading spinner ---------------------------------------------------------- */
.hms-btn-loading { position: relative; color: transparent !important; pointer-events: none; }

.hms-btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hms-spin 0.6s linear infinite;
}

.btn-secondary.hms-btn-loading::after,
.btn-light.hms-btn-loading::after,
.btn-outline-secondary.hms-btn-loading::after {
    border-color: rgba(30, 33, 48, 0.25);
    border-top-color: var(--hms-text);
}

.hms-btn-spinner { display: inline-flex; }
.hms-btn-spinner::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: hms-spin 0.6s linear infinite;
}

/* =============================================================== forms ==== */

label, .form-label, .col-form-label, .custom-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--hms-text-muted);
    margin-bottom: 0.35rem;
}

.form-group { margin-bottom: 1.1rem; }

.form-control, .custom-select {
    height: auto;
    min-height: 42px;
    padding: 0.5rem 0.85rem;
    font-family: var(--hms-font);
    font-size: 0.875rem;
    color: var(--hms-text);
    background-color: #fff;
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm);
    transition: border-color var(--hms-transition), box-shadow var(--hms-transition), background var(--hms-transition);
}

.form-control::placeholder { color: var(--hms-text-subtle); opacity: 1; }

.form-control:hover:not(:disabled):not(:focus),
.custom-select:hover:not(:disabled):not(:focus) {
    border-color: #b9c1d2;
}

.form-control:focus, .custom-select:focus {
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px var(--hms-ring);
    outline: none;
    background: #fff;
}

.form-control-sm, .custom-select-sm { min-height: 34px; padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.form-control-lg, .custom-select-lg { min-height: 50px; padding: 0.7rem 1rem; font-size: 0.95rem; }

.form-control:disabled, .custom-select:disabled, .form-control[readonly] {
    background: var(--hms-surface-sunken);
    color: var(--hms-text-muted);
    opacity: 1;
}

textarea.form-control { min-height: 96px; }

.form-control.is-invalid, .custom-select.is-invalid,
.was-validated .form-control:invalid, .was-validated .custom-select:invalid {
    border-color: var(--hms-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22); }

.form-control.is-valid, .custom-select.is-valid { border-color: var(--hms-success); }

.form-text, .hms-form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--hms-text-muted);
}

.invalid-feedback, .hms-form-error {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--hms-danger-text);
}

.valid-feedback { color: var(--hms-success-text); font-size: 0.78rem; }

.hms-required::after {
    content: " *";
    color: var(--hms-danger);
    font-weight: 700;
}

/* input groups ------------------------------------------------------------- */
.input-group-text {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    color: var(--hms-text-muted);
    background: var(--hms-surface-alt);
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm);
}

.input-group > .form-control:not(:first-child),
.input-group > .custom-select:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

.input-group > .form-control:not(:last-child),
.input-group > .custom-select:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.input-group > .form-control:focus, .input-group > .custom-select:focus { z-index: 3; }

.input-group-append .btn, .input-group-prepend .btn {
    display: inline-flex;
    align-items: center;
    border-radius: var(--hms-radius-sm);
    border-color: var(--hms-border-strong);
}

.hms-field .form-control,
.hms-field .custom-select { border-radius: var(--hms-radius-sm); }

.hms-field .input-group > .form-control:first-child { border-radius: var(--hms-radius-sm) 0 0 var(--hms-radius-sm); }
.hms-field .input-group > .form-control:last-child { border-radius: 0 var(--hms-radius-sm) var(--hms-radius-sm) 0; }

.hms-field .input-group-prepend .input-group-text {
    border-right: 0;
    border-radius: var(--hms-radius-sm) 0 0 var(--hms-radius-sm);
    color: var(--hms-text-subtle);
}

.hms-field .input-group-append .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.hms-field .input-group-append .btn:hover,
.hms-field .input-group-append .btn:focus {
    background: var(--hms-primary);
    border-color: var(--hms-primary);
    color: #fff;
}

/* switch + checkbox -------------------------------------------------------- */
.custom-control-label { font-size: 0.85rem; font-weight: 600; color: var(--hms-text); }

.custom-control-label::before {
    border: 1px solid var(--hms-border-strong);
    background: #fff;
}

.custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--hms-primary);
    border-color: var(--hms-primary);
}

.custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: 0 0 0 3px var(--hms-ring);
}

.form-switch .custom-control-label::before { background: #cbd5e1; border-color: transparent; }
.form-switch .custom-control-input:checked ~ .custom-control-label::before { background: var(--hms-primary); }

.custom-checkbox.small .custom-control-label { font-size: 0.78rem; }

/* select2 ------------------------------------------------------------------ */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    min-height: 42px;
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm);
    background: #fff;
    transition: border-color var(--hms-transition), box-shadow var(--hms-transition);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
    padding-left: 0.85rem;
    color: var(--hms-text);
    font-size: 0.875rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; right: 6px; }

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px var(--hms-ring);
}

.select2-dropdown {
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius-sm);
    box-shadow: var(--hms-shadow-lg);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm);
    padding: 0.4rem 0.6rem;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--hms-primary);
    color: #fff;
}

/* gijgo datepicker --------------------------------------------------------- */
.gijgo-calendar .calendar-header,
.gijgo-calendar .calendar-body { font-family: var(--hms-font); }

.gijgo-calendar .calendar-header {
    background: var(--hms-primary);
    color: #fff;
    border-radius: var(--hms-radius-sm) var(--hms-radius-sm) 0 0;
}

.gijgo-calendar .calendar-table td.selected span { background: var(--hms-primary); }
.gijgo-calendar .calendar-table td.today span { border-color: var(--hms-primary); color: var(--hms-primary); }

/* =============================================================== tables ==== */

.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--hms-text);
    border-collapse: separate;
    border-spacing: 0;
}

.table > thead > tr > th,
.table > tbody > tr > td {
    padding: 0.8rem 0.9rem;
    vertical-align: middle;
    border-color: var(--hms-border);
}

.table > thead > tr > th {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
    background: var(--hms-surface-alt);
    border-bottom: 1px solid var(--hms-border);
    white-space: nowrap;
}

/* several detail tables emit <th> without wrapping them in <thead>, which left
   those header cells completely unstyled - style them the same way */
.table > tbody > tr > th,
.table > tr > th {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
    background: var(--hms-surface-alt);
    border-bottom: 1px solid var(--hms-border);
    white-space: nowrap;
    text-align: left;
}
.table > tbody > tr > th { padding: 0.55rem 0.9rem; }

.table > thead > tr > th:first-child,
.table > tbody > tr > td:first-child { padding-left: 1.1rem; }
.table > thead > tr > th:last-child,
.table > tbody > tr > td:last-child { padding-right: 1.1rem; }

.table > tbody > tr > td {
    font-size: 0.85rem;
    border-bottom: 1px solid var(--hms-border);
}

.table > tbody > tr:first-child > td { border-top: 0; }

.table-striped tbody tr:nth-of-type(odd) > td { background: var(--hms-surface-alt); }
.table-striped tbody tr:nth-of-type(even) > td { background: var(--hms-surface); }

.table-hover tbody tr:hover > td,
.table-striped tbody tr:hover > td {
    background: var(--hms-primary-soft);
}

.table-bordered { border: 1px solid var(--hms-border); }
.table-bordered thead th,
.table-bordered tbody td,
.table-bordered tfoot th,
.table-bordered tfoot td { border-color: var(--hms-border); }
.table-bordered thead th:first-child,
.table-bordered tbody td:first-child { border-left: 0; }

/* bordered + separate collapse gives doubled lines; collapse and let the
   cell borders do the drawing so the grid reads as one clean surface */
.table-bordered { border-collapse: collapse !important; }
.table-bordered > thead > tr > th:first-child,
.table-bordered > tbody > tr > td:first-child { border-left: 0; }

.table-sm td, .table-sm th { padding: 0.45rem 0.6rem; }

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

.table-thead-scroll { overflow-x: auto; }

/* ------------------------------------------------- datatables chrome ------ */
/* every listing page in the app is a DataTable, so its controls are themed
   here once instead of per page.

   dataTables.bootstrap4.js renders this exact shape:
     .dataTables_wrapper.dt-bootstrap4
       > .row > .col-sm-12.col-md-6   length select
       > .row > .col-sm-12.col-md-6   search box
       > .row > .col-sm-12             the table
       > .row > .col-sm-12.col-md-5   info
       > .row > .col-sm-12.col-md-7   <ul.pagination>
   It leans on Bootstrap's grid - negative .row margins, .col padding, and a
   .pagination with no auto margin - which left the controls hanging past the
   card body padding and the pagination pinned left with a dead gap on the
   right. Rebuilt on flex so both edges line up with the table.

   NOTE: `no-footer` is not an error. Core only adds that class when a table has
   no <tfoot>, and none of these listing tables have one. */

/* position:relative so the processing overlay below cannot escape the table */
.dataTables_wrapper.dt-bootstrap4 { position: relative; padding: 25px; }

/* The listing blades used to wrap #dataTable in Bootstrap's .table-responsive
   (overflow-x:auto). DataTables wraps the table itself, so that div ended up
   enclosing the whole chrome - toolbar and pagination were trapped inside a
   horizontal scroll box, which is what made the controls look glued and
   stop short of the card edge. The wrapper div is now .hms-table-host: a plain
   block that clips nothing, and the table's own column does the scrolling. */
.hms-table-host { margin: 0; }

.dataTables_wrapper.dt-bootstrap4 > .row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem 1rem;
    margin: 0 0 1rem;
}
.dataTables_wrapper.dt-bootstrap4 > .row:last-child { margin: 0.95rem 0 0; }

/* kill the grid gutter so the chrome lines up with the card body edge */
.dataTables_wrapper.dt-bootstrap4 > .row > [class*="col-"] { padding: 0; }

/* toolbar row: length select left, search box right */
.dataTables_wrapper.dt-bootstrap4 > .row:first-child > .col-sm-12 {
    flex: 1 1 0;
    min-width: 0;
}
.dataTables_wrapper.dt-bootstrap4 > .row:first-child > .col-sm-12:last-child { text-align: right; }

/* table row takes full width and may shrink; it is the only part that scrolls,
   so a wide table no longer drags the toolbar and pagination with it */
.dataTables_wrapper.dt-bootstrap4 > .row > .col-sm-12:not([class*="col-md-"]) {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* footer row: info left, pagination right */
.dataTables_wrapper.dt-bootstrap4 > .row:last-child > .col-sm-12.col-md-5 { flex: 0 0 auto; }
.dataTables_wrapper.dt-bootstrap4 > .row:last-child > .col-sm-12.col-md-7 {
    flex: 0 0 auto;
    margin-left: auto;
}

/* DataTables wraps each control in a <label>. Left as inline-block the label
   shrink-wraps, so `width:100%` on the input resolves against the label's own
   content width instead of the .dataTables_filter box - which capped the search
   box at ~180px once the toolbar stacked. inline-flex keeps the label
   shrink-wrapped on wide screens (so the col's text-align:right can push it to
   the trailing edge) while still giving the input a real flex parent to grow
   into on narrow ones. */
.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    color: var(--hms-text-subtle);
    font-weight: 600;
}

.dataTables_filter input[type="search"],
.dataTables_filter input[type="text"] {
    min-width: 15rem;
    max-width: 100%;
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--hms-text);
    background: var(--hms-surface);
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-pill);
    box-shadow: none;
    transition: border-color var(--hms-transition), box-shadow var(--hms-transition);
}
.dataTables_filter input:focus {
    outline: 0;
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px var(--hms-ring);
}
.dataTables_filter input::placeholder { color: var(--hms-text-subtle); }

.dataTables_length select {
    padding: 0.45rem 1.9rem 0.45rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--hms-text-muted);
    background-color: var(--hms-surface);
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}
.dataTables_length select:focus {
    outline: 0;
    border-color: var(--hms-primary);
    box-shadow: 0 0 0 3px var(--hms-ring);
}

.dataTables_info {
    padding-top: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--hms-text-muted);
}

/* Bootstrap's .pagination has no auto margin, so under a col it hugged the
   left and left a void on the right - push it to the trailing edge. */
.dataTables_wrapper .pagination { margin: 0 0 0 auto; }
.dataTables_wrapper .pagination .page-item { margin: 0 0.15rem; }
.dataTables_wrapper .pagination .page-item .page-link {
    min-width: 2.15rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: var(--hms-text-muted);
    background: var(--hms-surface);
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm) !important;
    box-shadow: none;
    transition: background var(--hms-transition), color var(--hms-transition),
                border-color var(--hms-transition);
}
.dataTables_wrapper .pagination .page-item:first-child .page-link { border-radius: var(--hms-radius-sm) 0 0 var(--hms-radius-sm); }
.dataTables_wrapper .pagination .page-item:last-child .page-link { border-radius: 0 var(--hms-radius-sm) var(--hms-radius-sm) 0; }
.dataTables_wrapper .pagination .page-item .page-link:hover {
    color: var(--hms-primary);
    background: var(--hms-primary-soft);
    border-color: var(--hms-primary-border);
}
.dataTables_wrapper .pagination .page-item.active .page-link {
    color: #fff;
    background: var(--hms-primary);
    border-color: var(--hms-primary);
}
.dataTables_wrapper .pagination .page-item.disabled .page-link {
    color: var(--hms-text-subtle);
    background: var(--hms-surface-alt);
    border-color: var(--hms-border);
}

/* export/print buttons rendered by Buttons extension */
.dataTables_wrapper .dt-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dataTables_wrapper .dt-buttons .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--hms-radius-sm);
}

/* loading overlay. DataTables tags this element `dataTables_processing card`,
   so .card's own border/background have to be reset, otherwise the spinner
   renders as a white bordered card floating over the rows. */
.dataTables_processing,
.dataTables_processing.card {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    background: rgba(255, 255, 255, 0.75);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: blur(1px);
}
.dataTables_processing::after {
    content: "";
    width: 1.8rem;
    height: 1.8rem;
    border: 2px solid var(--hms-primary-border);
    border-top-color: var(--hms-primary);
    border-radius: 50%;
    animation: hms-table-spin 0.7s linear infinite;
}
@keyframes hms-table-spin { to { transform: rotate(360deg); } }

.dataTables_wrapper td.dataTables_empty,
.dataTables_wrapper th.dataTables_empty,
table.dataTable tbody tr td.dataTables_empty {
    padding: 2.4rem 1rem !important;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--hms-text-subtle);
    background: var(--hms-surface-alt);
    border-bottom: 0;
}

table.dataTable thead th { box-shadow: inset 0 -1px 0 var(--hms-border); }
table.dataTable.no-footer { border-bottom: 0; }

/* column ordering / sorting affordances */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc { cursor: pointer; user-select: none; }
table.dataTable thead th.sorting:hover,
table.dataTable thead th.sorting_asc:hover,
table.dataTable thead th.sorting_desc:hover {
    color: var(--hms-primary);
    background: var(--hms-primary-soft);
}

/* keep header readable when a long table scrolls vertically */
.hms-table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

@media (max-width: 767.98px) {
    .dataTables_wrapper.dt-bootstrap4 > .row:first-child,
    .dataTables_wrapper.dt-bootstrap4 > .row:last-child {
        flex-direction: column;
        align-items: stretch;
    }
    .dataTables_wrapper.dt-bootstrap4 > .row:first-child > .col-sm-12:last-child { text-align: left; }
    .dataTables_wrapper.dt-bootstrap4 > .row:last-child > .col-sm-12.col-md-7 { margin-left: 0; }
    .dataTables_wrapper .dataTables_filter label { width: 100%; }
    .dataTables_filter input[type="search"],
    .dataTables_filter input[type="text"] {
        min-width: 0;
        width: auto;
        flex: 1 1 auto;
    }
    .dataTables_wrapper .pagination { margin: 0; justify-content: center; }
}

/* ------------------------------------------------------- patient id card --- */
/* dual-sided print card: one physical card, two printable faces */

.hms-idcard-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: center;
}

.hms-idcard {
    position: relative;
    width: 100%;
    max-width: 30rem;
    background: var(--hms-surface);
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-lg);
    box-shadow: var(--hms-shadow);
    overflow: hidden;
}

.hms-idcard__band {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.15rem;
    background: linear-gradient(135deg, var(--hms-sidebar-bg), var(--hms-sidebar-bg-2));
    color: #fff;
}
.hms-idcard__band .hms-idcard__kicker {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.68);
}
.hms-idcard__band .hms-idcard__name {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
}

.hms-idcard__photo {
    flex: 0 0 auto;
    width: 3.5rem;
    height: 3.5rem;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: var(--hms-surface-sunken);
}
.hms-idcard__photo--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.85);
}

.hms-idcard__no {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-radius: var(--hms-radius-pill);
    white-space: nowrap;
}

.hms-idcard__body { padding: 0.4rem 0; }

.hms-idcard__row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.5rem 1.15rem;
}
.hms-idcard__row + .hms-idcard__row { border-top: 1px solid var(--hms-border); }

.hms-idcard__label {
    flex: 0 0 7.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
}
.hms-idcard__value {
    flex: 1 1 auto;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--hms-text);
    word-break: break-word;
}
.hms-idcard__value--muted { color: var(--hms-text-subtle); font-weight: 500; }

.hms-idcard__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.7rem 1.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--hms-text-subtle);
    background: var(--hms-surface-alt);
    border-top: 1px solid var(--hms-border);
}

/* the side meant for the hospital's own printed wording */
.hms-idcard__blank {
    padding: 1.4rem 1.15rem;
    text-align: center;
}
.hms-idcard__blank > div { margin-bottom: 0.35rem; }

@media (max-width: 575.98px) {
    .hms-idcard { max-width: 100%; }
    .hms-idcard__row { flex-direction: column; gap: 0.15rem; }
    .hms-idcard__label { flex: 0 0 auto; }
}

@media print {
    .hms-idcard-wrap { display: block; }
    .hms-idcard {
        max-width: none;
        box-shadow: none;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .hms-idcard + .hms-idcard { margin-top: 1rem; }
}

/* sortable headers --------------------------------------------------------- */
.table thead th.sorting,
.table thead th.sorting_asc,
.table thead th.sorting_desc {
    cursor: pointer;
    position: relative;
    padding-right: 1.5rem;
}

.table thead th.sorting::after,
.table thead th.sorting_asc::after,
.table thead th.sorting_desc::after {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.6rem;
    color: var(--hms-text-subtle);
}
.table thead th.sorting::after { content: "\f0dc"; opacity: 0.45; }
.table thead th.sorting_asc::after { content: "\f0de"; color: var(--hms-primary); }
.table thead th.sorting_desc::after { content: "\f0dd"; color: var(--hms-primary); }

/* record links ------------------------------------------------------------- */
.table tbody td > a:not(.btn) {
    font-weight: 600;
    color: var(--hms-primary-text);
}
.table tbody td > a:not(.btn):hover { color: var(--hms-primary-hover); text-decoration: underline; }

/* empty state row ---------------------------------------------------------- */
.hms-empty-cell { text-align: center; padding: 2.5rem 1rem !important; color: var(--hms-text-muted); }
.hms-empty-cell i { display: block; font-size: 1.6rem; color: var(--hms-border-strong); margin-bottom: 0.5rem; }
.hms-empty-cell span { font-size: 0.85rem; }

.hms-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2.75rem 1.25rem;
    text-align: center;
    color: var(--hms-text-muted);
}

.hms-empty i { font-size: 1.9rem; color: var(--hms-border-strong); }

/* DataTables chrome is themed once in the tables section above. An older
   duplicate used to live here and, sitting later in the file, silently won the
   cascade: it flattened the search box to a square input and its `background`
   shorthand reset the select's arrow to `initial`, and it re-added the
   per-control margins that the flex wrapper now handles. Removed deliberately. */

/* =============================================================== alerts ==== */

.alert {
    position: relative;
    padding: 0.9rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--hms-radius-sm);
    font-size: 0.86rem;
}

.alert ul { margin: 0; padding-left: 1.1rem; }
.alert ul li + li { margin-top: 0.2rem; }
.alert a { font-weight: 700; text-decoration: underline; }

.alert-primary { background: var(--hms-primary-soft); border-color: var(--hms-primary-border); color: var(--hms-primary-text); }
.alert-success { background: var(--hms-success-soft); border-color: #a7f3d0; color: var(--hms-success-text); }
.alert-info { background: var(--hms-info-soft); border-color: #bae6fd; color: var(--hms-info-text); }
.alert-warning { background: var(--hms-warning-soft); border-color: #fde68a; color: var(--hms-warning-text); }
.alert-danger { background: var(--hms-danger-soft); border-color: #fecaca; color: var(--hms-danger-text); }

.hms-flash { margin-bottom: 1rem; }
.hms-flash-dismissible { position: relative; }

/* bootstrap-notify --------------------------------------------------------- */
.notifications { position: fixed; z-index: 9999; }

.notifications .notification[data-notify="container"] {
    padding: 0.85rem 1.1rem;
    border-radius: var(--hms-radius-sm);
    border: 1px solid transparent;
    box-shadow: var(--hms-shadow-lg);
    font-size: 0.86rem;
    background: #fff;
    animation: hms-notify-in 0.35s ease;
}

.notifications .notification .close { color: inherit; opacity: 0.6; }
.notifications .notification .close:hover { opacity: 1; }
.notifications .notification .notification-message { font-weight: 600; }

.notifications .notification[data-type="success"] { background: var(--hms-success); color: #fff; }
.notifications .notification[data-type="danger"] { background: var(--hms-danger); color: #fff; }
.notifications .notification[data-type="warning"] { background: var(--hms-warning); color: #fff; }
.notifications .notification[data-type="info"] { background: var(--hms-info); color: #fff; }

/* =============================================================== badges ==== */

.badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    border-radius: var(--hms-radius-pill);
    letter-spacing: 0.01em;
}

.badge-primary { background: var(--hms-primary-soft); color: var(--hms-primary-text); }
.badge-success { background: var(--hms-success-soft); color: var(--hms-success-text); }
.badge-info { background: var(--hms-info-soft); color: var(--hms-info-text); }
.badge-warning { background: var(--hms-warning-soft); color: var(--hms-warning-text); }
.badge-danger { background: var(--hms-danger-soft); color: var(--hms-danger-text); }
.badge-secondary { background: var(--hms-surface-sunken); color: var(--hms-text-muted); }

/* solid variants for lists */
.bg-primary { background: var(--hms-primary) !important; }
.bg-success { background: var(--hms-success) !important; }
.bg-info { background: var(--hms-info) !important; }
.bg-warning { background: var(--hms-warning) !important; }
.bg-danger { background: var(--hms-danger) !important; }

.pill { border-radius: var(--hms-radius-pill); }

/* =============================================================== modals ==== */

.modal-backdrop.show { opacity: 0.5; background: #0f172a; }

.modal-content {
    border: 0;
    border-radius: var(--hms-radius-lg);
    box-shadow: var(--hms-shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 1.05rem 1.35rem;
    background: var(--hms-surface);
    border-bottom: 1px solid var(--hms-border);
}

.modal-title { font-size: 1.05rem; font-weight: 800; color: var(--hms-text); }

.modal-body { padding: 1.35rem; font-size: 0.88rem; }

.modal-footer {
    padding: 0.9rem 1.35rem;
    background: var(--hms-surface-alt);
    border-top: 1px solid var(--hms-border);
    gap: 0.5rem;
}

.modal-footer .btn { min-width: 88px; }

.modal-dialog { margin: 1.75rem auto; }

.close {
    font-size: 1.4rem;
    font-weight: 400;
    line-height: 1;
    color: var(--hms-text-subtle);
    opacity: 0.8;
    text-shadow: none;
    transition: color var(--hms-transition), opacity var(--hms-transition);
}

.close:hover { color: var(--hms-danger); opacity: 1; }

/* ================================================================ navs ==== */

.nav-tabs { border-bottom: 1px solid var(--hms-border); gap: 0.15rem; }

.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hms-text-muted);
    transition: color var(--hms-transition), border-color var(--hms-transition);
}

.nav-tabs .nav-link:hover { color: var(--hms-primary); border-bottom-color: var(--hms-primary-border); }

.nav-tabs .nav-link.active {
    color: var(--hms-primary);
    border-bottom-color: var(--hms-primary);
    background: transparent;
}

.card-header-tabs { margin: -0.4rem -0.5rem; }
.card-header-tabs .nav-item .nav-link { border: 0; border-radius: var(--hms-radius-sm); }
.card-header-tabs .nav-item .nav-link.active { background: var(--hms-primary-soft); color: var(--hms-primary-text); }

.card-header-pills .nav-link { border-radius: var(--hms-radius-sm); }

.accordion > .card { overflow: hidden; margin-bottom: 0.5rem; }
.accordion > .card > .card-header { border-bottom: 1px solid var(--hms-border); padding: 0.6rem 1rem; }
.accordion > .card > .card-header button { font-weight: 700; color: var(--hms-text); }

/* ============================================================ pagination ==== */

.pagination { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0; }

.page-item .page-link {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--hms-text-muted);
    background: #fff;
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm) !important;
    transition: background var(--hms-transition), color var(--hms-transition), border-color var(--hms-transition);
}

.page-item .page-link:hover { background: var(--hms-primary-soft); color: var(--hms-primary-text); border-color: var(--hms-primary-border); }
.page-item.active .page-link { background: var(--hms-primary); border-color: var(--hms-primary); color: #fff; }
.page-item.disabled .page-link { opacity: 0.55; pointer-events: none; }

.card-footer .pagination { justify-content: flex-end; }

/* ============================================================== widgets ==== */

/* scroll to top ------------------------------------------------------------ */
.scroll-to-top {
    position: fixed;
    right: 1.35rem;
    bottom: 1.35rem;
    z-index: 1040;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--hms-radius-sm);
    background: var(--hms-primary);
    color: #fff !important;
    box-shadow: var(--hms-shadow);
    transition: background var(--hms-transition), transform var(--hms-transition), opacity var(--hms-transition);
}

.scroll-to-top.hms-visible { display: flex; }
.scroll-to-top:hover { background: var(--hms-primary-hover); transform: translateY(-2px); }

/* ajax progress bar -------------------------------------------------------- */
.hms-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--hms-transition);
}

.hms-progress span {
    display: block;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, var(--hms-primary), #818cf8);
    border-radius: 0 3px 3px 0;
}

.hms-progress.is-active { opacity: 1; }
.hms-progress.is-active span { animation: hms-progress-slide 1.1s ease-in-out infinite; }

/* tooltip / popover -------------------------------------------------------- */
.tooltip-inner {
    background: var(--hms-text);
    border-radius: var(--hms-radius-sm);
    font-size: 0.76rem;
    padding: 0.35rem 0.6rem;
}

.bs-tooltip-top .arrow::before { border-top-color: var(--hms-text); }
.bs-tooltip-bottom .arrow::before { border-bottom-color: var(--hms-text); }
.bs-tooltip-left .arrow::before { border-left-color: var(--hms-text); }
.bs-tooltip-right .arrow::before { border-right-color: var(--hms-text); }

.popover {
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
    box-shadow: var(--hms-shadow-lg);
    font-family: var(--hms-font);
}

.popover-header {
    background: var(--hms-surface-alt);
    border-bottom: 1px solid var(--hms-border);
    font-weight: 700;
    border-radius: var(--hms-radius) var(--hms-radius) 0 0;
}

/* list group / progress ---------------------------------------------------- */
.list-group-item {
    padding: 0.8rem 1rem;
    border: 1px solid var(--hms-border);
    color: var(--hms-text);
}

.list-group-item:first-child { border-radius: var(--hms-radius) var(--hms-radius) 0 0; }
.list-group-item:last-child { border-radius: 0 0 var(--hms-radius) var(--hms-radius); }
.list-group-item.active { background: var(--hms-primary); border-color: var(--hms-primary); color: #fff; }

.progress {
    height: 8px;
    background: var(--hms-surface-sunken);
    border-radius: var(--hms-radius-pill);
    overflow: hidden;
}

.progress-bar { background: var(--hms-primary); }
.progress-bar.bg-success { background: var(--hms-success) !important; }
.progress-bar.bg-warning { background: var(--hms-warning) !important; }
.progress-bar.bg-danger { background: var(--hms-danger) !important; }

/* text + rail utilities ---------------------------------------------------- */
.text-primary { color: var(--hms-primary) !important; }
.text-success { color: var(--hms-success) !important; }
.text-info { color: var(--hms-info) !important; }
.text-warning { color: var(--hms-warning) !important; }
.text-danger { color: var(--hms-danger) !important; }
.text-teal { color: var(--hms-teal) !important; }

.text-gray-300 { color: #cbd5e1 !important; }
.text-gray-400 { color: var(--hms-text-subtle) !important; }
.text-gray-500 { color: var(--hms-text-muted) !important; }
.text-gray-600 { color: #475569 !important; }
.text-gray-700 { color: #334155 !important; }
.text-gray-800 { color: var(--hms-text) !important; }

.border-primary { border-color: var(--hms-primary) !important; }
.border-success { border-color: var(--hms-success) !important; }
.border-info { border-color: var(--hms-info) !important; }
.border-warning { border-color: var(--hms-warning) !important; }
.border-danger { border-color: var(--hms-danger) !important; }

/* token utility classes (kept for compatibility) --------------------------- */
.hms-canvas { background: var(--hms-canvas) !important; }
.hms-surface { background: var(--hms-surface) !important; }
.hms-surface-alt { background: var(--hms-surface-alt) !important; }
.hms-text { color: var(--hms-text) !important; }
.hms-text-muted { color: var(--hms-text-muted) !important; }
.hms-text-subtle { color: var(--hms-text-subtle) !important; }
.hms-border { border-color: var(--hms-border) !important; }
.hms-border-strong { border-color: var(--hms-border-strong) !important; }
.hms-primary { color: var(--hms-primary) !important; }
.hms-primary-hover { color: var(--hms-primary-hover) !important; }
.hms-primary-active { color: var(--hms-primary-active) !important; }
.hms-primary-border { border-color: var(--hms-primary-border) !important; }
.hms-primary-soft { background: var(--hms-primary-soft) !important; }

.hms-success { color: var(--hms-success) !important; }
.hms-success-soft { background: var(--hms-success-soft) !important; }
.hms-success-text { color: var(--hms-success-text) !important; }
.hms-info { color: var(--hms-info) !important; }
.hms-info-soft { background: var(--hms-info-soft) !important; }
.hms-info-text { color: var(--hms-info-text) !important; }
.hms-warning { color: var(--hms-warning) !important; }
.hms-warning-soft { background: var(--hms-warning-soft) !important; }
.hms-warning-text { color: var(--hms-warning-text) !important; }
.hms-danger { color: var(--hms-danger) !important; }
.hms-danger-hover { color: var(--hms-danger-hover) !important; }
.hms-danger-soft { background: var(--hms-danger-soft) !important; }
.hms-danger-text { color: var(--hms-danger-text) !important; }
.hms-purple { color: var(--hms-purple) !important; }
.hms-purple-soft { background: var(--hms-purple-soft) !important; }
.hms-teal { color: var(--hms-teal) !important; }
.hms-teal-soft { background: var(--hms-teal-soft) !important; }

.hms-radius-sm { border-radius: var(--hms-radius-sm) !important; }
.hms-radius { border-radius: var(--hms-radius) !important; }
.hms-radius-lg { border-radius: var(--hms-radius-lg) !important; }
.hms-radius-pill { border-radius: var(--hms-radius-pill) !important; }

.hms-shadow-xs { box-shadow: var(--hms-shadow-xs) !important; }
.hms-shadow-sm { box-shadow: var(--hms-shadow-sm) !important; }
.hms-shadow { box-shadow: var(--hms-shadow) !important; }
.hms-shadow-lg { box-shadow: var(--hms-shadow-lg) !important; }

.hms-transition { transition: all var(--hms-transition) !important; }

.hms-divider { border-top: 1px solid var(--hms-border); margin: 1rem 0; }

.hms-filter { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.hms-table-search { position: relative; }

.shadow { box-shadow: var(--hms-shadow) !important; }
.shadow-sm { box-shadow: var(--hms-shadow-sm) !important; }
.rounded { border-radius: var(--hms-radius) !important; }

/* live queue card ---------------------------------------------------------- */
.hms-queue-card {
    overflow: hidden;
    border: 1px solid var(--hms-border);
    box-shadow: var(--hms-shadow-sm);
    transition: box-shadow var(--hms-transition), transform var(--hms-transition);
}

.hms-queue-card:hover {
    box-shadow: var(--hms-shadow);
    transform: translateY(-2px);
}

/* New patient: green wash. Returning patient: amber wash. Replaces the
   old hard-coded #00c30b / #fffd00 card backgrounds. */
.hms-queue-card--new {
    border-left: 4px solid var(--hms-success);
    background: linear-gradient(90deg, var(--hms-success-soft) 0%, var(--hms-surface) 62%);
}

.hms-queue-card--return {
    border-left: 4px solid var(--hms-warning);
    background: linear-gradient(90deg, var(--hms-warning-soft) 0%, var(--hms-surface) 62%);
}

.hms-queue-card__photo {
    width: 100%;
    max-width: 130px;
    height: 130px;
    object-fit: cover;
    border-radius: var(--hms-radius-sm);
    border: 2px solid var(--hms-surface);
    box-shadow: var(--hms-shadow-xs);
}

.hms-queue-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.hms-queue-card__link:hover { color: inherit; text-decoration: none; }

.hms-queue-card__name {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    text-transform: uppercase;
    color: var(--hms-primary-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hms-queue-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
    margin-top: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hms-text);
}

.hms-queue-card__id::before { content: "#"; color: var(--hms-text-subtle); }

.hms-queue-card__room::before {
    content: "\00b7";
    margin-right: 0.4rem;
    color: var(--hms-text-subtle);
}

.hms-queue-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.65rem;
}

.hms-queue-card__danger {
    margin-top: 0.6rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--hms-border);
    text-align: center;
}

/* document preview tile ---------------------------------------------------- */
.hms-doc-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 209px;
    background: var(--hms-surface-sunken);
    border-bottom: 1px solid var(--hms-border);
    color: var(--hms-text-muted);
    text-decoration: none;
}

.hms-doc-preview i { font-size: 2.4rem; color: var(--hms-border-strong); }

.hms-doc-preview span {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hms-doc-preview:hover { color: var(--hms-primary); text-decoration: none; }
.hms-doc-preview:hover i { color: var(--hms-primary); }

/* bulk-action bar (patient list) ------------------------------------------ */
.hms-bulk-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    background: var(--hms-surface-alt);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius-sm);
}

.hms-bulk-bar__select {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    font-weight: 600;
    cursor: pointer;
}

.hms-bulk-bar__divider {
    width: 1px;
    height: 24px;
    background: var(--hms-border-strong);
}

.hms-bulk-bar input[type="checkbox"],
.patient-row-select {
    width: 17px;
    height: 17px;
    vertical-align: middle;
    cursor: pointer;
}

/* selected rows in the server-side patient list */
.table tbody tr.row-selected,
.table tbody tr.row-selected td {
    background-color: var(--hms-primary-soft) !important;
}

/* remarks suggestion dropdown --------------------------------------------- */
.hms-suggest-box {
    position: relative;
    z-index: 20;
}

.hms-suggest-box .hms-suggest-list {
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    background: var(--hms-surface);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius-sm);
    box-shadow: var(--hms-shadow);
}

.hms-suggest-box .hms-suggest-list li {
    list-style: none;
    padding: 0.4rem 0.6rem;
    border-radius: var(--hms-radius-sm);
    cursor: pointer;
}

.hms-suggest-box .hms-suggest-list li:hover,
.hms-suggest-box .hms-suggest-list li.active {
    background: var(--hms-surface-alt);
}

/* accent rule ------------------------------------------------------------- */
.hms-hr-accent {
    border: 0;
    border-top: 2px solid var(--hms-success);
    opacity: 0.35;
}

/* prescription completion chip -------------------------------------------- */
.hms-complete-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--hms-text-muted);
    background: var(--hms-surface);
    border: 1px solid var(--hms-border-strong);
    border-radius: var(--hms-radius-sm);
}

.hms-complete-chip .btn-circle {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    margin-top: -0.3rem;
}

.hms-complete-chip--done {
    color: var(--hms-success-text);
    border-color: var(--hms-success);
}

.hms-complete-chip--done .btn-circle {
    color: #fff;
    background: var(--hms-success);
    border-color: var(--hms-success);
    pointer-events: none;
}

/* inline emphasis in clinical detail rows --------------------------------- */
.hms-amount-danger { color: var(--hms-danger); }
.hms-detail-strong { color: var(--hms-primary-text); }

/* bootstrap-notify must sit above modals ----------------------------------- */
[data-notify] { z-index: 9999 !important; }

/* focus ring helper */
.hms-ring { box-shadow: 0 0 0 3px var(--hms-ring) !important; }
.hms-submitting { opacity: 0.85; }

/* ========================================================= sidebar bits ==== */

/* legacy selectors still emitted by some partials */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(185deg, var(--hms-sidebar-bg-2) 0%, var(--hms-sidebar-bg) 60%, #15123a 100%);
}

.sidebar .nav-link { color: var(--hms-sidebar-text); }
.sidebar .nav-link:hover, .sidebar .nav-link:focus { color: var(--hms-sidebar-text-strong); }

/* ============================================================== backdrop ==== */

.hms-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1025;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(1px);
}

.hms-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 3000;
    padding: 0.6rem 1rem;
    background: var(--hms-primary);
    color: #fff;
    border-radius: 0 0 var(--hms-radius-sm) 0;
    font-weight: 700;
}

.hms-skip-link:focus { left: 0; color: #fff; }

/* =========================================================== auth ============ */

.hms-auth-body {
    margin: 0;
    min-height: 100vh;
    background: var(--hms-canvas);
    font-family: var(--hms-font);
}

.hms-auth-shell {
    display: flex;
    min-height: 100vh;
}

/* brand panel (left) ------------------------------------------------------- */
.hms-auth-aside {
    position: relative;
    flex: 0 0 46%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.75rem 3rem;
    color: #e5e7ff;
    background: linear-gradient(160deg, #312e81 0%, #1e1b4b 55%, #15123a 100%);
    overflow: hidden;
}

.hms-auth-aside::before,
.hms-auth-aside::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
    opacity: 0.5;
}

.hms-auth-aside::before {
    width: 420px;
    height: 420px;
    right: -160px;
    top: -140px;
    background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.75), transparent 68%);
}

.hms-auth-aside::after {
    width: 360px;
    height: 360px;
    left: -140px;
    bottom: -150px;
    background: radial-gradient(circle at 60% 40%, rgba(14, 165, 233, 0.55), transparent 68%);
}

.hms-auth-aside-inner { position: relative; z-index: 1; }

.hms-auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    color: #fff;
    text-decoration: none;
}

.hms-auth-brand .hms-auth-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: var(--hms-radius);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.25rem;
    color: #fff;
}

.hms-auth-brand .hms-auth-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; }

.hms-auth-head h1 {
    margin: 1.6rem 0 0.5rem;
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.hms-auth-head p, .hms-auth-lede { color: #b9bdf0; font-size: 0.95rem; }

.hms-auth-points { list-style: none; margin: 1.75rem 0 0; padding: 0; }

.hms-auth-points li {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.5rem 0;
    color: #d7d9f7;
    font-size: 0.9rem;
}

.hms-auth-points i { color: #818cf8; margin-top: 0.15rem; }

.hms-auth-aside-foot { position: relative; z-index: 1; font-size: 0.8rem; color: #8f93c9; }

/* form panel (right) ------------------------------------------------------- */
.hms-auth-main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}

.hms-auth-wrap { width: 100%; max-width: 420px; }
.hms-auth-wrap.wide { max-width: 520px; }

.hms-auth-card {
    background: var(--hms-surface);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius-lg);
    box-shadow: var(--hms-shadow);
    padding: 2.25rem;
}

.hms-auth-body-pad { padding: 2.25rem; }

.hms-auth-eyebrow {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--hms-primary);
    margin-bottom: 0.35rem;
}

.hms-auth-head h1 { color: var(--hms-text); }

.hms-auth-tagline { color: var(--hms-text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.hms-auth-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }

.hms-auth-text { font-size: 0.85rem; color: var(--hms-text-muted); text-align: center; margin-top: 1.25rem; }
.hms-auth-text .hms-auth-link, .hms-auth-link { color: var(--hms-primary); font-weight: 700; }

.hms-auth-foot { margin-top: 1.5rem; text-align: center; font-size: 0.8rem; color: var(--hms-text-subtle); }
.hms-auth-foot a { color: var(--hms-primary); font-weight: 600; }

/* old auth card shims ------------------------------------------------------ */
.form-control-user {
    height: auto;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: var(--hms-radius-sm);
}

.form-control-user:focus { box-shadow: 0 0 0 3px var(--hms-ring); }
.form-control-user::placeholder { color: var(--hms-text-subtle); }

/* ============================================================ animation ==== */

.hms-fade-in { animation: hms-fade-in 0.4s ease both; }
.hms-notify-in { animation: hms-notify-in 0.35s ease both; }
.hms-pulse { animation: hms-pulse-soft 2s infinite; }
.hms-spin { animation: hms-spin 0.7s linear infinite; }
.hms-progress-slide { animation: hms-progress-slide 1.1s ease-in-out infinite; }

@keyframes hms-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes hms-notify-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes hms-progress-slide {
    0% { margin-left: -35%; }
    100% { margin-left: 100%; }
}

@keyframes hms-pulse-soft {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.6; }
}

@keyframes hms-spin {
    to { transform: rotate(360deg); }
}

/* ================================================================ print ==== */

@media print {
    .sidebar,
    .hms-topbar,
    .scroll-to-top,
    .hms-backdrop,
    footer,
    .no-print,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_paginate,
    .hms-page-head__actions {
        display: none !important;
    }

    .hms-container, #content-wrapper, body { background: #fff !important; }
    .card { box-shadow: none !important; border-color: #ccc !important; }
    a[href]::after { content: ""; }
}

/* printable prescription / report body ------------------------------------ */
.hms-print-doc p,
.hms-print-doc u,
.hms-print-doc li {
    color: var(--hms-text) !important;
}

/* ============================================================ responsive ==== */

@media (max-width: 1199.98px) {
    .hms-topbar-search .input-group { width: 200px; }
}

@media (max-width: 991.98px) {
    .hms-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1031;
        transform: translateX(-100%);
        transition: transform var(--hms-transition);
        box-shadow: var(--hms-shadow-lg);
    }

    body.hms-sidebar-open .hms-sidebar { transform: translateX(0); }

    .hms-topbar-search { display: none; }

    .hms-topbar { padding: 0.6rem 1rem; }

    .hms-container { padding: 0 14px 24px; }
}

@media (max-width: 575.98px) {
    .hms-page-head { flex-direction: column; align-items: stretch; }
    .hms-stat__value { font-size: 1.45rem; }
    .hms-auth-card { padding: 1.5rem; }
    .modal-dialog { margin: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}


/* ------------------------------------------------- topbar quick search */
.hms-topbar-search { position: relative; }

.hms-quicksearch {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(400px, calc(100vw - 2rem));
    max-height: min(62vh, 470px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--hms-surface);
    border: 1px solid var(--hms-border);
    border-radius: var(--hms-radius);
    box-shadow: var(--hms-shadow-lg);
    padding: 0.35rem;
    z-index: 1050;
}

.hms-quicksearch[hidden] { display: none; }

.hms-quicksearch__group {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--hms-text-subtle);
    padding: 0.6rem 0.7rem 0.28rem;
}

.hms-quicksearch__group + .hms-quicksearch__group {
    border-top: 1px solid var(--hms-border);
    margin-top: 0.3rem;
}

.hms-quicksearch__item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 0;
    background: none;
    border-radius: var(--hms-radius-sm);
    color: var(--hms-text);
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--hms-transition), color var(--hms-transition);
}

.hms-quicksearch__item i {
    width: 1.15rem;
    text-align: center;
    color: var(--hms-text-subtle);
    flex: 0 0 auto;
}

.hms-quicksearch__item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hms-quicksearch__item:hover,
.hms-quicksearch__item:focus,
.hms-quicksearch__item.is-active {
    background: var(--hms-primary-soft);
    color: var(--hms-primary-text);
    outline: none;
}

.hms-quicksearch__item:hover i,
.hms-quicksearch__item:focus i,
.hms-quicksearch__item.is-active i { color: var(--hms-primary); }

.hms-quicksearch__item mark {
    background: transparent;
    color: inherit;
    font-weight: 700;
}

.hms-quicksearch__empty {
    padding: 1.15rem 0.75rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--hms-text-muted);
}

.hms-quicksearch__foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0.7rem 0.2rem;
    margin-top: 0.3rem;
    border-top: 1px solid var(--hms-border);
    font-size: 0.68rem;
    color: var(--hms-text-subtle);
}

.hms-quicksearch__foot kbd {
    font-family: inherit;
    padding: 0.05rem 0.35rem;
    border: 1px solid var(--hms-border-strong);
    border-radius: 4px;
    background: var(--hms-surface-sunken);
    color: var(--hms-text-muted);
}
