/* =====================================================================
   HELIX EHR - "Cryo Glass" design layer
   One set of tokens, one button family, one glass material.
   Print rules live at the bottom of this file and are not part of this layer.
   ===================================================================== */
:root {
    --bg: #070b14;
    --bg-2: #0b1220;
    --neon: #38f0ff;
    --em: #34f5a4;
    --amber: #ffcf5c;
    --red: #ff5d73;
    --purple: #a78bfa;
    --acc-rgb: 56, 240, 255;
    --em-rgb: 52, 245, 164;
    --line: rgba(255, 255, 255, .10);
    --line-2: rgba(255, 255, 255, .18);
    --txt: #e8eef7;
    --mut: #8fa3bf;
    --faint: #6f84a3;
    --r-sm: 9px;
    --r: 12px;
    --r-lg: 16px;
    --h: 36px;
    --h-sm: 30px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --glass: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .032));
    --edge: inset 0 1px 0 rgba(255, 255, 255, .14);
}

html,
body {
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--txt);
    font: 14px/1.5 'IBM Plex Sans', 'Cairo', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Fixed backdrop: soft glows + faint grid (composited, so scrolling stays smooth) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px) 0 0 / 36px 36px,
        linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px) 0 0 / 36px 36px,
        radial-gradient(900px 520px at 88% -8%, rgba(var(--acc-rgb), .14), transparent 62%),
        radial-gradient(760px 520px at -8% 108%, rgba(140, 110, 255, .11), transparent 60%),
        var(--bg);
}

.hud {
    font-family: 'Chakra Petch', 'Cairo', sans-serif;
}

.mut {
    color: var(--mut);
}

.hidden {
    display: none !important;
}

::selection {
    background: rgba(var(--acc-rgb), .3);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .14);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--acc-rgb), .35);
}

/* ---------- Icons (inline SVG sprite in index.html) ---------- */
.ic {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -3px;
}

.ic-lg {
    width: 20px;
    height: 20px;
}

/* ---------- Glass material ---------- */
.glass {
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--edge), 0 10px 28px rgba(0, 0, 0, .28);
}

/* ---------- Top bar ---------- */
#top {
    position: fixed;
    inset: 0 0 auto 0;
    padding-left: 20px;
    padding-right: 20px;
    height: 60px;
    z-index: 30;
    background: rgba(8, 13, 24, .78);
    backdrop-filter: blur(18px) saturate(1.5);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
    gap: 12px;
}

#ecg {
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 14px;
    pointer-events: none;
    opacity: .5;
}

#ecg path {
    stroke: var(--neon);
    fill: none;
    stroke-width: 1.2;
    stroke-dasharray: 260 1400;
    animation: ecg 7s linear infinite;
    filter: drop-shadow(0 0 3px var(--neon));
}

@keyframes ecg {
    from {
        stroke-dashoffset: 260;
    }

    to {
        stroke-dashoffset: -1400;
    }
}

#syncIndicator {
    height: var(--h-sm);
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .04);
    padding: 0 12px;
}

#syncIndicator #syncText {
    font-size: 11px;
    letter-spacing: .04em;
}

.tab {
    height: var(--h-sm);
    padding: 0 13px;
    border-radius: 10px;
    color: var(--mut);
    font-weight: 500;
    font-size: 13px !important;
    border: 1px solid transparent;
    transition: color .18s, background .18s, border-color .18s, box-shadow .18s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    white-space: nowrap;
}

.tab:hover {
    color: var(--txt);
    background: rgba(255, 255, 255, .05);
}

.tab.on {
    color: #fff;
    border-color: rgba(var(--acc-rgb), .4);
    background: rgba(var(--acc-rgb), .13);
    box-shadow: 0 0 20px rgba(var(--acc-rgb), .18), var(--edge);
}

nav.tabs-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 13px;
    background: rgba(0, 0, 0, .28);
    border: 1px solid var(--line);
}

/* ---------- Buttons: one family ---------- */
.btn,
.mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: var(--h) !important;
    padding: 0 14px !important;
    border-radius: var(--r) !important;
    font: 500 13px/1 'IBM Plex Sans', 'Cairo', system-ui, sans-serif !important;
    letter-spacing: 0;
    color: var(--txt) !important;
    border: 1px solid var(--line-2) !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .04)) !important;
    box-shadow: var(--edge) !important;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s var(--ease), border-color .15s, background .15s, box-shadow .15s;
}

.mini {
    height: var(--h-sm) !important;
    padding: 0 11px !important;
    border-radius: var(--r-sm) !important;
    font-size: 12px !important;
}

.btn:hover,
.mini:hover {
    border-color: rgba(var(--acc-rgb), .55) !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .06)) !important;
    transform: translateY(-1px);
}

.btn:active,
.mini:active {
    transform: translateY(0) scale(.98);
}

.btn:focus-visible,
.inp:focus-visible,
.tab:focus-visible,
.mini:focus-visible {
    outline: 2px solid var(--neon);
    outline-offset: 2px;
}

.btn:disabled,
.mini:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

.btn .ic,
.mini .ic {
    width: 15px;
    height: 15px;
}

.btn.btn-p,
.mini.btn-p {
    color: #04141a !important;
    font-weight: 600 !important;
    border-color: transparent !important;
    background: linear-gradient(135deg, var(--neon), var(--em)) !important;
    box-shadow: 0 0 22px rgba(var(--acc-rgb), .32), inset 0 1px 0 rgba(255, 255, 255, .5) !important;
}

.btn.btn-p:hover,
.mini.btn-p:hover {
    filter: brightness(1.08);
    border-color: transparent !important;
    background: linear-gradient(135deg, var(--neon), var(--em)) !important;
}

.btn.btn-e,
.mini.btn-e {
    color: var(--em) !important;
    border-color: rgba(var(--em-rgb), .5) !important;
    background: rgba(var(--em-rgb), .11) !important;
    box-shadow: 0 0 16px rgba(var(--em-rgb), .14), var(--edge) !important;
}

.btn.btn-e:hover,
.mini.btn-e:hover {
    border-color: rgba(var(--em-rgb), .8) !important;
    background: rgba(var(--em-rgb), .2) !important;
}

.btn.btn-d,
.mini.btn-d {
    color: #ff8a9b !important;
    border-color: rgba(255, 93, 115, .45) !important;
    background: rgba(255, 93, 115, .09) !important;
}

.btn.btn-d:hover,
.mini.btn-d:hover {
    border-color: rgba(255, 93, 115, .8) !important;
    background: rgba(255, 93, 115, .18) !important;
}

.btn.btn-ai,
.mini.btn-ai {
    color: #cdbcff !important;
    border-color: rgba(167, 139, 250, .5) !important;
    background: rgba(167, 139, 250, .12) !important;
    box-shadow: 0 0 16px rgba(167, 139, 250, .14), var(--edge) !important;
}

.btn.btn-ai:hover,
.mini.btn-ai:hover {
    border-color: rgba(167, 139, 250, .85) !important;
    background: rgba(167, 139, 250, .22) !important;
}

.btn.btn-g,
.mini.btn-g {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: var(--mut) !important;
}

.btn.btn-g:hover,
.mini.btn-g:hover {
    color: var(--txt) !important;
    background: rgba(255, 255, 255, .07) !important;
}

.mini.on {
    color: #fff !important;
    border-color: rgba(var(--acc-rgb), .5) !important;
    background: rgba(var(--acc-rgb), .16) !important;
    box-shadow: 0 0 16px rgba(var(--acc-rgb), .16), var(--edge) !important;
}

.btn.ic-only {
    width: var(--h);
    padding: 0 !important;
}

.mini.ic-only {
    width: var(--h-sm);
    padding: 0 !important;
}

.mini.btn-d.ic-only {
    background: transparent !important;
    border-color: rgba(255, 93, 115, .28) !important;
    box-shadow: none !important;
}

.mini.rm:hover {
    color: #ff8a9b !important;
    background: rgba(255, 93, 115, .12) !important;
}

/* ---------- Form controls ---------- */
.inp {
    width: 100%;
    min-height: var(--h);
    background: rgba(3, 7, 14, .55);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--txt);
    font: 13px/1.45 'IBM Plex Sans', 'Cairo', system-ui, sans-serif !important;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.inp::placeholder {
    color: var(--faint);
}

.inp:hover {
    border-color: var(--line-2);
}

.inp:focus {
    border-color: rgba(var(--acc-rgb), .65);
    box-shadow: 0 0 0 3px rgba(var(--acc-rgb), .13);
    outline: none;
    background: rgba(3, 7, 14, .75);
}

textarea.inp {
    resize: vertical;
    min-height: 74px;
}

select.inp option {
    background: #101826;
}

input[type=date] {
    color-scheme: dark;
}

input[type=checkbox] {
    accent-color: var(--neon);
}

.lbl {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--mut);
    margin: 0 0 5px;
}

.sec {
    font: 600 12px/1.2 'Chakra Petch', sans-serif;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--neon);
    padding-bottom: 7px;
    margin-bottom: 10px;
    border-bottom: 1px solid;
    border-image: linear-gradient(90deg, rgba(var(--acc-rgb), .4), transparent 85%) 1;
}

/* ---------- Pills / status ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    font-size: 11px;
    font-weight: 600;
    padding: 0 10px;
    border-radius: 99px;
    border: 1px solid;
    white-space: nowrap;
}

.pill[class*="st-"]::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.st-waiting {
    color: var(--amber);
    border-color: rgba(255, 207, 92, .45);
    background: rgba(255, 207, 92, .08);
}

.st-in-consult {
    color: var(--neon);
    border-color: rgba(var(--acc-rgb), .45);
    background: rgba(var(--acc-rgb), .08);
}

.st-completed {
    color: var(--em);
    border-color: rgba(var(--em-rgb), .45);
    background: rgba(var(--em-rgb), .08);
}

.st-sent-for-evaluation {
    color: #b9a4ff;
    border-color: rgba(167, 139, 250, .45);
    background: rgba(167, 139, 250, .08);
}

.st-archived {
    color: var(--mut);
    border-color: rgba(142, 160, 184, .45);
    background: rgba(142, 160, 184, .08);
}

.st-deleted {
    color: var(--red);
    border-color: rgba(255, 93, 115, .45);
    background: rgba(255, 93, 115, .08);
}

.vitals-alert {
    border-color: rgba(255, 93, 115, .75) !important;
    color: #ff8a9b !important;
    background: rgba(255, 93, 115, .12) !important;
    box-shadow: 0 0 0 3px rgba(255, 93, 115, .1), 0 0 18px rgba(255, 93, 115, .18);
}

/* ---------- Queue ---------- */
.qcard {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    grid-template-areas: "no info pill" "no act act";
    gap: 8px 14px;
    align-items: center;
    padding: 14px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .2s var(--ease);
}

.qcard:hover {
    border-color: rgba(var(--acc-rgb), .5);
    box-shadow: var(--edge), 0 0 30px rgba(var(--acc-rgb), .15), 0 12px 30px rgba(0, 0, 0, .3);
    transform: translateY(-2px);
}

.qno {
    grid-area: no;
    align-self: start;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font: 700 24px/1 'Chakra Petch', sans-serif;
    color: var(--neon);
    border: 1px solid rgba(var(--acc-rgb), .4);
    background: rgba(var(--acc-rgb), .08);
    text-shadow: 0 0 14px rgba(var(--acc-rgb), .7);
}

.qcard.done .qno {
    color: var(--em);
    border-color: rgba(var(--em-rgb), .4);
    background: rgba(var(--em-rgb), .07);
    text-shadow: 0 0 14px rgba(var(--em-rgb), .6);
}

.qinfo {
    grid-area: info;
    min-width: 0;
}

.qpill {
    grid-area: pill;
    align-self: start;
}

.qact {
    grid-area: act;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

#qStats {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.qstat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
}

.qstat b {
    font: 700 24px/1 'Chakra Petch', sans-serif;
}

/* ---------- Tables ---------- */
.tbl {
    width: 100%;
    border-collapse: collapse;
}

.tbl th {
    text-align: left;
    font: 600 11px/1.2 'Chakra Petch', sans-serif;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--faint);
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: rgba(12, 19, 33, .96);
    z-index: 1;
}

.tbl td {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.tbl tbody tr {
    cursor: pointer;
    transition: background .15s;
}

.tbl tbody tr:hover {
    background: rgba(var(--acc-rgb), .06);
}

/* ---------- Modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
    background: radial-gradient(900px 600px at 50% 0%, rgba(var(--acc-rgb), .07), transparent 60%), rgba(3, 6, 12, .74);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    padding: 16px;
}

.sheet {
    background: linear-gradient(180deg, rgba(20, 30, 50, .96), rgba(11, 18, 32, .97));
    border: 1px solid var(--line-2);
    border-radius: 20px;
    box-shadow: var(--edge), 0 40px 90px rgba(0, 0, 0, .7), 0 0 0 1px rgba(0, 0, 0, .4);
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.sheet-h {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent);
    border-radius: 20px 20px 0 0;
}

.sheet-h .hud {
    color: var(--txt) !important;
    letter-spacing: .01em;
}

.sheet-h .hud>span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
}

.sheet-h .hud>span:first-child .ic {
    width: 20px;
    height: 20px;
    color: var(--neon);
}

.sheet-b {
    padding: 20px;
    overflow: auto;
}

.sheet-f {
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, .18);
    border-radius: 0 0 20px 20px;
}

#modal-profile,
#drawer-ai-chat {
    justify-content: flex-end;
    padding: 0;
}

#modal-profile .sheet,
#drawer-ai-chat .sheet {
    max-width: 540px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border-width: 0 0 0 1px;
    animation: slide .24s var(--ease);
}

#modal-profile .sheet-h,
#drawer-ai-chat .sheet-h {
    border-radius: 0;
}

#drawer-ai-chat .sheet {
    max-width: 440px;
}

@keyframes slide {
    from {
        transform: translateX(36px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

/* Layering: a window opened from inside another one must sit above it.
   50 base screens (visit, new patient, catalogs) < 56 profile drawer < 58 diet planner < 60 print editor
   < 62 tools opened from a visit (checklist, calculators, AI, follow-up) < 64 edit patient < 65 copilot
   < 66 search < 72 super admin < 80 confirm. */
#modal-encounter,
#modal-patient,
#modal-db-manager {
    z-index: 50;
}

#modal-profile {
    z-index: 56;
}

#modal-diet-planner {
    z-index: 58;
}

#modal-editor {
    z-index: 60;
}

#modal-sch-fu,
#modal-surgical-checklist,
#modal-ai-synthesis,
#modal-photo,
#modal-dictation,
#modal-ai-key,
#modal-metabolic {
    z-index: 62;
}

#modal-edit-patient {
    z-index: 64;
}

#drawer-ai-chat {
    z-index: 65;
}

#modal-global-search {
    z-index: 66;
}

#modal-super-admin {
    z-index: 72;
}

#modal-confirm {
    z-index: 80;
}

/* ---------- Overlays, toasts, spinner ---------- */
/* Sign-in card */
#authOverlay .sheet {
    max-width: 420px;
    padding: 8px 4px;
    box-shadow: var(--edge), 0 40px 90px rgba(0, 0, 0, .7), 0 0 60px rgba(var(--acc-rgb), .12);
}

#authOverlay .sheet .hud {
    font-size: 22px !important;
    text-shadow: 0 0 18px rgba(var(--acc-rgb), .5);
}

/* Windows ease in */
@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.985);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal:not(.hidden):not(#modal-profile):not(#drawer-ai-chat) .sheet {
    animation: pop .2s var(--ease);
}

#idle-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(700px 480px at 50% 40%, rgba(var(--acc-rgb), .1), transparent 65%), rgba(5, 9, 17, .97);
    backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    min-width: 250px;
    max-width: 390px;
    padding: 12px 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(24, 36, 58, .97), rgba(12, 19, 34, .97));
    border: 1px solid var(--line-2);
    border-left: 3px solid var(--em);
    box-shadow: var(--edge), 0 14px 36px rgba(0, 0, 0, .5);
    animation: slide .22s var(--ease);
    transition: .35s;
    font-size: 13px;
}

.toast.error {
    border-left-color: var(--red);
}

.toast.info {
    border-left-color: var(--neon);
}

.toast.out {
    opacity: 0;
    transform: translateX(30px);
}

#spinner {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 6, 12, .4);
}

.ring {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 3px solid rgba(var(--acc-rgb), .16);
    border-top-color: var(--neon);
    animation: spin .8s linear infinite;
    filter: drop-shadow(0 0 8px var(--neon));
}

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

/* ---------- Visit workspace ---------- */
.enc-head {
    padding: 14px 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .01));
}

.enc-q {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 700 22px/1 'Chakra Petch', sans-serif;
    color: var(--neon);
    border: 1px solid rgba(var(--acc-rgb), .4);
    background: rgba(var(--acc-rgb), .08);
    text-shadow: 0 0 14px rgba(var(--acc-rgb), .7);
}

.enc-bmi {
    min-width: 86px;
    height: 52px;
    padding: 0 10px;
    border-radius: 16px;
    border: 1px solid var(--line-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .15s var(--ease);
}

.enc-bmi:hover {
    transform: translateY(-1px);
}

.enc-bmi span:first-child {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.enc-bmi span:last-child {
    font: 700 18px/1.1 'Chakra Petch', sans-serif;
}

.grp-lab {
    font: 600 11px/1 'Chakra Petch', sans-serif;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 0 0 6px 2px;
}

.grp-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.panel {
    padding: 16px;
    border-radius: var(--r-lg);
}

.vit-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.vit-grid .lbl {
    font-size: 11px;
    margin-bottom: 4px;
}

.vit-grid .inp {
    font: 600 16px/1 'Chakra Petch', sans-serif !important;
    text-align: center;
    padding: 6px 4px;
}

.med-row,
.lab-row,
.rad-row {
    border-radius: 12px !important;
    padding: 6px !important;
    background: rgba(3, 7, 14, .35) !important;
    border: 1px solid var(--line) !important;
    transition: border-color .15s;
}

.med-row:hover,
.lab-row:hover,
.rad-row:hover {
    border-color: var(--line-2) !important;
}

.med-row {
    display: grid !important;
    grid-template-columns: minmax(0, 2.6fr) minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, .8fr) minmax(0, .8fr) 30px !important;
    gap: 6px;
    align-items: center;
}

.med-row>* {
    grid-column: auto !important;
}

.med-row>.med-alert {
    grid-column: 1 / -1 !important;
}

.med-row .inp,
.lab-row .inp,
.rad-row .inp {
    min-height: 32px;
    border-radius: 9px;
}

#medsList,
#labsList,
#radList {
    scrollbar-gutter: stable;
}

/* ---------- AI synthesis page ---------- */
.ai-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 60px 20px; color: #cdbcff; font-weight: 600; }
.ai-glance { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.ai-tile { padding: 14px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--edge); display: flex; flex-direction: column; gap: 4px; }
.ai-tile span { font: 600 11px/1 'Chakra Petch', sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.ai-tile b { font-size: 17px; font-weight: 600; line-height: 1.3; }
.ai-tile b.hud { font-size: 28px; color: var(--neon); }
.ai-card { padding: 16px 18px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--edge); }
.ai-card h4 { font: 600 12px/1.2 'Chakra Petch', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--neon); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.ai-card h4 em, .ai-more summary em { font-style: normal; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: rgba(var(--acc-rgb), .14); color: var(--neon); }
.ai-text { font-size: 14px; line-height: 1.75; color: #dbe6f5; }
.ai-2col { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 900px) { .ai-2col, .ai-glance { grid-template-columns: 1fr; } }
.ai-dx { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.ai-dx:first-of-type { border-top: 0; padding-top: 0; }
.ai-rank { flex: none; width: 24px; height: 24px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font: 700 12px 'Chakra Petch', sans-serif; background: rgba(var(--acc-rgb), .12); color: var(--neon); }
.ai-dx-h { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ai-dx-h b { font-size: 14px; font-weight: 600; }
.ai-dx p { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: var(--mut); }
.prob { font-style: normal; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid; white-space: nowrap; align-self: flex-start; }
.prob.high { color: #ff8a9b; border-color: rgba(255, 93, 115, .5); background: rgba(255, 93, 115, .1); }
.prob.med { color: var(--amber); border-color: rgba(255, 207, 92, .5); background: rgba(255, 207, 92, .09); }
.prob.low { color: var(--neon); border-color: rgba(var(--acc-rgb), .45); background: rgba(var(--acc-rgb), .08); }
.ai-gaps, .ai-more ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-gaps li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.55; color: #dbe6f5; }
.ai-gaps li .ic { color: var(--amber); margin-top: 3px; }
.ai-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 8px; }
.ai-steps li { counter-increment: s; display: flex; gap: 12px; font-size: 14px; line-height: 1.6; color: #dbe6f5; }
.ai-steps li::before { content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font: 700 12px 'Chakra Petch', sans-serif; background: rgba(var(--em-rgb), .12); color: var(--em); }
.ai-more summary { cursor: pointer; font: 600 12px 'Chakra Petch', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); display: flex; align-items: center; gap: 8px; list-style: none; }
.ai-more ul { margin-top: 10px; font-size: 13px; line-height: 1.6; color: #dbe6f5; list-style: disc inside; }

/* ---------- Diet planner extras ---------- */
.dchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid rgba(255, 207, 92, .55); color: var(--amber); background: rgba(255, 207, 92, .1); transition: .18s; }
.dchip:not(.on) { border-color: var(--line); color: var(--faint); background: transparent; text-decoration: line-through; }
.dchip .ic { width: 14px; height: 14px; }
.chk { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 12px; border: 1px solid; }
.chk .ic { width: 15px; height: 15px; }
.chk.ok { color: var(--em); border-color: rgba(52, 245, 164, .4); background: rgba(52, 245, 164, .08); }
.chk.warn { color: var(--amber); border-color: rgba(255, 207, 92, .5); background: rgba(255, 207, 92, .09); }
#dietPlanTableBody tr { transition: background .15s; }
#dietPlanTableBody tr.drag-over { background: rgba(var(--acc-rgb), .14); box-shadow: inset 0 2px 0 var(--neon); }
#dietPlanTableBody tr.drag-src { opacity: .45; }
#dietPlanTableBody tr.row-warn { background: rgba(255, 207, 92, .07); }
.grip { cursor: grab; color: var(--faint); display: inline-flex; padding: 4px 2px; }
.grip .ic { width: 16px; height: 16px; }
.rot-up, .rot-down { display: inline-flex; }
.rot-up { transform: rotate(90deg); }
.rot-down { transform: rotate(90deg); }

/* ---------- Dashboard ---------- */
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--edge); display: flex; flex-direction: column; gap: 4px; }
.kpi span { font: 600 11px/1.2 'Chakra Petch', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.kpi b { font-size: 30px; font-weight: 700; color: var(--neon); line-height: 1.1; }
.kpi em { font-style: normal; font-size: 12px; color: var(--mut); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.dbar { display: grid; grid-template-columns: 130px 1fr 36px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.dbar .dl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe6f5; }
.dbar .dt { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.dbar .dt i { display: block; height: 100%; border-radius: 99px; }
.dbar b { text-align: right; font-variant-numeric: tabular-nums; }
.dspark { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.dspark span { flex: 1; min-width: 3px; max-width: 40px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--neon), rgba(var(--acc-rgb), .25)); }

/* ---------- Dictation ---------- */
.dict-live { animation: dictPulse 1.2s ease-in-out infinite; }
@keyframes dictPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 93, 115, .5); } 50% { box-shadow: 0 0 0 8px rgba(255, 93, 115, 0); } }
@media (prefers-reduced-motion: reduce) { .dict-live { animation: none; } }
.dict-field { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); display: flex; gap: 10px; align-items: flex-start; }
.dict-field b { display: block; font: 600 11px 'Chakra Petch', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--neon); margin-bottom: 3px; }
.dict-field div { white-space: pre-wrap; line-height: 1.6; color: #dbe6f5; font-size: 13px; }

/* ---------- Profile tabs and timeline ---------- */
.ptabs { display: flex; gap: 6px; margin-bottom: 14px; padding: 4px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); position: sticky; top: 0; z-index: 3; backdrop-filter: blur(10px); }
.ptab { flex: 1; padding: 8px 10px; border-radius: 10px; font: 600 12px 'Chakra Petch', sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); transition: .18s; }
.ptab:hover { color: #fff; }
.ptab.on { color: #fff; background: rgba(var(--acc-rgb), .18); box-shadow: inset 0 0 0 1px rgba(var(--acc-rgb), .35); }
.tl-svg { width: 100%; height: auto; display: block; }
.tl-grid { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.tl-ref { stroke: rgba(255, 207, 92, .5); stroke-width: 1; stroke-dasharray: 4 4; }
.tl-mark { stroke: rgba(167, 139, 250, .7); stroke-width: 1.5; stroke-dasharray: 3 3; }
.tl-marktxt { fill: #c4b5fd; font-size: 10px; font-weight: 600; }
.tl-ax { fill: var(--faint); font-size: 10px; }
.tl-legend { display: flex; gap: 14px; margin-top: 4px; font-size: 11px; color: var(--mut); }
.tl-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------- Change history ---------- */
.hist-ch { display: grid; grid-template-columns: 110px 1fr 18px 1fr; gap: 8px; align-items: start; margin-top: 6px; font-size: 12px; line-height: 1.5; }
.hist-ch b { color: var(--neon); font-weight: 600; }
.hist-old { color: #ff9aa9; text-decoration: line-through; text-decoration-color: rgba(255, 154, 169, .5); word-break: break-word; }
.hist-new { color: #7ef0c0; word-break: break-word; }
.hist-arrow { color: var(--faint); text-align: center; }
@media (max-width: 640px) { .hist-ch { grid-template-columns: 1fr; } .hist-arrow { display: none; } }

/* ---------- Drug check ---------- */
.rx-box { margin-bottom: 8px; border-radius: 14px; border: 1px solid rgba(255, 207, 92, .4); background: rgba(255, 207, 92, .06); overflow: hidden; }
.rx-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 12px; color: var(--amber); }
.rx-head .ic { width: 15px; height: 15px; }
.rx-pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; flex: none; align-self: flex-start; }
.rx-pill.major { background: rgba(255, 93, 115, .18); color: #ff8a9b; border: 1px solid rgba(255, 93, 115, .5); }
.rx-pill.moderate { background: rgba(255, 207, 92, .14); color: var(--amber); border: 1px solid rgba(255, 207, 92, .5); }
.rx-pill.minor { background: rgba(var(--acc-rgb), .1); color: var(--neon); border: 1px solid rgba(var(--acc-rgb), .35); }
.rx-item { display: flex; gap: 10px; padding: 8px 12px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 12px; line-height: 1.5; }
.rx-title { font-weight: 700; color: #fff; } .rx-why { color: #cbd5e1; } .rx-do { color: var(--mut); }
.rx-foot { padding: 6px 12px 8px; font-size: 10.5px; color: var(--faint); }
.med-row.rx-major { border-color: rgba(255, 93, 115, .7) !important; box-shadow: 0 0 0 1px rgba(255, 93, 115, .25); }
.med-row.rx-moderate { border-color: rgba(255, 207, 92, .6) !important; }
.med-row.rx-minor { border-color: rgba(var(--acc-rgb), .45) !important; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 14px; }
.photo-th { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #0b1220; padding: 0; }
.photo-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-th.sel { outline: 3px solid var(--neon); }
.photo-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; font-size: 10px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); text-align: left; }
.photo-viewer { position: fixed; inset: 0; z-index: 90; background: rgba(3, 7, 15, .92); display: flex; align-items: center; justify-content: center; padding: 14px; }
.photo-viewer[hidden] { display: none; }
.pv-box { position: relative; width: min(960px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; }
.pv-x { position: absolute; top: -6px; right: -6px; z-index: 3; width: 38px; height: 38px; border-radius: 99px; background: rgba(255, 255, 255, .12); color: #fff; display: flex; align-items: center; justify-content: center; }
.pv-top { display: flex; flex-wrap: wrap; gap: 6px 14px; color: #fff; font-size: 13px; padding-right: 40px; } .pv-top span { color: var(--mut); }
.pv-one img { width: 100%; max-height: 72vh; object-fit: contain; border-radius: 12px; background: #000; display: block; }
.pv-act { display: flex; gap: 8px; }
.pv-cmp { position: relative; width: 100%; max-height: 70vh; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #000; touch-action: none; }
.pv-cmp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pv-bar { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--neon); box-shadow: 0 0 12px var(--neon); }
.pv-lab { position: absolute; top: 8px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: rgba(0, 0, 0, .6); color: #fff; } .pv-lab.l { left: 8px; } .pv-lab.r { right: 8px; }
.pv-range { width: 100%; accent-color: var(--neon); height: 30px; }

/* ---------- Offline mode widgets ---------- */
#offlineBadge {
    height: var(--h-sm);
    padding: 0 12px;
    font-size: 12px;
}

@media (max-width: 1500px) {
    .enc-head .mini {
        padding: 0 9px !important;
    }

    .enc-head .grp-bar {
        gap: 5px;
    }
}

/* ---------- Dropdown menu ---------- */
#userProfileMenu {
    background: linear-gradient(180deg, rgba(22, 33, 55, .97), rgba(11, 18, 32, .98)) !important;
    border: 1px solid var(--line-2) !important;
    border-radius: 18px !important;
    box-shadow: var(--edge), 0 24px 60px rgba(0, 0, 0, .6) !important;
    backdrop-filter: blur(18px);
}

#syncIndicator #syncText {
    display: none;
}

.brand {
    white-space: nowrap;
}

/* Top bar: the extra tabs (DB manager, Guide members, Super admin, Ozempic guide) show only their icon until the window is wide */
@media (min-width: 1900px) {
    #syncIndicator #syncText {
        display: inline;
    }
}

@media (max-width: 1899px) {
    .tab .tl {
        display: none;
    }

    .brand-sub {
        display: none;
    }

    #top {
        gap: 12px;
    }

    .tab {
        padding: 0 10px;
    }
}

@media (max-width: 1249px) {
    #syncIndicator {
        display: none;
    }

    #top {
        gap: 8px;
        padding-left: 14px;
        padding-right: 14px;
    }

    .tab {
        padding: 0 8px;
        gap: 5px;
    }
}

@media (max-width: 1340px) {
    #btnSearch>span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* =====================================================================
   PRINT (unchanged: do not edit without re-checking every printed document)
   ===================================================================== */
.print-paper-wrapper {
    position: relative;
    margin: 0 auto;
}

.print-paper {
    background: #fff;
    color: #000;
    box-shadow: 0 0 35px rgba(0, 0, 0, .6);
    margin: 0 auto;
    outline: none;
    position: relative;
    z-index: 2;
}

.stationery-overlay-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 1;
    opacity: .35;
}

.print-clean-box {
    border: 1px solid #111;
    padding: 8px 12px;
    margin-bottom: 10px;
    page-break-inside: avoid;
}

.print-clean-hdr {
    font-weight: 700;
    border-bottom: 1px solid #111;
    margin: -8px -12px 6px -12px;
    padding: 4px 12px;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: #f9f9f9;
}

#printSection {
    display: none;
}

@media print {

    html,
    body {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
        overflow: visible !important;
        width: 100% !important;
    }

    body::before,
    #top,
    main,
    .modal,
    #toasts,
    #spinner,
    datalist,
    #idle-overlay,
    #offlineBar,
    #offlineBadge,
    .stationery-overlay-img {
        display: none !important;
    }

    #printSection {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        page-break-inside: avoid !important;
    }
}

#authOverlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: radial-gradient(800px 520px at 50% 30%, rgba(var(--acc-rgb), .12), transparent 62%), rgba(5, 9, 17, .97);
    backdrop-filter: blur(24px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Visit window header: one card for patient, BMI and fee; two tidy rows of tools on the right */
.enc-head .enc-q { width: 58px; height: 76px; }
.enc-card { display: flex; align-items: stretch; height: 76px; border-radius: 18px; padding: 0; overflow: hidden; }
.enc-card .enc-pt { display: flex; flex-direction: column; justify-content: center; padding: 0 18px; min-width: 250px; }
.enc-card .enc-bmi, .enc-card .enc-fee {
    min-width: 96px; height: auto; padding: 0 16px; border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none !important;
    border-inline-start: 1px solid var(--line-2) !important; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; transition: background .15s;
}
.enc-card .enc-bmi:hover, .enc-card .enc-fee:hover { background: rgba(255, 255, 255, .05) !important; transform: none; }
.enc-card .enc-fee { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.enc-card .enc-fee.hidden { display: none; }
.enc-card .enc-fee #feeChip { font-size: 13px; font-weight: 800; letter-spacing: 0; text-transform: none; color: #fff; white-space: nowrap; }
.enc-right { display: flex; align-items: center; justify-content: flex-end; flex: 1; min-width: 0; }
/* the tools: one card, two rows, every button is a cell */
.enc-tools { display: flex; flex-direction: column; height: 76px; border-radius: 18px; overflow: hidden; }
.enc-rowc { display: flex; flex: 1; min-height: 0; }
.enc-rowc + .enc-rowc { border-top: 1px solid var(--line-2); }
.enc-cell {
    flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px; font-size: 12px; font-weight: 600; white-space: nowrap;
    color: #dbe4f0; background: transparent; border: 0; border-radius: 0; cursor: pointer; transition: background .15s, color .15s;
}
.enc-cell + .enc-cell { border-inline-start: 1px solid var(--line-2); }
.enc-cell:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.enc-cell.hidden { display: none; }
.enc-cell .ic { width: 15px; height: 15px; }
.enc-cell.icon { padding: 0 13px; flex: 0 0 auto; }
.enc-cell.ai { color: #b9b4ff; }
.enc-cell.ai:hover { background: rgba(140, 120, 255, .14); color: #fff; }
.enc-cell.danger { color: #ff8a98; flex: 0 0 auto; padding: 0 15px; }
.enc-cell.danger:hover { background: rgba(255, 93, 115, .16); color: #fff; }
/* the small + inside the drug box (adds a drug that is not in the database yet) */
.med-add { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--em); background: rgba(52, 245, 164, .12); color: var(--em); font-size: 16px; font-weight: 800; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.med-add:hover { background: var(--em); color: #04110c; }
.med-add.hidden { display: none; }
