:root { --sidebar-width: 250px; --header-height: 64px; }
* { box-sizing: border-box; }
body { margin: 0; background: #f4f6f9; color: #263238; font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eef4ff, #f8fafc); }
.login-box { width: 100%; max-width: 420px; }
.login-captcha { display: flex; align-items: stretch; gap: 10px; }
.login-captcha img { flex: 0 0 180px; border-radius: 6px; background: #f4f7fc; }
.login-captcha .btn { flex: 1 1 auto; white-space: nowrap; }
.app-shell { width: 100%; height: 100vh; overflow: hidden; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: var(--header-height) minmax(0, 1fr) auto; grid-template-areas: "sidebar header" "sidebar content" "sidebar footer"; }
.app-sidebar { grid-area: sidebar; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: #172033; color: #fff; }
.brand { flex: 0 0 var(--header-height); height: var(--header-height); display: flex; align-items: center; gap: 10px; padding: 0 20px; color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: #2563eb; }
.app-sidebar nav { min-height: 0; flex: 1 1 auto; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #53627a transparent; }
.app-sidebar .nav-link { color: #dbe5f5; padding: 11px 14px; border-radius: 8px; }
.app-sidebar .nav-link.active, .app-sidebar .nav-link:hover { color: #fff; background: #2563eb; }
.sidebar-label { margin: 24px 14px 8px; color: #8390a7; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
/* Sidebar accordion: menu ngắn hơn, chỉ mở nhóm đang làm việc. */
.sidebar-group { margin-top: 8px; }
.sidebar-group > summary { list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; padding: 10px 14px; border-radius: 8px; color: #9eabc0; font-size: .76rem; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary::after { content: "\F285"; font-family: bootstrap-icons; margin-left: auto; font-size: .8rem; transition: transform .18s ease; }
.sidebar-group[open] > summary::after { transform: rotate(90deg); }
.sidebar-group > summary:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-group-items { padding: 2px 0 4px 8px; }
.sidebar-group-items .nav-link { padding-top: 9px; padding-bottom: 9px; font-size: .93rem; }

.app-header { grid-area: header; position: relative; z-index: 10; min-width: 0; background: #fff; border-bottom: 1px solid #e7ebf0; box-shadow: 0 1px 3px rgba(15,23,42,.04); }
.navbar-menu { position: relative; }
.navbar-menu > summary { list-style: none; }
.navbar-menu > summary::-webkit-details-marker { display: none; }
.navbar-menu-panel { position: absolute; z-index: 1100; top: calc(100% + 8px); right: 0; overflow: hidden; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 12px 30px rgba(15,23,42,.16); }
.notification-panel { width: min(390px, calc(100vw - 32px)); }
.account-panel { width: 190px; padding: 6px; }
.account-panel a,.account-panel button { display: block; width: 100%; padding: 9px 10px; color: #263238; text-align: left; text-decoration: none; background: transparent; border: 0; border-radius: 6px; }
.account-panel form { margin: 0; border-top: 1px solid #eef1f4; }
.account-panel a:hover,.account-panel button:hover { background: #eef4ff; color: #0d6efd; }
.notification-count { position: absolute; top: -7px; right: -8px; min-width: 19px; height: 19px; padding: 0 5px; color: #fff; background: #dc3545; border: 2px solid #fff; border-radius: 10px; font-size: .68rem; font-weight: 700; line-height: 15px; }
.pagination .page-link { color: #cf202b; }
.pagination .page-item.active .page-link { color: #fff; background-color: #cf202b; border-color: #cf202b; }
.notification-item { display: flex; gap: 10px; padding: 11px 14px; color: #263238; text-decoration: none; border-bottom: 1px solid #eef1f4; }
.notification-item:hover { background: #f8fafc; }
.notification-item strong,.notification-item small { display: block; }
.notification-item small { margin-top: 3px; color: #6c757d; }
.notification-icon { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.notification-table th:first-child { width: 48px; }
.notification-table th:nth-child(2) { width: 64px; }
.notification-table th:nth-child(3) { min-width: 120px; }
.notification-table th:nth-child(4) { min-width: 260px; }
.notification-table th:nth-child(5) { min-width: 330px; }
.notification-table th:nth-child(6) { width: 155px; }
.notification-table th:nth-child(7) { width: 105px; }
.notification-table th:last-child { width: 90px; }
.app-content { grid-area: content; min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 28px; scrollbar-gutter: stable; }
.app-footer { grid-area: footer; position: relative; z-index: 10; display: flex; min-width: 0; background: #fff; border-top: 1px solid #e7ebf0; color: #6c757d; font-size: .875rem; }
.feature-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: #e8f0ff; color: #2563eb; font-size: 1.5rem; }

/* Căn giữa nội dung của tất cả ô trong bảng theo chiều dọc. */
.table > :not(caption) > * > * { vertical-align: middle; }

/* Badge dùng inline-flex để chữ luôn nằm chính giữa khung màu. */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 5px 10px;
    line-height: 1;
    vertical-align: middle;
    white-space: nowrap;
}

.permission-group { overflow: hidden; }
.permission-group-header .form-check-input, .permission-option .form-check-input { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; }
.permission-option { cursor: pointer; transition: background-color .15s ease; }
.permission-option:hover { background: #f8fafc; }
.permission-option code { font-size: .78rem; }
.file-manager-card { height: calc(100vh - 185px); min-height: 520px; overflow: hidden; }
.file-manager-card .card-body { height: 100%; }
#elfinder { width: 100%; height: 100%; }
#elfinder .elfinder { height: 100% !important; border: 0; border-radius: 0; }
#elfinder .elfinder-workzone { height: calc(100% - 70px) !important; }
.category-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 6px; border: 1px solid #dee2e6; }
.category-media-column { min-width: 0; }
.category-media-column .card { overflow: hidden; }
.category-preview { width: 100%; height: 230px; min-width: 0; display: grid; place-items: center; overflow: hidden; background: #eef1f4; border: 1px dashed #cbd3dc; }
.category-preview.is-processing,
.extra-image-item.is-processing { position: relative; }
.category-preview.is-processing::before,
.extra-image-item.is-processing::before { content: ''; position: absolute; inset: 0; z-index: 4; background: rgba(255, 255, 255, .78); }
.category-preview.is-processing::after,
.extra-image-item.is-processing::after { content: ''; position: absolute; z-index: 5; top: calc(50% - 15px); left: calc(50% - 15px); width: 30px; height: 30px; border: 3px solid #cbd5e1; border-top-color: #0d6efd; border-radius: 50%; animation: product-image-spin .7s linear infinite; }
.extra-image-item.is-processing::after { width: 24px; height: 24px; top: calc(50% - 12px); left: calc(50% - 12px); }
@keyframes product-image-spin { to { transform: rotate(360deg); } }
.product-upload-status { position: sticky; top: 8px; z-index: 1030; box-shadow: 0 8px 24px rgba(15, 23, 42, .14); }
.product-upload-status .progress { height: 8px; background: rgba(13, 110, 253, .12); }
#product-form.is-uploading .product-form-card { pointer-events: none; opacity: .92; }
.category-preview img { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 230px; object-fit: contain; background: #fff; }
.category-preview-empty { color: #98a2b3; text-align: center; }
.category-action { min-width: 38px; }
.file-picker-page { width: 100vw; height: 100vh; overflow: hidden; background: #f4f6f9; }
.file-picker-shell { width: 100%; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.file-picker-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; background: #fff; border-bottom: 1px solid #dee2e6; }
.file-picker-content { min-width: 0; min-height: 0; overflow: hidden; padding: 12px; }
.file-picker-content #elfinder { width: 100%; height: 100%; }
.file-picker-content #elfinder .elfinder { height: 100% !important; }
.file-picker-content #elfinder .elfinder-workzone { height: calc(100% - 70px) !important; }
.product-table th:first-child { width: 48px; }
.product-table th:nth-child(2) { width: 64px; }
.product-table th:nth-child(3) { width: 82px; }
.product-table th:nth-child(6) { width: 130px; }
.product-table th:nth-child(7) { width: 250px; }
.product-table th:last-child { width: 145px; }
.product-form-card > .card-header .nav-link { border-radius: 0; padding: 14px 18px; color: #263238; }
.product-form-card > .card-header .nav-link.active { color: #dc3545; border-color: transparent transparent #dc3545; background: transparent; }
.warehouse-box { min-width: 0; padding: 20px; border: 1px solid #dfe3e8; border-radius: 8px; background: #fff; }
.warehouse-box legend { float: none; width: auto; margin: 0 0 4px; padding: 0 8px; color: #243247; font-size: 1rem; font-weight: 600; }
.warehouse-box .form-label { margin-bottom: 6px; font-weight: 500; }
.warehouse-box .form-control { font-variant-numeric: tabular-nums; }
.attribute-group { width: 100%; max-width: none; margin-inline: 0; }
.product-price-row { max-width: none; }
.product-side-column { min-width: 0; }
.product-side-column .card { overflow: hidden; }
.extra-image-item { position: relative; width: 104px; height: 104px; padding: 6px; border: 1px dashed #c2185b; border-radius: 0; }
.extra-image-item[draggable="true"] { cursor: grab; }
.extra-image-item.is-dragging { opacity: .45; cursor: grabbing; }
.extra-image-item img { width: 100%; height: 100%; object-fit: contain; }
.extra-image-placeholder { min-width: 0; flex: 1; color: #6c757d; font-size: .875rem; }
.extra-image-actions { position: absolute; top: 2px; left: -24px; display: grid; gap: 2px; }
.extra-image-actions .btn { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: #111; }
#extra-images { min-height: 138px; display: flex !important; flex-wrap: wrap; align-items: center; justify-content: center; gap: 88px !important; padding: 16px 40px; border: 2px dotted #c2185b; }
.crop-stage { height: 440px; background: #777; }
.crop-stage img { display: block; max-width: 100%; max-height: 100%; }
.input-group > .choices { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }
.choices__inner { min-height: 38px; background: #fff; border-color: #dee2e6; }
.variant-table th:first-child { min-width: 150px; }
.variant-table th:not(:first-child) { min-width: 180px; }
.variant-table .form-control { min-width: 140px; }
.product-flags .form-check-input { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; }
.tox-tinymce { border-radius: 6px !important; }
.customer-table th:first-child { width: 48px; }
.customer-table th:nth-child(2) { width: 64px; }
.customer-table th:nth-child(6) { width: 150px; }
.customer-table th:nth-child(7) { width: 170px; }
.customer-table th:nth-child(8) { width: 125px; }
.customer-table th:last-child { width: 150px; }
.customer-detail-list { display: grid; grid-template-columns: minmax(125px, 32%) minmax(0, 1fr); gap: 16px; }
.customer-detail-list dt, .customer-detail-list dd { margin: 0; }
.customer-detail-list dd { overflow-wrap: anywhere; }
.customer-empty-table { padding: 24px !important; color: #6c757d !important; text-align: center; }

@media (max-width: 991.98px) { .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "header" "content" "footer"; } .app-sidebar { display: none; } .app-content { padding: 20px; } }

/* Module Đơn hàng: giữ bảng dễ đọc và các badge nằm giữa dòng. */
.order-table th,
.order-table td {
    vertical-align: middle;
}
.order-table .badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    white-space: normal;
}
.order-item-image {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}
.order-completion-image {
    width: 110px;
    height: 90px;
    object-fit: cover;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}
.order-timeline {
    max-height: 330px;
    overflow-y: auto;
}
.order-timeline-item {
    position: relative;
    margin-left: 8px;
    padding: 0 0 18px 22px;
    border-left: 2px solid #d8dee9;
}
.order-timeline-item::before {
    position: absolute;
    top: 2px;
    left: -7px;
    width: 12px;
    height: 12px;
    content: '';
    background: #198754;
    border-radius: 50%;
}
.order-modal[hidden] {
    display: none;
}
.order-modal {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.order-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
}
.order-modal-dialog {
    position: relative;
    width: min(500px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}
.order-modal-header,
.order-modal-body,
.order-modal-footer {
    padding: 18px;
}
.order-modal-header,
.order-modal-footer {
    border-bottom: 1px solid #dee2e6;
}
.order-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #dee2e6;
    border-bottom: 0;
}
.order-modal-open {
    overflow: hidden;
}
.order-option-group {
    margin-bottom: 22px;
    text-align: center;
}
.order-option-title {
    margin-bottom: 10px;
    font-weight: 500;
}
.order-option-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.order-option-button {
    min-width: 48px;
    padding: 7px 15px;
    color: #54278f;
    background: #fff;
    border: 1px solid #6937a4;
    border-radius: 22px;
}
.order-option-button.active {
    color: #dc3545;
    border-color: #dc3545;
}
.order-option-button:disabled {
    color: #adb5bd;
    cursor: not-allowed;
    border-color: #ced4da;
    opacity: 0.6;
}
.order-modal-quantity,
.order-quantity-control {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}
.order-modal-quantity {
    display: flex;
    width: 180px;
    margin: 0 auto;
}
.order-modal-quantity button,
.order-modal-quantity input,
.order-quantity-control button,
.order-quantity-control input {
    width: 58px;
    height: 40px;
    text-align: center;
    background: #fff;
    border: 0;
}
.order-modal-quantity input,
.order-quantity-control input {
    appearance: textfield;
}
.order-create-image {
    width: 70px;
    height: 70px;
    object-fit: contain;
}
.order-create-table th,
.order-create-table td {
    vertical-align: middle;
}
.order-create-table th:first-child {
    width: 35%;
}
.order-quantity-control {
    margin: 0 auto 5px;
}
.order-stock-left {
    white-space: nowrap;
}
.order-autocomplete {
    position: relative;
}
.order-autocomplete-results {
    position: absolute;
    z-index: 1060;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    overflow-y: auto;
    max-height: 280px;
    padding: 5px;
    background: #fff;
    border: 1px solid #dce3ed;
    border-radius: 9px;
    box-shadow: 0 14px 32px rgba(28, 45, 77, .16);
}
.order-autocomplete-item {
    display: block;
    width: 100%;
    padding: 9px 11px;
    color: #263247;
    background: transparent;
    border: 0;
    border-radius: 6px;
    text-align: left;
}
.order-autocomplete-item:hover,
.order-autocomplete-item:focus {
    color: #0d5bd7;
    background: #eef5ff;
    outline: 0;
}
.order-autocomplete-empty {
    padding: 11px;
    color: #7a8598;
    text-align: center;
}
.order-create-total th,
.order-create-total td {
    padding: 9px 0;
}
.order-create-total td {
    font-weight: 600;
    text-align: right;
}
.benefit-upload-box {
    min-height: 165px;
    border: 1px dashed #dc3545;
    border-radius: .5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-align: center;
    padding: 1.5rem;
}
.report-page {
    width: 100%;
    max-width: 1600px;
    margin-inline: auto;
}
.report-page > .d-flex:first-child h1 {
    color: #172033;
    font-size: 1.55rem;
    font-weight: 750;
    letter-spacing: -.025em;
}
.report-page .card {
    overflow: hidden;
    border: 1px solid #e4eaf2 !important;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(28, 45, 77, .055) !important;
}
.report-page > form.card {
    overflow: visible;
    background: #fbfcfe;
}
.report-page > form .card-body {
    padding: 1rem;
}
.report-page > form .form-label {
    margin-bottom: .35rem;
    color: #46536a;
    font-size: .79rem;
    font-weight: 650;
}
.report-page > form .form-control,
.report-page > form .form-select {
    min-height: 40px;
    border-color: #dce3ed;
    border-radius: 8px;
}
.report-page > form .form-control:focus,
.report-page > form .form-select:focus {
    border-color: #7e9ff8;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .1);
}
.report-page .card-header {
    padding: .85rem 1rem;
    color: #263247;
    background: #fff !important;
    border-bottom-color: #e9edf3;
    font-weight: 700;
}
.report-metric {
    position: relative;
    min-height: 132px;
    transition: transform .18s ease, box-shadow .18s ease;
}
.report-metric::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: #2875ed;
    content: "";
}
.report-metric:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(28, 45, 77, .09) !important;
}
.report-metric .bi {
    font-size: 1.2rem;
}
.report-metric .fs-4 {
    color: #172033;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.025em;
}
.report-chart-large,
.report-chart {
    position: relative;
    height: 300px;
    background: linear-gradient(180deg, rgba(247, 249, 252, .75), rgba(255, 255, 255, 0));
    border-radius: 8px;
}
.report-chart-large {
    height: 340px;
}
.report-chart-state {
    display: grid;
    min-height: 180px;
    padding: 1.5rem;
    color: #7a8598;
    place-items: center;
    text-align: center;
}
.report-chart-state .bi {
    display: block;
    margin-bottom: .55rem;
    color: #a3adbc;
    font-size: 1.5rem;
}
.report-page > .alert-light {
    color: #5d687b;
    background: #f7f9fc;
    border: 1px solid #e4eaf2;
    border-radius: 10px;
}
@media (prefers-reduced-motion: reduce) {
    .report-metric { transition: none; }
}
@media (max-width: 767.98px) {
    .report-page > .d-flex:first-child h1 { font-size: 1.3rem; }
    .report-page .card { border-radius: 10px; }
    .report-chart-large,
    .report-chart { height: 280px; }
    .report-metric { min-height: 118px; }
}
