:root {
    --ifmc-primary: #0f766e;
    --ifmc-primary-dark: #115e59;
    --ifmc-accent: #14b8a6;
    --ifmc-ink: #172033;
    --ifmc-muted: #64748b;
    --ifmc-bg: #f3f7f8;
    --ifmc-surface: #ffffff;
    --ifmc-border: #dfe8eb;
    --ifmc-radius: 14px;
    --ifmc-shadow: 0 8px 28px rgba(15, 23, 42, .07);
}

html, body { background: var(--ifmc-bg); color: var(--ifmc-ink); }
body { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
#container { display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--ifmc-primary); }
a:hover, a:focus { color: var(--ifmc-primary-dark); text-decoration: none; }

.header.white-bg {
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--ifmc-border);
    box-shadow: 0 4px 18px rgba(15,23,42,.05);
    height: 68px;
    left: 0;
    min-height: 68px;
    padding: 0 20px;
    position: fixed;
    right: 0;
}
.header .logo { color: var(--ifmc-ink); font-size: 18px; line-height: 68px; letter-spacing: -.02em; margin: 0; }
.header .logo strong { font-weight: 800; }
.sidebar-toggle-box { margin-top: 21px; }
.sidebar-toggle-box .fa { color: var(--ifmc-muted); }
.top-nav { margin-top: 9px; }
.top-nav .dropdown-toggle { border: 1px solid var(--ifmc-border) !important; border-radius: 12px !important; background: #fff !important; }
.notify-row {
    float: left;
    margin: 15px 0 0 28px;
    position: relative;
    z-index: 1002;
}
.notify-row .top-menu {
    align-items: center;
    display: flex;
    gap: 7px;
    margin: 0;
}
.notify-row .top-menu > li { float: none; margin: 0; }
.notify-row .top-menu > li > .dropdown-toggle {
    align-items: center;
    background: #fff !important;
    border: 1px solid var(--ifmc-border) !important;
    border-radius: 10px !important;
    color: var(--ifmc-muted);
    display: flex;
    height: 38px;
    justify-content: center;
    margin: 0;
    padding: 0;
    position: relative;
    width: 38px;
}
.notify-row .top-menu > li > .dropdown-toggle:hover,
.notify-row .top-menu > li.open > .dropdown-toggle {
    background: #edf8f7 !important;
    border-color: #abd7d2 !important;
    color: var(--ifmc-primary) !important;
}
.notify-row .dropdown-toggle .fa { font-size: 15px; line-height: 1; }
.notify-row .badge {
    align-items: center;
    border: 2px solid #fff;
    display: flex;
    font-size: 9px;
    font-weight: 800;
    height: 19px;
    justify-content: center;
    min-width: 19px;
    padding: 0 4px;
    right: -7px;
    top: -8px;
}
.notify-row .dropdown-menu.extended {
    border: 1px solid var(--ifmc-border) !important;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .16) !important;
    margin-top: 7px;
    overflow: hidden;
    top: 38px;
}
.notify-row .dropdown-menu.extended > li > p { margin: 0; padding: 12px 14px; }
.notify-row .dropdown-menu.extended li a { white-space: normal; }

#sidebar {
    background: linear-gradient(180deg, #0f766e 0%, #115e59 100%);
    box-shadow: 8px 0 30px rgba(15,23,42,.08);
}
ul.sidebar-menu { padding-top: 84px; }
ul.sidebar-menu li { margin: 4px 12px; }
ul.sidebar-menu li a {
    background: transparent !important;
    border-radius: 10px;
    color: #e6fffb;
    padding: 12px 14px;
    transition: none;
}
#sidebar ul.sidebar-menu > li > a,
#sidebar ul.sidebar-menu li ul.sub li a { background: transparent !important; }
ul.sidebar-menu li a:hover, ul.sidebar-menu li a:focus,
ul.sidebar-menu li a.active, ul.sidebar-menu li.active > a {
    background: rgba(255,255,255,.16) !important;
    color: #fff !important;
    transform: none;
}

#sidebar ul.sidebar-menu li a,
#sidebar ul.sidebar-menu li a i,
#sidebar ul.sidebar-menu li ul.sub {
    animation: none !important;
    transition: none !important;
}
#sidebar ul.sidebar-menu li a:hover, #sidebar ul.sidebar-menu li a:focus,
#sidebar ul.sidebar-menu li a.active, #sidebar ul.sidebar-menu li.active > a {
    background: rgba(255,255,255,.16) !important;
}
ul.sidebar-menu li a i { color: #ccfbf1; width: 24px; }
ul.sidebar-menu li ul.sub { background: transparent; }
ul.sidebar-menu li ul.sub li { margin: 2px 0 2px 8px; }

#main-content { background: var(--ifmc-bg); flex: 1 0 auto; }
.wrapper { padding: 92px 24px 28px; }
.panel {
    border: 1px solid var(--ifmc-border);
    border-radius: var(--ifmc-radius);
    box-shadow: var(--ifmc-shadow);
    background: var(--ifmc-surface);
    overflow: hidden;
}
.panel-heading {
    background: #fff !important;
    border-bottom: 1px solid var(--ifmc-border) !important;
    color: var(--ifmc-ink) !important;
    font-size: 16px;
    font-weight: 700;
    min-height: 56px;
    padding: 17px 20px;
}
.panel-body { padding: 20px; }

.state-overview .panel { min-height: 116px; transition: transform .18s ease, box-shadow .18s ease; }
.state-overview .panel:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(15,23,42,.11); }
.state-overview .symbol { width: 38%; border-radius: 0; background: var(--ifmc-primary) !important; }
.state-overview .symbol i { font-size: 34px; }
.state-overview .value { width: 62%; padding-top: 22px; }
.state-overview .value h3 { color: var(--ifmc-ink); font-size: 30px; font-weight: 800; }
.state-overview .value p { color: var(--ifmc-muted); font-weight: 600; text-transform: none; }

.btn { border-radius: 9px; font-weight: 600; padding: 8px 14px; transition: all .15s ease; }
.btn-xs { border-radius: 7px; padding: 5px 9px; }
.btn-info, .btn-primary, .detailsbutton, .btn-success {
    background: var(--ifmc-primary) !important;
    border-color: var(--ifmc-primary) !important;
    color: #fff !important;
}
.btn-info:hover, .btn-primary:hover, .detailsbutton:hover, .btn-success:hover {
    background: var(--ifmc-primary-dark) !important;
    border-color: var(--ifmc-primary-dark) !important;
}
.btn-danger { background: #dc2626; border-color: #dc2626; }

.form-control, .select2-container .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid #cfdcdf !important;
    border-radius: 9px !important;
    box-shadow: none !important;
    min-height: 40px;
}
.form-control:focus { border-color: var(--ifmc-accent) !important; box-shadow: 0 0 0 3px rgba(20,184,166,.12) !important; }
label { color: #334155; font-weight: 650; }

.table { margin-bottom: 0; }
.table > thead > tr > th {
    background: #edf5f5;
    border-bottom: 1px solid #d8e5e6;
    color: #334155;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .035em;
    padding: 13px 12px;
    text-transform: uppercase;
}
.table > tbody > tr > td { border-top: 1px solid #edf1f3; padding: 12px; vertical-align: middle; }
.table-striped > tbody > tr:nth-of-type(odd) { background: #fbfdfd; }
.table-hover > tbody > tr:hover { background: #eef8f7; }
.dataTables_wrapper .dataTables_filter { float: right; max-width: 330px; padding-bottom: 10px; width: 100% !important; }
.dataTables_wrapper .dataTables_filter label { display: block; font-size: 0 !important; line-height: 1; margin: 0; width: 100% !important; }
.dataTables_wrapper .dataTables_filter input {
    background: #fff;
    border: 2px solid #b9cccf !important;
    border-radius: 9px;
    box-shadow: 0 2px 7px rgba(15, 23, 42, .06);
    color: #172033;
    float: none !important;
    font-size: 14px !important;
    height: 42px;
    margin: 0 !important;
    min-width: 220px;
    padding: 8px 12px;
    width: 100% !important;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--ifmc-accent) !important; box-shadow: 0 0 0 3px rgba(20,184,166,.14) !important; outline: 0; }
.dataTables_wrapper .dataTables_filter input::placeholder { color: #64748b; opacity: 1; }
.dataTables_wrapper .dataTables_length select { border: 1px solid #cfdcdf; border-radius: 8px; min-width: 100px; padding: 7px 28px 7px 9px; width: auto !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 8px !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--ifmc-primary) !important; border-color: var(--ifmc-primary) !important; color: #fff !important; }

.modal-content { border: 0; border-radius: 16px; box-shadow: 0 24px 70px rgba(15,23,42,.22); overflow: hidden; }
.modal-header { background: #f7fbfb; border-bottom: 1px solid var(--ifmc-border); padding: 18px 22px; }
.modal-title { color: var(--ifmc-ink); font-weight: 750; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--ifmc-border); padding: 15px 22px; }
.alert { border: 0; border-radius: 10px; }
.site-footer {
    background: #fff;
    border-top: 1px solid var(--ifmc-border);
    color: var(--ifmc-muted);
    min-height: 54px;
    padding: 0;
    flex: 0 0 auto;
    transition: margin-left .2s ease;
}
.site-footer .footer-content { align-items: center; display: flex; justify-content: center; min-height: 54px; padding: 10px 22px; }

@media (min-width: 769px) {
    #sidebar { width: 250px; }
    #main-content, .site-footer { margin-left: 250px; }
    .sidebar-closed #main-content, .sidebar-closed .site-footer { margin-left: 0; }
    .sidebar-closed #sidebar { margin-left: -220px; }
}

@media (max-width: 767px) {
    html, body { max-width: 100%; overflow-x: hidden; }
    body.mobile-menu-open { overflow: hidden; }

    .header.white-bg {
        height: 60px;
        min-height: 60px;
        padding: 0 10px;
        position: fixed !important;
    }
    .sidebar-toggle-box {
        float: left;
        margin: 10px 8px 0 0;
        padding: 0;
    }
    .mobile-menu-toggle {
        align-items: center;
        background: var(--ifmc-primary);
        border: 0;
        border-radius: 9px;
        color: #fff;
        display: flex;
        font-size: 18px;
        height: 40px;
        justify-content: center;
        padding: 0;
        width: 42px;
    }
    .mobile-menu-toggle:focus { box-shadow: 0 0 0 3px rgba(20,184,166,.25); outline: 0; }
    .mobile-menu-toggle .fa { color: #fff !important; }

    .dataTables_wrapper .dataTables_filter { float: none; max-width: none; }
    .dataTables_wrapper .dataTables_filter input { min-width: 0; }
    .wrapper { padding: 74px 10px 20px; }
    .header .logo { display: none; }

    #sidebar {
        bottom: 0;
        height: calc(100vh - 60px) !important;
        left: 0;
        margin: 0 !important;
        max-width: 300px;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        position: fixed !important;
        top: 60px;
        transform: translateX(-105%);
        visibility: hidden;
        width: 86vw !important;
        z-index: 1101;
    }
    #container.mobile-nav-open #sidebar { transform: translateX(0); visibility: visible; }
    #sidebar > ul.sidebar-menu { display: block !important; margin: 0 !important; padding: 10px 0 24px !important; }
    #sidebar > ul > li { margin: 3px 10px; }
    #sidebar > ul > li > a { height: auto; min-height: 44px; padding: 5px 12px; }
    #sidebar > ul > li > a > span { line-height: 34px; }
    #sidebar ul.sub { width: 100%; }

    .mobile-sidebar-backdrop {
        background: rgba(15,23,42,.5);
        border: 0;
        bottom: 0;
        display: none;
        left: 0;
        padding: 0;
        position: fixed;
        right: 0;
        top: 60px;
        width: 100%;
        z-index: 1100;
    }
    #container.mobile-nav-open .mobile-sidebar-backdrop { display: block; }

    #main-content, .site-footer { margin-left: 0 !important; }
    #top_menu.notify-row { display: block; margin-left: 4px; max-width: calc(100vw - 118px); width: auto; }
    .notify-row .top-menu { gap: 3px; }
    .notify-row .top-menu > li > .dropdown-toggle { height: 31px; width: 31px; }
    .notify-row .dropdown-toggle .fa { font-size: 13px; }
    .notify-row .badge { font-size: 8px; height: 17px; min-width: 17px; right: -5px; top: -7px; }
    .notify-row .dropdown-menu.extended { left: 0; position: fixed; right: 12px; top: 62px; width: auto !important; }
    .top-nav { margin: 5px 0 0; right: 8px; }
    .top-nav .username { display: none; }
    .top-nav .dropdown-toggle { padding-left: 9px !important; padding-right: 9px !important; }
    .top-nav .dropdown-menu { left: auto; max-width: calc(100vw - 20px); right: 0; }

    .panel { border-radius: 11px; margin-bottom: 14px; }
    .panel-heading { min-height: 50px; padding: 14px; }
    .panel-heading .btn, .panel-heading .pull-right { float: none !important; margin-top: 8px; }
    .panel-body { padding: 12px; }

    .form-horizontal .form-group { margin-left: -6px; margin-right: -6px; }
    .form-control, .select2-container { max-width: 100%; width: 100% !important; }
    textarea.form-control { min-height: 110px; }
    .input-group { width: 100%; }
    .btn { min-height: 40px; white-space: normal; }
    .btn-group { display: flex; flex-wrap: wrap; gap: 5px; }
    .btn-group > .btn { border-radius: 8px !important; flex: 0 1 auto; margin: 0 !important; }

    .table-responsive, .adv-table, .panel-body { -webkit-overflow-scrolling: touch; }
    .table-responsive, .adv-table { overflow-x: auto; width: 100%; }
    .dataTables_wrapper { overflow: visible; width: 100%; }
    .dataTables_wrapper .dataTables_scroll,
    .dataTables_wrapper .dataTables_scrollBody { -webkit-overflow-scrolling: touch; overflow-x: auto !important; }
    .dataTables_wrapper table.dataTable { min-width: 680px; width: 100% !important; }
    .dataTables_wrapper .dataTables_scroll { margin-bottom: 10px; width: 100%; }
    .dataTables_wrapper .dataTables_scrollHead,
    .dataTables_wrapper .dataTables_scrollBody { width: 100% !important; }
    #editable-sample3 { min-width: 1180px !important; }
    #editable-sample { min-width: 760px !important; }

    /* Keep row actions available while the data columns scroll underneath. */
    .dataTables_scrollHead table.dataTable th:last-child,
    .dataTables_scrollBody table.dataTable td:last-child {
        background: #fff !important;
        box-shadow: -7px 0 12px rgba(15,23,42,.09);
        position: sticky;
        right: 0;
        white-space: nowrap;
        z-index: 3;
    }
    .dataTables_scrollHead table.dataTable th:last-child { background: #edf5f5 !important; z-index: 4; }
    .dataTables_scrollBody table.dataTable td:last-child .btn {
        align-items: center;
        display: inline-flex;
        margin: 2px;
        min-height: 34px;
        padding: 6px 8px;
    }
    .dataTables_wrapper .row { margin-left: 0; margin-right: 0; }
    .dataTables_wrapper .row > [class*="col-"] { padding-left: 0; padding-right: 0; width: 100%; }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate { float: none !important; margin: 0 0 10px; text-align: left !important; width: 100%; }
    .dataTables_wrapper .dataTables_length label { align-items: center; display: flex; gap: 8px; }
    .dataTables_wrapper .dataTables_paginate { overflow-x: auto; padding-bottom: 4px; white-space: nowrap; }
    .dataTables_wrapper .dt-buttons { display: flex; float: none; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; width: 100%; }
    .custom_buttons .dt-buttons { display: flex; float: none; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; width: 100%; }
    .custom_buttons .dt-button { flex: 1 1 calc(50% - 6px); margin: 0 !important; min-height: 40px; }

    /* Finance and Lab records become complete labelled cards on phones. */
    .dataTables_wrapper table.ifmc-mobile-card-table,
    .dataTables_wrapper table.ifmc-mobile-card-table tbody {
        display: block !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    #editable-sample3.ifmc-mobile-card-table,
    #editable-sample.ifmc-mobile-card-table { min-width: 0 !important; }
    .dataTables_wrapper table.ifmc-mobile-card-table thead {
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        height: 1px;
        overflow: hidden;
        position: absolute;
        white-space: nowrap;
        width: 1px;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody tr {
        background: #fff !important;
        border: 1px solid #dce7e9;
        border-radius: 12px;
        box-shadow: 0 4px 14px rgba(15,23,42,.06);
        display: block !important;
        margin: 0 0 12px;
        overflow: hidden;
        width: 100% !important;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td {
        align-items: start;
        background: #fff !important;
        border: 0 !important;
        border-bottom: 1px solid #edf2f3 !important;
        box-sizing: border-box;
        display: grid !important;
        font-size: 13px;
        gap: 10px;
        grid-template-columns: minmax(105px, 38%) minmax(0, 1fr);
        line-height: 1.4;
        min-height: 42px;
        overflow-wrap: anywhere;
        padding: 10px 12px !important;
        text-align: left !important;
        white-space: normal !important;
        width: 100% !important;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td::before {
        color: #52616f;
        content: attr(data-label);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .025em;
        text-transform: uppercase;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td:last-child {
        background: #f5faf9 !important;
        border-bottom: 0 !important;
        box-shadow: none;
        display: block !important;
        position: static;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td:last-child::before {
        display: block;
        margin-bottom: 7px;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td:last-child .btn {
        display: inline-flex;
        margin: 3px 3px 3px 0;
        min-height: 36px;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td.dataTables_empty {
        display: block !important;
        padding: 18px !important;
        text-align: center !important;
    }
    .dataTables_wrapper table.ifmc-mobile-card-table tbody td.dataTables_empty::before { display: none; }

    .ms-container { width: 100% !important; }
    .ms-container .ms-selectable, .ms-container .ms-selection { float: none; margin-bottom: 12px; width: 100% !important; }
    .ms-container .search-input { box-sizing: border-box; width: 100% !important; }

    .modal-dialog { margin: 10px; width: auto; }
    .modal-header, .modal-body, .modal-footer { padding-left: 14px; padding-right: 14px; }
    .modal-footer .btn { margin: 4px 0 4px 5px; }

    .fc-header td { display: block; text-align: center !important; width: 100%; }
    .fc-header-right { left: auto !important; position: static !important; }
    .fc-content { margin-top: 12px !important; }
    .fc-header-title h2 { font-size: 16px !important; line-height: 28px !important; }

    .site-footer .footer-content { padding: 10px 14px; }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .notify-row { margin-left: 12px; }
    .notify-row .top-menu { gap: 5px; }
    .quickFindDiv { display: none; }
}

@media print {
    @page { size: A4 portrait; margin: 12mm; }
    .header, #sidebar, .site-footer, .btn, .dataTables_filter, .dataTables_length, .dataTables_paginate { display: none !important; }
    #main-content { margin-left: 0 !important; }
    .wrapper { padding: 0; }
    .panel { border: 0; box-shadow: none; }
    table { page-break-inside: auto; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
    tr { page-break-inside: avoid; page-break-after: auto; }
    h1, h2, h3, h4 { page-break-after: avoid; }
}

body.login-body {
    align-items: center;
    background:
        radial-gradient(circle at 12% 18%, rgba(20,184,166,.20), transparent 34%),
        radial-gradient(circle at 88% 80%, rgba(15,118,110,.16), transparent 32%),
        linear-gradient(145deg, #ecf8f6 0%, #f7fafc 52%, #e7f3f4 100%);
    display: flex;
    min-height: 100vh;
    padding: 28px 0;
}
.login-body .container { width: 100%; }
.login-body .form-signin.ifmc-login-card {
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(15,42,45,.16);
    margin: 0 auto;
    max-width: 430px;
    overflow: hidden;
}
.login-body .form-signin-heading {
    align-items: center;
    background: linear-gradient(135deg, #0f766e, #134e4a) !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 34px 30px 28px;
}
.login-body .form-signin-heading img {
    background: #fff;
    border: 4px solid rgba(255,255,255,.3);
    border-radius: 18px;
    height: 70px;
    object-fit: contain;
    padding: 8px;
    width: 70px;
}
.login-body .form-signin-heading span { color: #fff; font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.login-body .form-signin-heading small { color: #c9f5ef; font-size: 13px; font-weight: 500; }
.login-body .login-wrap { padding: 28px 32px 32px; }
.login-body .login-wrap label { display: block; margin: 13px 0 7px; }
.login-body .login-wrap .form-control { margin-bottom: 0; }
.login-body .forgot-link { margin: 14px 0 20px; text-align: right; }
.login-body .btn-login { background: var(--ifmc-primary) !important; border: 0; border-radius: 10px; color: #fff; font-size: 15px; padding: 12px; }
.login-body #infoMessage:empty { display: none; }
.login-body #infoMessage:not(:empty) { margin: 20px 32px 0; }
