:root {
    --sidebar-bg: #0b1220;
    --sidebar-active: #152447;
    --sidebar-border: #2563eb;
    --page-bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
}

html, body.admin-body {
    height: 100%;
    background: var(--page-bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
    border-right: 1px solid rgba(255,255,255,.06);
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar for Chrome/Safari later if needed */
    transition: width 0.22s ease, min-width 0.22s ease, max-width 0.22s ease;
}
.sidebar::-webkit-scrollbar { display: none; }

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed {
    width: 76px;
    min-width: 76px;
    max-width: 76px;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-brand-text,
body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-section-label,
body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .nav-label {
    display: none;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-brand-row {
    justify-content: center;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-brand-main {
    flex: 0 0 auto;
    justify-content: center;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-collapse-btn {
    display: none;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-brand {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .sidebar-nav .nav-item {
    justify-content: center;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed .nav-ico {
    width: 1.5rem;
    font-size: 1.05rem;
}

body.admin-pos-sidebar-host .sidebar-brand-row {
    align-items: center;
}

body.admin-pos-sidebar-host .sidebar-collapse-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

body.admin-pos-sidebar-host .sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

body.admin-pos-sidebar-host .sidebar-hover-expand {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(45%, -50%);
    z-index: 40;
    width: 26px;
    height: 44px;
    border-radius: 0 10px 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: none;
    background: linear-gradient(180deg, #152447 0%, #0f172a 100%);
    color: #fff;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease, background 0.15s ease;
}

body.admin-pos-sidebar-host .sidebar:not(.sidebar--collapsed) .sidebar-hover-expand {
    display: none;
}

body.admin-pos-sidebar-host .sidebar.sidebar--collapsed:hover .sidebar-hover-expand,
body.admin-pos-sidebar-host .sidebar.sidebar--collapsed:focus-within .sidebar-hover-expand {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.admin-pos-sidebar-host .sidebar-hover-expand:hover {
    background: #1e3a6f;
    color: #fff;
}

.nav-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .9rem;
    border-radius: .5rem;
    color: rgba(255,255,255,.82);
    text-decoration: none;
    margin-bottom: .25rem;
    font-weight: 500;
}

.sidebar-nav .nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.sidebar-nav .nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--sidebar-border);
}

.nav-ico { opacity: .9; width: 1.25rem; text-align: center; flex-shrink: 0; }

.sidebar-brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,.45);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.sidebar-brand-title {
    font-size: 1.05rem;
    line-height: 1.2;
    font-weight: 700;
    color: #fff;
    letter-spacing: .01em;
}

.sidebar-brand-sub {
    font-size: .8rem;
    color: rgba(255,255,255,.72);
}

.main-area {
    background: var(--page-bg);
    min-width: 0; /* flex: cho phép co theo chiều ngang, tránh tràn khi tiêu đề/nút dài */
}

.topbar { position: sticky; top: 0; z-index: 20; }
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1.25rem;
    width: 100%;
}
.topbar-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-pill {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: .25rem .75rem;
}

.top-link {
    color: var(--muted);
    text-decoration: none;
    font-size: .9rem;
    padding: .35rem .5rem;
    border-radius: .35rem;
}

.top-link:hover { color: var(--text); background: #f1f5f9; }
.top-link.active { color: var(--primary); font-weight: 600; }

.btn {
    min-height: 40px;
    padding: .42rem .95rem;
    border-radius: .75rem;
    font-weight: 600;
    transition: transform .08s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
}

.btn.btn-sm {
    min-height: 34px;
    padding: .28rem .72rem;
    border-radius: .62rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-color: #1d4ed8;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    border-color: #1e40af;
    box-shadow: 0 10px 20px rgba(37, 99, 235, .28);
}

.btn-outline-secondary {
    border-color: #cbd5e1;
    color: #334155;
    background: #fff;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-light {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.btn-light:hover {
    background: #f1f5f9;
}

.avatar-sm {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}

.card-surface {
    background: var(--card);
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    box-shadow: 0 4px 12px rgba(15,23,42,.03);
    overflow: hidden;
}

body.auth-page {
    background:
        linear-gradient(rgba(15, 23, 42, .52), rgba(15, 23, 42, .52)),
        url('/images/login-bg-aj1.png') center center / cover no-repeat fixed;
}

.auth-background {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.auth-container {
    max-width: 340px !important;
}

.auth-card {
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(4px);
    border-radius: 1.5rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .12);
    padding: 1.25rem !important;
}

.auth-logo {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
}

.auth-input {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .8rem;
    border-radius: 999px;
    background: rgba(239, 246, 255, .92);
    border: 1px solid rgba(219, 234, 254, .95);
}

.auth-input-ico {
    font-size: .95rem;
    opacity: .8;
}

.auth-input-control {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding-left: 0;
    padding-top: .35rem;
    padding-bottom: .35rem;
    font-size: .95rem;
}

.auth-input-control:focus {
    outline: none;
}

.auth-submit {
    min-height: 40px;
    border-radius: 999px;
    font-weight: 700;
}

.page-title { font-weight: 700; letter-spacing: .02em; }
.page-sub { color: var(--muted); max-width: 720px; }

.sidebar-section-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255, .38);
    margin-top: 1.5rem;
    margin-bottom: .5rem;
    padding-left: .9rem;
    white-space: nowrap;
}

.required-label::after {
    content: " *";
    color: var(--danger);
    font-weight: 700;
}

.kpi {
    border-radius: .75rem;
    padding: 1rem 1.1rem;
    background: var(--card);
    border: 1px solid #e2e8f0;
    height: 100%;
}

.kpi .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .value { font-size: 1.35rem; font-weight: 700; }
.kpi .hint { font-size: .8rem; color: var(--muted); }

.kpi-soft {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-color: #dbeafe;
}

.dashboard-hero {
    background: linear-gradient(120deg, #1d4ed8 0%, #2563eb 45%, #0ea5e9 100%);
    border-radius: 1rem;
    padding: 1rem 1.2rem;
    box-shadow: 0 12px 28px rgba(37, 99, 235, .25);
}

.dashboard-panel {
    border-radius: .95rem;
    border-color: #dbeafe;
}

.badge-soft { 
    font-size: .7rem; 
    padding: .28rem .65rem; 
    border-radius: 6px; 
    font-weight: 700; 
    text-transform: uppercase;
    letter-spacing: .02em;
}
.badge-soft.success { background: #f0fdf4; color: #15803d; border: 1px solid #dcfce7; }
.badge-soft.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #dbeafe; }
.badge-soft.warn { background: #fff7ed; color: #c2410c; border: 1px solid #ffedd5; }
.badge-soft.danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fee2e2; }
.badge-soft.neutral { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }

/* --- Tables & Data Displays --- */
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: #f1f5f9;
    margin-bottom: 0;
}

.table thead th {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding: 1rem .75rem;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    border-top: none;
}

.table tbody td {
    padding: .85rem .75rem;
    font-size: .875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color .15s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

.table-responsive {
    scrollbar-width: thin;
}

/* Compact form controls inside tables */
.table .form-select-sm,
.table .form-control-sm {
    font-size: .8rem;
    min-height: 30px;
    padding-top: .2rem;
    padding-bottom: .2rem;
    border-radius: .5rem;
    border-color: #e2e8f0;
}

.table .btn-sm {
    min-height: 28px;
    padding: .15rem .6rem;
    font-size: .75rem;
    border-radius: .4rem;
}

/* Avatar enhancement in tables */
.avatar-sm {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important;
    color: #fff !important;
    border-radius: 8px;
    font-size: .75rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.table img.rounded {
    object-fit: cover;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(15,23,42,.08);
    transition: transform .2s ease;
}

.table img.rounded:hover {
    transform: scale(1.15);
    z-index: 10;
}

/* Customizing standard Bootstrap badges to match our theme */
.badge {
    padding: .35em .65em;
    font-weight: 700;
    letter-spacing: .02em;
    border-radius: 6px;
}

.bg-secondary {
    background-color: #64748b !important;
}

.timeline-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: #fff;
}
.timeline-dot.on { border-color: #2563eb; background: #2563eb; }
.timeline-dot.current { box-shadow: 0 0 0 4px rgba(37,99,235,.2); }

.fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 50;
    width: 52px; height: 52px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary); color: #fff; text-decoration: none;
    font-size: 1.6rem; font-weight: 300;
    box-shadow: 0 10px 25px rgba(37,99,235,.35);
}
.fab:hover { color: #fff; filter: brightness(1.05); }

.chart-bar {
    display: flex; align-items: flex-end; gap: 8px; height: 160px;
}
.chart-bar .bar {
    flex: 1; background: linear-gradient(180deg, #93c5fd, #2563eb);
    border-radius: 6px 6px 2px 2px;
    min-height: 6px;
}

@media (max-width: 992px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        position: relative;
    }

    body.admin-pos-sidebar-host .sidebar.sidebar--collapsed {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }

    body.admin-pos-sidebar-host .sidebar .sidebar-hover-expand {
        display: none !important;
    }

    .sidebar .sidebar-brand-text,
    .sidebar .nav-label {
        display: block !important;
    }

    .sidebar-section-label {
        display: none !important;
    }

    .sidebar-brand {
        padding-bottom: .75rem !important;
    }

    .sidebar-nav {
        display: flex;
        gap: .5rem;
        overflow-x: auto;
        padding-bottom: .75rem;
    }

    .sidebar-nav .nav-item {
        justify-content: flex-start !important;
        white-space: nowrap;
        margin-bottom: 0;
    }

    body.admin-pos-sidebar-host .sidebar .sidebar-collapse-btn {
        display: none !important;
    }

    /* --- Mobile Topbar Layout --- */
    .topbar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.65rem 1rem !important;
    }

    .topbar-links {
        display: flex;
        justify-content: flex-start;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.35rem;
        gap: 0.5rem;
        scrollbar-width: none; /* Firefox */
        -webkit-overflow-scrolling: touch;
    }
    
    .topbar-links::-webkit-scrollbar {
        display: none; /* Safari and Chrome */
    }

    .topbar-links .top-link {
        padding: 0.4rem 0.75rem;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        font-size: 0.85rem;
        font-weight: 500;
        transition: all 0.15s ease;
    }
    
    .topbar-links .top-link.active {
        background: #eff6ff;
        border-color: #bfdbfe;
        color: var(--primary);
    }

    .topbar-user {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        border-top: 1px solid #f1f5f9;
        padding-top: 0.65rem;
        margin-top: 0.15rem;
    }
    
    .topbar-user form {
        margin-left: 0 !important;
    }
}

@media (max-width: 768px) {
    .content {
        padding: 1rem !important;
    }

    .table-responsive {
        font-size: .9rem;
    }
}

/* --- Pagination --- */
.pagination .page-link {
    border-radius: .5rem !important;
    margin: 0 3px;
    border: 1px solid #e2e8f0;
    color: #64748b;
    padding: .4rem .75rem;
    font-weight: 500;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, .2);
}

.pagination .page-item.disabled .page-link {
    background: #f8fafc;
    color: #cbd5e1;
}

.pagination .page-link:hover:not(.active) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text);
}

/* --- Select2 Enhancements (Bự ra xí) --- */
.select2-container--default .select2-selection--single {
    height: 48px !important;
    padding: 8px 12px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    background-color: #fff !important;
    transition: all .2s ease;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 30px !important;
    color: #1e293b !important;
    font-weight: 500 !important;
    font-size: .95rem !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 46px !important;
}

.select2-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,.1) !important;
    overflow: hidden;
    margin-top: 4px;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #f1f5f9 !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    background-color: #f8fafc !important;
}

.select2-results__option {
    padding: 10px 14px !important;
    font-size: .9rem !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #eff6ff !important;
    color: var(--primary) !important;
}

/* Fix for Select2 inside input-group or with form-control-sm */
.select2-container {
    display: block;
}

.is-invalid-border .select2-selection {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}
