:root {
    --msgrid-border-color: #dee2e6;
    --msgrid-freeze-border: #00676b;
    --msgrid-header-bg: #00676b;
    --msgrid-header-color: #ffffff;
    --msgrid-header-border: rgba(255, 255, 255, 0.2);
    --msgrid-alt-row-bg: #f9f9f9;
    --msgrid-hover-bg: #eaf3f3;
    --msgrid-selected-bg: #FFF6DE;
    --msgrid-selected-color: #000000;
    --msgrid-footer-bg: #f8f9fa;
    --msgrid-font-size: 13px;
}

/* Container */
.msgrid-container {
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: calc(100vh - 245px);
    min-height: 0;
    border: 1px solid var(--msgrid-border-color);
    background-color: #ffffff;
    font-size: var(--msgrid-font-size);
    overflow: hidden !important;
}

/* Scrollable Content */
.msgrid-content {
    flex: 1 1 0px !important;
    min-height: 0 !important;
    width: 100%;
    overflow-y: auto !important;
    overflow-x: auto !important;
    position: relative;
    outline: none;
    -webkit-overflow-scrolling: touch;
}

/* Table */
.msgrid-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0 !important;
    background-color: #ffffff;
    font-size: var(--msgrid-font-size);
}

/* Override Bootstrap 5 table styles */
.msgrid-table.table {
    margin-bottom: 0 !important;
}

.msgrid-table.table > :not(caption) > * > * {
    padding: 2px 5px !important;
    box-shadow: none !important;
    border-color: var(--msgrid-border-color) !important;
}

/* Cells Base */
.msgrid-th,
.msgrid-td {
    box-sizing: border-box;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.msgrid-td {
    padding: 2px 5px !important;
    border-bottom: 1px solid var(--msgrid-border-color);
    border-right: 1px solid var(--msgrid-border-color);
    background-color: #ffffff;
    color: #212529;
}

/* Header */
.msgrid-thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.msgrid-table.table > thead > tr:not(.msgrid-filter-tr) > th,
.msgrid-th:not(.msgrid-filter-th) {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--msgrid-header-bg) !important;
    color: var(--msgrid-header-color) !important;
    font-weight: 600;
    font-size: 13px;
    user-select: none;
    padding: 0 4px !important;
    height: 36px;
    min-height: 36px;
    box-sizing: border-box;
    border-bottom: 1px solid #004d50 !important;
    border-right: 1px solid var(--msgrid-header-border) !important;
    border-top: none !important;
    border-left: none !important;
    cursor: pointer;
    vertical-align: middle;
}

.msgrid-header-cell {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 36px;
    height: auto;
    padding: 4px 2px;
    box-sizing: border-box;
}

.msgrid-header-text {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre-line;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
    color: #ffffff !important;
}

.msgrid-sort-icon {
    flex: 0 0 auto;
    margin-left: 4px;
    font-size: 10px;
    color: #ffffff;
}

/* Stacked Header */
.msgrid-stacked-header-cell {
    height: 32px !important;
    min-height: 32px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;
    text-align: center !important;
}

.msgrid-stacked-header-cell-inner {
    justify-content: center !important;
    min-height: 32px !important;
    height: 32px !important;
    padding: 2px 4px !important;
}

.msgrid-table.table > thead > tr.msgrid-stacked-sub-row > th,
.msgrid-table > thead > tr.msgrid-stacked-sub-row > th {
    top: 32px !important;
    height: 36px !important;
    min-height: 36px !important;
}

.msgrid-table.table > thead > tr > th[rowspan="2"] > .msgrid-header-cell,
.msgrid-table > thead > tr > th[rowspan="2"] > .msgrid-header-cell {
    min-height: 68px !important;
    height: 100% !important;
}

.msgrid-has-stacked-header .msgrid-table.table > thead > tr.msgrid-filter-tr > th,
.msgrid-has-stacked-header .msgrid-table.table > thead > tr > th.msgrid-filter-th,
.msgrid-has-stacked-header .msgrid-filter-tr th,
.msgrid-has-stacked-header .msgrid-filter-th {
    top: 68px !important;
}

/* Filter Row */
.msgrid-table.table > thead > tr.msgrid-filter-tr > th,
.msgrid-table.table > thead > tr > th.msgrid-filter-th,
.msgrid-table > thead > tr.msgrid-filter-tr > th,
.msgrid-table > thead > tr > th.msgrid-filter-th,
.msgrid-filter-tr th,
.msgrid-filter-th {
    position: sticky;
    top: 36px;
    z-index: 9;
    background-color: var(--msgrid-hover-bg, #eaf3f3) !important;
    color: #1f2937 !important;
    padding: 2px 4px !important;
    border-bottom: 1px solid var(--msgrid-border-color) !important;
    border-right: 1px solid var(--msgrid-border-color) !important;
    border-top: none !important;
    border-left: none !important;
    height: 28px;
    cursor: default !important;
}

.msgrid-filter-cell {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.msgrid-filter-search-icon {
    position: absolute;
    left: 5px;
    font-size: 11px;
    color: #94a3b8;
    pointer-events: none;
    z-index: 1;
}

.msgrid-filter-cell:focus-within .msgrid-filter-search-icon {
    color: #00676b;
}

.msgrid-filter-input {
    width: 100%;
    height: 22px;
    padding: 1px 18px 1px 20px;
    font-size: 12px;
    border: 1px solid #ced4da;
    border-radius: 2px;
    outline: none;
    background-color: #ffffff;
    box-sizing: border-box;
}

.msgrid-filter-input:focus {
    border-color: #00676b;
    box-shadow: 0 0 0 1px #00676b;
}

.msgrid-filter-clear {
    position: absolute;
    right: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 2px;
    font-size: 11px;
    line-height: 1;
    z-index: 1;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.msgrid-filter-clear:hover {
    color: #ef4444;
    background-color: #fee2e2;
}

.msgrid-filter-clear i {
    font-size: 10px;
    font-weight: bold;
}

/* Rows Base */
.msgrid-row {
    background-color: #ffffff;
    transition: background-color 0.05s ease-in-out;
}

/* Text Wrapping */
.msgrid-text-nowrap .msgrid-td {
    white-space: nowrap;
}

.msgrid-text-wrap .msgrid-td {
    white-space: normal;
    word-break: break-word;
}

/* Alternating Rows (Alt Row) */
.msgrid-alt-row tbody tr.msgrid-row-alt > td,
.msgrid-alt-row tbody tr.e-altrow > td,
.msgrid-alt-row tbody tr.msgrid-row:nth-child(even) > td,
.msgrid-row.msgrid-row-alt > td,
.msgrid-row.e-altrow > td {
    background-color: var(--msgrid-alt-row-bg) !important;
}

/* Hover Row */
.msgrid-enable-hover tbody tr.msgrid-row:not(.msgrid-selected):hover > td,
.msgrid-enable-hover tbody tr.msgrid-row:not(.e-active):hover > td {
    background-color: var(--msgrid-hover-bg) !important;
    cursor: pointer;
}

/* Selected Row (Active) - Primary Yellow #FFF6DE */
.msgrid-row.msgrid-selected,
.msgrid-row.e-active,
.msgrid-table.table > tbody > tr.msgrid-selected > td,
.msgrid-table.table > tbody > tr.e-active > td,
.msgrid-table.table > tbody > tr > td.msgrid-selected-cell,
.msgrid-table.table > tbody > tr > td.e-active,
.msgrid-alt-row tbody tr.msgrid-row.msgrid-selected:nth-child(even) > td,
.msgrid-alt-row tbody tr.msgrid-row.e-active:nth-child(even) > td {
    background-color: var(--msgrid-selected-bg) !important;
    color: var(--msgrid-selected-color) !important;
    box-shadow: none !important;
}

/* Footer / Aggregates - Fixed Bottom */
.msgrid-footer-wrapper {
    flex: 0 0 auto !important;
    width: 100%;
    overflow: hidden;
    background-color: var(--msgrid-footer-bg);
    border-top: 1px solid var(--msgrid-border-color);
    box-sizing: border-box;
    position: relative;
    z-index: 5;
}

.msgrid-footer-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0 !important;
    background-color: var(--msgrid-footer-bg);
    font-size: var(--msgrid-font-size);
}

.msgrid-footer {
    background-color: var(--msgrid-footer-bg);
    font-weight: bold;
}

.msgrid-table.table > tfoot > tr > td,
.msgrid-footer-table td,
.msgrid-footer .msgrid-td,
.msgrid-footer .e-summarycell {
    background-color: var(--msgrid-footer-bg) !important;
    border-bottom: none !important;
    border-top: none !important;
    border-right: 1px solid var(--msgrid-border-color) !important;
    border-left: none !important;
    font-size: 13px;
    font-weight: bold;
    color: #000000 !important;
    padding: 4px 5px !important;
    line-height: 1.4;
    vertical-align: middle;
}

/* Alignment */
.msgrid-text-left { text-align: left !important; }
.msgrid-text-center { text-align: center !important; }
.msgrid-text-right { text-align: right !important; }

.msgrid-header-center .msgrid-header-cell { justify-content: center; text-align: center; }
.msgrid-header-right .msgrid-header-cell { justify-content: flex-end; text-align: right; }
.msgrid-header-left .msgrid-header-cell { justify-content: flex-start; text-align: left; }

/* GridLines */
.msgrid-gridlines-horizontal .msgrid-td,
.msgrid-gridlines-horizontal .msgrid-th {
    border-right: none !important;
}

.msgrid-gridlines-vertical .msgrid-td {
    border-bottom: none !important;
}

.msgrid-gridlines-none .msgrid-td,
.msgrid-gridlines-none .msgrid-th {
    border: none !important;
}

/* Freeze Columns (Sticky) */
.msgrid-freeze-left,
.msgrid-freeze-right,
.msgrid-table.table > tbody > tr > td.msgrid-freeze-left,
.msgrid-table.table > tbody > tr > td.msgrid-freeze-right,
.msgrid-td.msgrid-freeze-left,
.msgrid-td.msgrid-freeze-right {
    position: sticky !important;
    z-index: 4 !important;
    background-color: #ffffff !important;
}

/* Frozen columns on alt row */
.msgrid-table.table > tbody > tr.msgrid-row-alt > td.msgrid-freeze-left,
.msgrid-table.table > tbody > tr.msgrid-row-alt > td.msgrid-freeze-right,
.msgrid-table.table > tbody > tr.e-altrow > td.msgrid-freeze-left,
.msgrid-table.table > tbody > tr.e-altrow > td.msgrid-freeze-right,
.msgrid-alt-row tbody tr:nth-child(even) > td.msgrid-freeze-left,
.msgrid-alt-row tbody tr:nth-child(even) > td.msgrid-freeze-right,
.msgrid-row.msgrid-row-alt .msgrid-freeze-left,
.msgrid-row.msgrid-row-alt .msgrid-freeze-right,
.msgrid-alt-row tbody tr:nth-child(even) .msgrid-freeze-left,
.msgrid-alt-row tbody tr:nth-child(even) .msgrid-freeze-right {
    background-color: var(--msgrid-alt-row-bg) !important;
}

/* Frozen columns on hover */
.msgrid-enable-hover tbody tr.msgrid-row:not(.msgrid-selected):hover > td.msgrid-freeze-left,
.msgrid-enable-hover tbody tr.msgrid-row:not(.msgrid-selected):hover > td.msgrid-freeze-right,
.msgrid-enable-hover tbody tr:not(.msgrid-selected):hover > td.msgrid-freeze-left,
.msgrid-enable-hover tbody tr:not(.msgrid-selected):hover > td.msgrid-freeze-right,
.msgrid-enable-hover tbody tr.msgrid-row:not(.msgrid-selected):hover .msgrid-freeze-left,
.msgrid-enable-hover tbody tr.msgrid-row:not(.msgrid-selected):hover .msgrid-freeze-right {
    background-color: var(--msgrid-hover-bg) !important;
}

/* Frozen columns on selected */
.msgrid-table.table > tbody > tr.msgrid-selected > td.msgrid-freeze-left,
.msgrid-table.table > tbody > tr.msgrid-selected > td.msgrid-freeze-right,
.msgrid-table.table > tbody > tr.e-active > td.msgrid-freeze-left,
.msgrid-table.table > tbody > tr.e-active > td.msgrid-freeze-right,
.msgrid-row.msgrid-selected .msgrid-freeze-left,
.msgrid-row.msgrid-selected .msgrid-freeze-right,
.msgrid-row.e-active .msgrid-freeze-left,
.msgrid-row.e-active .msgrid-freeze-right,
.msgrid-freeze-left.msgrid-selected-cell,
.msgrid-freeze-right.msgrid-selected-cell,
.msgrid-freeze-left.e-active,
.msgrid-freeze-right.e-active {
    background-color: var(--msgrid-selected-bg) !important;
    color: var(--msgrid-selected-color) !important;
}

/* Elevation for Header / Footer Freeze Intersections */
.msgrid-table.table > thead > tr:not(.msgrid-filter-tr) > th.msgrid-freeze-left,
.msgrid-table.table > thead > tr:not(.msgrid-filter-tr) > th.msgrid-freeze-right,
.msgrid-th:not(.msgrid-filter-th).msgrid-freeze-left,
.msgrid-th:not(.msgrid-filter-th).msgrid-freeze-right {
    z-index: 15 !important;
    background-color: var(--msgrid-header-bg) !important;
    color: var(--msgrid-header-color) !important;
}

.msgrid-table.table > thead > tr.msgrid-filter-tr > th.msgrid-freeze-left,
.msgrid-table.table > thead > tr.msgrid-filter-tr > th.msgrid-freeze-right,
.msgrid-table.table > thead > tr > th.msgrid-filter-th.msgrid-freeze-left,
.msgrid-table.table > thead > tr > th.msgrid-filter-th.msgrid-freeze-right,
.msgrid-table > thead > tr.msgrid-filter-tr > th.msgrid-freeze-left,
.msgrid-table > thead > tr.msgrid-filter-tr > th.msgrid-freeze-right,
.msgrid-filter-tr th.msgrid-freeze-left,
.msgrid-filter-tr th.msgrid-freeze-right,
.msgrid-filter-th.msgrid-freeze-left,
.msgrid-filter-th.msgrid-freeze-right {
    z-index: 14 !important;
    background-color: var(--msgrid-hover-bg, #eaf3f3) !important;
}

.msgrid-table.table > tfoot > tr > td.msgrid-freeze-left,
.msgrid-table.table > tfoot > tr > td.msgrid-freeze-right,
.msgrid-footer .msgrid-freeze-left,
.msgrid-footer .msgrid-freeze-right {
    z-index: 15 !important;
    background-color: var(--msgrid-footer-bg) !important;
}

/* Border & shadow dividers to highlight frozen column boundaries */
.msgrid-table.table > thead > tr:not(.msgrid-filter-tr) > th.msgrid-freeze-left-edge,
.msgrid-th:not(.msgrid-filter-th).msgrid-freeze-left-edge {
    border-right: 2px solid rgba(0, 0, 0, 0.3) !important;
}

.msgrid-table.table > thead > tr.msgrid-filter-tr > th.msgrid-freeze-left-edge,
.msgrid-table.table > thead > tr > th.msgrid-filter-th.msgrid-freeze-left-edge,
.msgrid-filter-tr th.msgrid-freeze-left-edge,
.msgrid-filter-th.msgrid-freeze-left-edge {
    border-right: 2px solid var(--msgrid-freeze-border) !important;
}

.msgrid-table.table > tbody > tr > td.msgrid-freeze-left-edge,
.msgrid-td.msgrid-freeze-left-edge,
.msgrid-freeze-left-edge {
    border-right: 2px solid var(--msgrid-freeze-border) !important;
}

.msgrid-table.table > tfoot > tr > td.msgrid-freeze-left-edge,
.msgrid-footer .msgrid-freeze-left-edge,
.msgrid-group-footer-row td.msgrid-freeze-left-edge {
    border-right: 2px solid var(--msgrid-freeze-border) !important;
}

.msgrid-table.table > thead > tr:not(.msgrid-filter-tr) > th.msgrid-freeze-right-edge,
.msgrid-th:not(.msgrid-filter-th).msgrid-freeze-right-edge {
    border-left: 2px solid rgba(0, 0, 0, 0.3) !important;
}

.msgrid-table.table > thead > tr.msgrid-filter-tr > th.msgrid-freeze-right-edge,
.msgrid-table.table > thead > tr > th.msgrid-filter-th.msgrid-freeze-right-edge,
.msgrid-filter-tr th.msgrid-freeze-right-edge,
.msgrid-filter-th.msgrid-freeze-right-edge {
    border-left: 2px solid var(--msgrid-freeze-border) !important;
}

.msgrid-table.table > tbody > tr > td.msgrid-freeze-right-edge,
.msgrid-td.msgrid-freeze-right-edge,
.msgrid-freeze-right-edge {
    border-left: 2px solid var(--msgrid-freeze-border) !important;
}

.msgrid-table.table > tfoot > tr > td.msgrid-freeze-right-edge,
.msgrid-footer .msgrid-freeze-right-edge,
.msgrid-group-footer-row td.msgrid-freeze-right-edge {
    border-left: 2px solid var(--msgrid-freeze-border) !important;
}

/* Shadow indicator on edge of frozen column when scrolled */
.msgrid-freeze-left-edge {
    box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.2) !important;
}

.msgrid-freeze-right-edge {
    box-shadow: -3px 0 6px -2px rgba(0, 0, 0, 0.2) !important;
}

/* Pager (Syncfusion theme matching) */
.msgrid-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background-color: #f8f9fa;
    border-top: 1px solid var(--msgrid-border-color);
    font-size: 12px;
    user-select: none;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
}

.msgrid-pager-nav {
    display: flex;
    align-items: center;
    gap: 3px;
}

.msgrid-pager-btn {
    min-width: 26px;
    height: 24px;
    padding: 0 6px;
    font-size: 12px;
    border: 1px solid #ced4da;
    background-color: #ffffff;
    color: #333333;
    border-radius: 2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease-in-out;
}

.msgrid-pager-btn:hover:not(:disabled) {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.msgrid-pager-btn.msgrid-pager-active {
    background-color: #00676b !important;
    border-color: #00676b !important;
    color: #ffffff !important;
    font-weight: 600;
}

.msgrid-pager-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #ffffff;
}

.msgrid-pager-size-select {
    height: 24px;
    padding: 0 4px;
    font-size: 12px;
    border: 1px solid #ced4da;
    border-radius: 2px;
    background-color: #ffffff;
    outline: none;
}

.msgrid-pager-size-select:focus {
    border-color: #00676b;
}

.msgrid-pager-info {
    color: #6c757d;
}

/* Empty data row */
.msgrid-empty-record {
    text-align: center;
    padding: 24px;
    color: #6c757d;
    font-style: italic;
}

/* Grouping Styles */
.msgrid-group-drop-area {
    padding: 5px 10px;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--msgrid-border-color);
    font-size: 12px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.msgrid-group-drop-area.msgrid-group-drop-active {
    background-color: #e6f4f4 !important;
    border: 2px dashed #00676b !important;
}

.msgrid-group-placeholder {
    color: #6c757d;
    font-style: italic;
}

.msgrid-group-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-size: 11px;
    background-color: #ffffff !important;
    border: 1px solid #ced4da;
    border-radius: 2px;
}

.msgrid-group-row {
    background-color: #f0f7f7 !important;
    color: #00676b !important;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.msgrid-group-row:hover {
    background-color: #e2f0f0 !important;
}

.msgrid-group-row .msgrid-td {
    border-bottom: 1px solid var(--msgrid-border-color);
    background-color: #f0f7f7 !important;
    color: #00676b !important;
}

.msgrid-group-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 4px;
    font-size: 10px;
    color: #00676b;
}

/* Group Footer (Dòng tổng nhóm bên dưới) */
.msgrid-group-footer-row {
    background-color: #f7fafc !important;
}

.msgrid-group-footer-row .msgrid-td,
.msgrid-group-footer-row .e-summarycell,
.msgrid-group-footer-cell {
    background-color: #f7fafc !important;
    border-top: 1px solid var(--msgrid-border-color) !important;
    border-bottom: 2px solid var(--msgrid-border-color) !important;
    font-size: 13px;
    font-weight: 600;
    color: #000000 !important;
}

.msgrid-group-footer-label {
    font-weight: 600;
    color: #00676b;
}

/* Column Resizing */
.msgrid-th {
    position: sticky;
}

.msgrid-resizer {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 25;
}

.msgrid-resizer:hover,
.msgrid-resizer.is-resizing {
    background-color: #00adb5;
}

/* Checkbox Column */
.msgrid-checkbox {
    cursor: pointer;
    width: 15px;
    height: 15px;
    margin: 0;
    vertical-align: middle;
    accent-color: #00676b;
}

.msgrid-td .msgrid-checkbox,
.msgrid-th .msgrid-checkbox {
    display: inline-block;
}

