:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --success: #10B981;
    --success-hover: #059669;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg-main: #F3F4F6;
    --bg-card: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg-main); color: var(--text-main); line-height: 1.5; }

.app-container { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { 
    width: var(--sidebar-width); 
    background-color: #0f172a; 
    color: #fff; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden;
}
.logo { padding: 20px 24px; font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); flex-shrink: 0; }
.logo svg { color: var(--primary); }

.nav-menu { 
    padding: 16px 10px; 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; 
}

/* Custom Sleek Dark Scrollbar for Sidebar */
.nav-menu::-webkit-scrollbar { width: 4px; }
.nav-menu::-webkit-scrollbar-track { background: transparent; }
.nav-menu::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.nav-menu::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Accordion Nav Groups */
.nav-group { margin-bottom: 6px; }

.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    user-select: none;
    text-align: left;
}

.nav-group-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.nav-group.open .nav-group-toggle {
    color: #ffffff;
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-group-title svg {
    color: #818cf8;
    flex-shrink: 0;
}

.nav-group-chevron {
    color: #64748b;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.nav-group.open .nav-group-chevron {
    transform: rotate(180deg);
    color: #94a3b8;
}

.nav-group-items {
    display: none;
    padding: 4px 0 4px 14px;
    margin-left: 14px;
    border-left: 1.5px solid rgba(255, 255, 255, 0.08);
}

.nav-group.open .nav-group-items {
    display: block;
    animation: fadeInSlide 0.2s ease-out;
}

@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.nav-item { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 9px 12px; 
    color: #94a3b8; 
    text-decoration: none; 
    border-radius: 6px; 
    margin-bottom: 3px; 
    transition: all 0.18s ease; 
    font-weight: 500; 
    font-size: 13.5px; 
}
.nav-item:hover { 
    background-color: rgba(255, 255, 255, 0.06); 
    color: #ffffff; 
    transform: translateX(2px); 
}
.nav-item.active { 
    background-color: var(--primary); 
    color: #ffffff; 
    font-weight: 600; 
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35); 
}
.nav-item svg {
    width: 17px;
    height: 17px;
    opacity: 0.85;
}
.nav-item.active svg {
    opacity: 1;
}

.badge { background: #64748b; color: white; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.badge-success { background-color: #dcfce7 !important; color: #15803d !important; border: 1px solid #86efac !important; }
.badge-warning { background-color: #fef3c7 !important; color: #b45309 !important; border: 1px solid #fde68a !important; }
.badge-danger, .badge-error { background-color: #fee2e2 !important; color: #b91c1c !important; border: 1px solid #fca5a5 !important; }
.badge-secondary, .badge-neutral { background-color: #f1f5f9 !important; color: #475569 !important; border: 1px solid #cbd5e1 !important; }
.badge-info { background-color: #e0f2fe !important; color: #0369a1 !important; border: 1px solid #bae6fd !important; }
.badge-primary { background-color: #dbeafe !important; color: #1d4ed8 !important; border: 1px solid #93c5fd !important; }

.sync-panel { padding: 24px; border-top: 1px solid #1F2937; background: #0F1520; }
.sync-status { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; color: #9CA3AF; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-dot.active { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.syncing { background: var(--warning); animation: pulse 1s infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
button.syncing svg, .btn.syncing svg, .syncing .sync-icon { display: inline-block; animation: spin 0.8s linear infinite; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header { padding: 32px 40px 24px; background: var(--bg-card); display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--border); }
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--text-muted); font-size: 14px; }

.tab-content { padding: 32px 40px; overflow-y: auto; flex: 1; }
.hidden { display: none !important; }

/* Cards & Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 2px solid transparent;
    border-left: 4px solid var(--primary);
    position: relative;
}
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-info { border-left-color: #3B82F6; }
.stat-card.stat-warning { border-left-color: var(--danger); }
.stat-card h3 { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--text-main); }

.stat-card-clickable {
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}
.stat-card-clickable:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Active State for each card type */
#card-stat-total.stat-card-active {
    border-color: #4F46E5 !important;
    background-color: #EEF2FF !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25), 0 8px 16px rgba(79, 70, 229, 0.12) !important;
}

#card-stat-created.stat-card-active {
    border-color: #10B981 !important;
    background-color: #ECFDF5 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25), 0 8px 16px rgba(16, 185, 129, 0.12) !important;
}

#card-stat-ready.stat-card-active {
    border-color: #3B82F6 !important;
    background-color: #EFF6FF !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), 0 8px 16px rgba(59, 130, 246, 0.12) !important;
}

#card-stat-error.stat-card-active {
    border-color: #EF4444 !important;
    background-color: #FEF2F2 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25), 0 8px 16px rgba(239, 68, 68, 0.12) !important;
}

#card-stat-discrepancy.stat-card-active {
    border-color: #DC2626 !important;
    background-color: #FEF2F2 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25), 0 8px 16px rgba(220, 38, 38, 0.12) !important;
}

#card-stat-cancelled.stat-card-active {
    border-color: #64748B !important;
    background-color: #F8FAFC !important;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.25), 0 8px 16px rgba(100, 116, 139, 0.12) !important;
}

#tab-drafts .stat-card-active::after {
    content: "✓ Đang chọn";
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    color: white;
}

#card-stat-total.stat-card-active::after { background: #4F46E5; }
#card-stat-created.stat-card-active::after { background: #10B981; }
#card-stat-ready.stat-card-active::after { background: #3B82F6; }
#card-stat-error.stat-card-active::after { background: #EF4444; }
#card-stat-discrepancy.stat-card-active::after { background: #DC2626; }
#card-stat-cancelled.stat-card-active::after { background: #64748B; }

/* Tắt triệt để text "Đang chọn" ở tab Hóa Đơn Đầu Vào tránh đè lên nhãn phần trăm % */
#tab-input-invoices .stat-card::after,
#tab-input-invoices .stat-card-active::after,
#input-invoices-kpi-cards .stat-card::after,
#input-invoices-kpi-cards .stat-card-active::after,
#input-txs-kpi-cards .stat-card::after,
#input-txs-kpi-cards .stat-card-active::after {
    display: none !important;
    content: none !important;
}

/* Phục hồi chiều cao thẻ và kích thước chữ như cũ cho 6 thẻ thống kê tại tab Hàng đợi kế toán */
#tab-drafts .stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 14px !important;
}
#tab-drafts .stat-card {
    padding: 24px 20px !important;
    border-radius: 12px !important;
}
#tab-drafts .stat-card h3 {
    font-size: 13.5px !important;
    margin-bottom: 8px !important;
    letter-spacing: 0.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
#tab-drafts .stat-value {
    font-size: 32px !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
}
#tab-drafts .stat-card-active::after {
    top: 10px !important;
    right: 12px !important;
    font-size: 11px !important;
    padding: 2px 8px !important;
}

.card { background: var(--bg-card); border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); overflow: hidden; }
.mt-24 { margin-top: 24px; }
.mb-24 { margin-bottom: 24px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #F9FAFB; padding: 12px 24px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 16px 24px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:hover { background: #F9FAFB; }
.data-table tr:last-child td { border-bottom: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; font-size: 14px; font-weight: 500; border-radius: 8px; border: none; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-hover); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: #F9FAFB; border-color: #D1D5DB; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Forms */
.form-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; width: 100%; font-family: inherit; color: var(--text-main); outline: none; transition: border-color 0.2s; }
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.alert { padding: 16px 24px; border-radius: 8px; font-size: 14px; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 500; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.status-ready { background: #D1FAE5; color: #065F46; }

/* Loading Overlay */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.9); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 16px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-content { background: var(--bg-card); width: 600px; border-radius: 12px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); overflow: hidden; }
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.btn-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; }
.terminal { background: #111827; color: #10B981; padding: 24px; font-family: monospace; font-size: 13px; height: 300px; overflow-y: auto; line-height: 1.6; }

/* Toggle Switch css */
.switch { position: relative; display: inline-block; width: 44px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #d1d5db; transition: .3s; border-radius: 22px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(22px); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Premium Date Range Picker Styles */
.daterange-trigger-btn {
    transition: all 0.2s ease-in-out;
}
.daterange-trigger-btn:hover {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.daterange-popover {
    position: absolute;
    z-index: 1000;
    background: #1e2230;
    color: #f3f4f6;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    border: 1px solid #2e3446;
    display: flex;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    user-select: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    pointer-events: none;
}

.daterange-popover.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.drp-presets {
    width: 170px;
    background: #131722;
    border-right: 1px solid #2e3446;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.drp-preset-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 8px 16px;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.drp-preset-btn:hover {
    background: #1e2230;
    color: #fff;
}

.drp-preset-btn.active {
    background: #2563eb;
    color: #fff;
    font-weight: 500;
}

.drp-calendars-wrapper {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #1e2230;
}

.drp-inputs-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2e3446;
    padding-bottom: 12px;
}

.drp-date-input {
    background: #131722;
    border: 1px solid #2e3446;
    border-radius: 6px;
    color: #fff;
    padding: 6px 12px;
    font-size: 13px;
    text-align: center;
    width: 120px;
    outline: none;
    font-family: monospace;
}

.drp-date-input:focus {
    border-color: #2563eb;
}

.drp-arrow {
    color: #9ca3af;
    font-size: 14px;
}

.drp-calendars {
    display: flex;
    gap: 20px;
}

.drp-calendar {
    width: 230px;
}

.drp-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.drp-month-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.drp-nav-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.drp-nav-btn:hover {
    background: #2e3446;
    color: #fff;
}

.drp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
}

.drp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    row-gap: 4px;
}

.drp-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #d1d5db;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.1s;
    position: relative;
}

.drp-day:hover {
    background: #2e3446;
    color: #fff;
}

.drp-day.muted {
    color: #4b5563;
}

.drp-day.in-range {
    background: rgba(37, 99, 235, 0.25) !important;
    color: #93c5fd !important;
    border-radius: 0;
}

.drp-day.range-start {
    background: #2563eb !important;
    color: #fff !important;
    font-weight: 600;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.drp-day.range-end {
    background: #2563eb !important;
    color: #fff !important;
    font-weight: 600;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.drp-day.range-start.range-end {
    border-radius: 4px !important;
}

.drp-day.today::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 4px;
    height: 4px;
    background: #2563eb;
    border-radius: 50%;
}

.drp-day.range-start.today::after, .drp-day.range-end.today::after {
    background: #fff;
}

.drp-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #2e3446;
    padding-top: 12px;
}

.drp-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-close-picker {
    background: #2e3446;
    color: #d1d5db;
}

.btn-close-picker:hover {
    background: #3e4659;
    color: #fff;
}

.btn-apply-picker {
    background: #2563eb;
    color: #fff;
}

.btn-apply-picker:hover {
    background: #3b82f6;
}

/* ==================== REMINDERS & KPI STYLES ==================== */
.btn-subtab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.btn-subtab:hover {
    color: #111827;
}
.btn-subtab.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Department Badges */
.badge-dept {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-dept-ke_toan { background-color: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }
.badge-dept-sale { background-color: #fce7f3; color: #9d174d; border: 1px solid #fbcfe8; }
.badge-dept-kho { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-dept-san_xuat { background-color: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.badge-dept-toan_cong_ty { background-color: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }

/* Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-status-completed { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-status-pending { background-color: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }
.badge-status-unnotified { background-color: #f8fafc; color: #64748b; border: 1px dashed #cbd5e1; }
.badge-status-notified { background-color: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.badge-status-in_progress { background-color: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-status-delayed { background-color: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-status-overdue { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Click to Copy */
.click-to-copy {
    cursor: pointer;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-weight: 600;
    color: #4f46e5;
    background: #eef2ff;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}
.click-to-copy:hover {
    background: #e0e7ff;
    color: #3730a3;
    transform: scale(1.02);
}

/* KPI Progress Bars */
.kpi-progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}
.kpi-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.kpi-progress-success { background-color: #10b981; }
.kpi-progress-warning { background-color: #f59e0b; }
.kpi-progress-danger { background-color: #ef4444; }

/* KPI Grade Badges */
.badge-grade-xuat_sac { background-color: #d1fae5; color: #065f46; font-weight: 700; padding: 4px 8px; border-radius: 6px; }
.badge-grade-tot { background-color: #dbeafe; color: #1e40af; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.badge-grade-kha { background-color: #fef3c7; color: #92400e; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.badge-grade-can_cai_thien { background-color: #fee2e2; color: #991b1b; font-weight: 700; padding: 4px 8px; border-radius: 6px; }

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast-msg {
    background: #111827;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInRight 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Row Hover & Pointer */
.interactive-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.interactive-row:hover {
    background-color: #f8fafc !important;
}
/* Frequency & Time Picker Component Styles */
.freq-type-btn {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    user-select: none;
}
.freq-type-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.freq-day-pill {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}
.freq-day-pill:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}
.freq-day-pill.active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.freq-month-cell {
    padding: 6px 0;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}
.freq-month-cell:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}
.freq-month-cell.active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}

.btn-time-preset {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #e0e7ff;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-time-preset:hover {
    background: #e0e7ff;
    border-color: #c7d2fe;
}

.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: #4f46e5;
    color: #ffffff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.time-badge-remove {
    cursor: pointer;
    color: #c7d2fe;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}
.time-badge-remove:hover {
    color: #ffffff;
}

.assignee-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.assignee-badge-remove {
    cursor: pointer;
    color: #059669;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}
.assignee-badge-remove:hover {
    color: #dc2626;
}

/* ==================== SWITCH TOGGLE ON/OFF COMPONENT ==================== */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    vertical-align: middle;
    user-select: none;
    cursor: pointer;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
}

.switch-toggle .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch-toggle input:checked + .slider {
    background-color: #10b981; /* Emerald Active */
}

.switch-toggle input:focus + .slider {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* ==================== MEMBERS MANAGEMENT VIEW STYLES ==================== */
.dept-member-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}
.dept-member-card:hover {
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.dept-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.dept-badge-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.zalo-search-dropdown-wrapper {
    position: relative;
}
.zalo-search-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 99;
    margin-top: 4px;
}
.zalo-user-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.15s ease;
}
.zalo-user-option:hover {
    background: #eef2ff;
    color: #4338ca;
}
/* ==================== ENTERPRISE HR & DOCUMENT MANAGEMENT STYLES ==================== */
.emp-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4338ca;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.emp-name-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.emp-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.emp-status-active { background: #dcfce7; color: #15803d; }
.emp-status-probation { background: #fef9c3; color: #a16207; }
.emp-status-suspended { background: #ffedd5; color: #c2410c; }
.emp-status-resigned { background: #fee2e2; color: #b91c1c; }

.emp-row-resigned {
    opacity: 0.72;
    background-color: #f8fafc;
}
.emp-row-resigned td {
    color: #64748b;
}

.btn-emp-work-toggle {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn-emp-work-resign {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}
.btn-emp-work-resign:hover {
    background: #fee2e2;
    border-color: #f87171;
}
.btn-emp-work-active {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}
.btn-emp-work-active:hover {
    background: #d1fae5;
    border-color: #34d399;
}

/* Drag & Drop Zone */
.doc-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 24px 20px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
}
.doc-dropzone:hover, .doc-dropzone.dragover {
    border-color: #4f46e5;
    background: #eef2ff;
}

.doc-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.doc-card-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    transition: all 0.15s ease;
}
.doc-card-item:hover {
    border-color: #a5b4fc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.profile-tab-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}
.profile-tab-btn:hover {
    color: #1e293b;
}
.profile-tab-btn.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
}

/* ==================== ENTERPRISE 360 DATA GRID STYLES ==================== */
.data-table th {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.data-table td {
    padding: 12px 14px;
    font-size: 13px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
    background: #ffffff;
    transition: background-color 0.15s ease;
}

/* Sticky column styling for flawless scrolling */
.data-table thead th:nth-child(1),
.data-table thead th:nth-child(2),
.data-table thead th:nth-child(3),
.data-table thead th:nth-child(4) {
    background: #f8fafc !important;
}

.data-table thead th:nth-child(4) {
    box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.06);
}

.data-table tbody td:nth-child(1),
.data-table tbody td:nth-child(2),
.data-table tbody td:nth-child(3),
.data-table tbody td:nth-child(4) {
    background: #ffffff !important;
}

.data-table tbody td:nth-child(4) {
    box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.06);
}

.data-table thead th:last-child {
    background: #f8fafc !important;
    box-shadow: -3px 0 6px -2px rgba(0, 0, 0, 0.06);
}

.data-table tbody td:last-child {
    background: #ffffff !important;
    box-shadow: -3px 0 6px -2px rgba(0, 0, 0, 0.06);
}

/* Interactive Hover Row */
.interactive-row:hover td {
    background: #f8fafc !important;
    cursor: pointer;
}

.interactive-row.row-selected td {
    background: #eff6ff !important;
}

/* Data Grid Layout & Cell Word-break protection */
.table-scrollable-container {
    overflow-x: auto;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8fafc;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    vertical-align: middle;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
}

.data-table td.cell-wrap,
.data-table td.cell-wrap-text,
.cell-wrap-text {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
}

.data-table td.cell-nowrap {
    white-space: nowrap !important;
}

.data-table td.cell-truncate,
.cell-truncate {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* ==================== INVENTORY ORDERS & PURCHASING STYLES ==================== */
.inv-group-row {
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: filter 0.15s ease, transform 0.1s ease;
}
.inv-group-row:hover {
    filter: brightness(0.97);
}
.inv-group-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.inv-badge-urgent {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
}
.inv-badge-safe {
    color: #15803d;
    font-weight: 600;
}
.inv-subnav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
}
.inv-subnav-btn {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -2px;
}
.inv-subnav-btn:hover {
    color: #1e293b;
}
.inv-subnav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.inv-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    vertical-align: middle;
}
.inv-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.inv-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .25s;
    border-radius: 20px;
}
.inv-switch-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .25s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.inv-switch input:checked + .inv-switch-slider {
    background-color: #10b981;
}
.inv-switch input:checked + .inv-switch-slider:before {
    transform: translateX(16px);
}
.inv-inline-edit {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12.5px;
    text-align: inherit;
    font-family: inherit;
    color: inherit;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.inv-inline-edit:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}
.inv-inline-edit:focus {
    border-color: var(--primary);
    background: #ffffff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
.inv-inline-edit.saving {
    border-color: #6366f1 !important;
    background: #eef2ff !important;
}
.inv-inline-edit.saved-success {
    border-color: #10b981 !important;
    background: #ecfdf5 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
    transition: all 0.3s ease;
}
.inv-inline-edit.save-error {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* ==================== INTERACTIVE STAT CARDS IN INVENTORY ORDERS ==================== */
#tab-inventory-orders .stat-card-clickable {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}
#tab-inventory-orders .stat-card-clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 18px -4px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
#tab-inventory-orders .stat-card-active {
    box-shadow: 0 0 0 2.5px var(--primary), 0 8px 16px rgba(79, 70, 229, 0.15) !important;
    background-color: #f5f3ff !important;
}
#card-inv-stat-all.stat-card-active {
    box-shadow: 0 0 0 2.5px #3b82f6, 0 8px 16px rgba(59, 130, 246, 0.18) !important;
    background-color: #eff6ff !important;
}
#card-inv-stat-need-7.stat-card-active {
    box-shadow: 0 0 0 2.5px #ef4444, 0 8px 16px rgba(239, 68, 68, 0.18) !important;
    background-color: #fef2f2 !important;
}
#card-inv-stat-need-14.stat-card-active {
    box-shadow: 0 0 0 2.5px #f59e0b, 0 8px 16px rgba(245, 158, 11, 0.18) !important;
    background-color: #fffbeb !important;
}
#card-inv-stat-need-25.stat-card-active {
    box-shadow: 0 0 0 2.5px #4f46e5, 0 8px 16px rgba(79, 70, 229, 0.18) !important;
    background-color: #eef2ff !important;
}
#card-inv-stat-vai.stat-card-active {
    box-shadow: 0 0 0 2.5px #7c3aed, 0 8px 16px rgba(124, 58, 237, 0.18) !important;
    background-color: #f5f3ff !important;
}
#card-inv-stat-tong-ton.stat-card-active {
    box-shadow: 0 0 0 2.5px #059669, 0 8px 16px rgba(5, 150, 105, 0.18) !important;
    background-color: #ecfdf5 !important;
}

/* ==================== INPUT INVOICES ACTIVE KPI CARDS & FILTER PILLS ==================== */
#tab-input-invoices .stat-card-active {
    box-shadow: 0 0 0 2.5px var(--primary), 0 8px 16px rgba(79, 70, 229, 0.15) !important;
}
#card-stat-input-total.stat-card-active {
    box-shadow: 0 0 0 2.5px #3b82f6, 0 8px 16px rgba(59, 130, 246, 0.18) !important;
    background-color: #eff6ff !important;
}
#card-stat-input-completed.stat-card-active {
    box-shadow: 0 0 0 2.5px #6366f1, 0 8px 16px rgba(99, 102, 241, 0.18) !important;
    background-color: #f5f3ff !important;
}
#card-stat-input-booked.stat-card-active {
    box-shadow: 0 0 0 2.5px #10b981, 0 8px 16px rgba(16, 185, 129, 0.18) !important;
    background-color: #f0fdf4 !important;
}
#card-stat-input-unbooked.stat-card-active {
    box-shadow: 0 0 0 2.5px #f59e0b, 0 8px 16px rgba(245, 158, 11, 0.18) !important;
    background-color: #fff7ed !important;
}
#card-stat-input-matched.stat-card-active {
    box-shadow: 0 0 0 2.5px #0284c7, 0 8px 16px rgba(2, 132, 199, 0.18) !important;
    background-color: #f0f9ff !important;
}
#card-stat-input-risk.stat-card-active {
    box-shadow: 0 0 0 2.5px #ef4444, 0 8px 16px rgba(239, 68, 68, 0.18) !important;
    background-color: #fef2f2 !important;
}

.inv-filter-pill {
    transition: all 0.15s ease;
    border-radius: 6px;
    font-weight: 600;
}
.inv-filter-pill.active {
    background-color: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}


/* ==================== HIGH PERFORMANCE TABLE SCROLLING ==================== */
#inv-table-wrapper {
    overflow-y: auto !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: auto !important;
}

#table-inventory-orders {
    table-layout: fixed !important;
}

#table-inventory-orders th,
#table-inventory-orders td {
    box-shadow: none !important;
}

#table-inventory-orders thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc !important;
    border-bottom: 2px solid #cbd5e1 !important;
}

.inv-sku-row {
    background-color: #ffffff;
}

.inv-sku-row:hover td {
    background-color: #f1f5f9 !important;
}

.inv-group-row {
    background-color: inherit;
}

.inv-btn-del {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 15px;
    padding: 2px 6px;
    transition: color 0.15s ease;
}

.inv-btn-del:hover {
    color: #ef4444 !important;
}

/* ==================== WAREHOUSE AUDIT & ASSIGNMENT STYLES ==================== */
.audit-row:hover td {
    background-color: #f8fafc !important;
}

.assign-row:hover td {
    background-color: #f8fafc !important;
}

.badge-audit-diff {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.badge-audit-diff.diff-match {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge-audit-diff.diff-shortage {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.badge-audit-diff.diff-surplus {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.badge-audit-status {
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 700;
    user-select: none;
    transition: all 0.15s ease;
    display: inline-block;
}

.badge-audit-status:hover {
    transform: scale(1.05);
}

.badge-audit-status.status-audited {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #10b981;
}

.badge-audit-status.status-pending {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #f59e0b;
}

.badge-audit-location {
    background: #f1f5f9;
    color: #334155;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    display: inline-block;
}

.badge-audit-pic {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid #bfdbfe;
    display: inline-block;
}

#table-warehouse-audit th,
#table-warehouse-audit td,
#table-warehouse-assignments th,
#table-warehouse-assignments td {
    box-shadow: none !important;
}

#card-audit-stat-total.stat-card-active {
    box-shadow: 0 0 0 2.5px #3b82f6, 0 8px 16px rgba(59, 130, 246, 0.18) !important;
    background-color: #eff6ff !important;
}

#card-audit-stat-pending.stat-card-active {
    box-shadow: 0 0 0 2.5px #f59e0b, 0 8px 16px rgba(245, 158, 11, 0.18) !important;
    background-color: #fffbeb !important;
}

#card-audit-stat-audited.stat-card-active {
    box-shadow: 0 0 0 2.5px #10b981, 0 8px 16px rgba(16, 185, 129, 0.18) !important;
    background-color: #ecfdf5 !important;
}

#card-audit-stat-discrepancy.stat-card-active {
    box-shadow: 0 0 0 2.5px #ef4444, 0 8px 16px rgba(239, 68, 68, 0.18) !important;
    background-color: #fef2f2 !important;
}

#card-audit-stat-matched.stat-card-active {
    box-shadow: 0 0 0 2.5px #06b6d4, 0 8px 16px rgba(6, 182, 212, 0.18) !important;
    background-color: #ecfeff !important;
}

#card-audit-stat-shortage.stat-card-active {
    box-shadow: 0 0 0 2.5px #dc2626, 0 8px 16px rgba(220, 38, 38, 0.2) !important;
    background-color: #fef2f2 !important;
}

#card-audit-stat-surplus.stat-card-active {
    box-shadow: 0 0 0 2.5px #8b5cf6, 0 8px 16px rgba(139, 92, 246, 0.2) !important;
    background-color: #f5f3ff !important;
}

/* Sticky Columns for Wide Purchasing Tables */
.data-table th.sticky-col-check,
.data-table td.sticky-col-check {
    position: sticky;
    left: 0;
    z-index: 5;
    background-color: inherit;
}
.data-table th.sticky-col-stt,
.data-table td.sticky-col-stt {
    position: sticky;
    left: 40px;
    z-index: 5;
    background-color: inherit;
}
.data-table th.sticky-col-switch,
.data-table td.sticky-col-switch {
    position: sticky;
    left: 85px;
    z-index: 5;
    background-color: inherit;
}
.data-table th.sticky-col-sku,
.data-table td.sticky-col-sku {
    position: sticky;
    left: 150px;
    z-index: 5;
    background-color: inherit;
    box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.08);
}
.data-table thead th.sticky-col-check,
.data-table thead th.sticky-col-stt,
.data-table thead th.sticky-col-switch,
.data-table thead th.sticky-col-sku {
    z-index: 15 !important;
    background-color: #f8fafc !important;
}

/* Floating Batch Action Bar */
.floating-batch-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: #0f172a;
    color: #f8fafc;
    padding: 10px 22px;
    border-radius: 9999px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}
.floating-batch-bar.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.floating-batch-bar .batch-count-badge {
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 12px;
}
.floating-batch-bar .btn-batch-action {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.floating-batch-bar .btn-batch-action:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}
.floating-batch-bar .btn-batch-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    margin-left: 4px;
}
.floating-batch-bar .btn-batch-close:hover {
    color: #ffffff;
}

/* Column Customization Popover */
.col-customizer-wrapper {
    position: relative;
    display: inline-block;
}
.col-customizer-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18);
    padding: 12px 14px;
    width: 250px;
    z-index: 120;
    display: none;
}
.col-customizer-popover.show {
    display: block;
}
.col-customizer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: 12.5px;
    color: #334155;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    transition: background 0.15s ease;
}
.col-customizer-item:hover {
    background: #f1f5f9;
}
.col-customizer-item input {
    accent-color: var(--primary);
    cursor: pointer;
}

/* Zalo Chat Bubble Preview */
.zalo-chat-bubble {
    background: #eef6ff;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
    position: relative;
    font-family: inherit;
}
.zalo-chat-bubble:before {
    content: "";
    position: absolute;
    top: 14px;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #bfdbfe;
}
.zalo-bubble-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0284c7;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    margin-bottom: 8px;
}
.zalo-bubble-text {
    font-size: 12.5px;
    line-height: 1.55;
    color: #1e293b;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==================== REALTIME SYNC PULSE EFFECT ==================== */
@keyframes realtimeSyncPulse {
    0% {
        background-color: rgba(16, 185, 129, 0.3);
        box-shadow: inset 0 0 0 2px #10b981;
    }
    60% {
        background-color: rgba(16, 185, 129, 0.15);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.realtime-sync-highlight {
    animation: realtimeSyncPulse 2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ==================== AUDIT SESSIONS MASTER - DETAIL ==================== */
.audit-session-row {
    cursor: pointer;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
}
.audit-session-row:hover {
    background-color: #f1f5f9 !important;
}
.audit-session-row.active {
    background-color: #eff6ff !important;
    font-weight: 500;
}
.audit-session-row.active td:first-child {
    border-left: 4px solid #4f46e5;
}
.session-progress-container {
    width: 100%;
    height: 18px;
    background-color: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
}
.session-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.session-progress-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    color: #1e293b;
    line-height: 18px;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}
.badge-session-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}
.badge-session-status.in_progress {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.badge-session-status.completed {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}
.badge-session-status.overdue {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ==========================================================================
   SYNC PROGRESS POPUP & TELEGRAM REPORT CARD (2026 Accounting Standard)
   ========================================================================== */
.sync-modal-content {
    max-width: 580px;
    width: 92%;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    padding: 28px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sync-modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.15s ease;
    z-index: 10;
}
.sync-modal-close:hover {
    color: #374151;
}

.sync-modal-view {
    display: flex;
    flex-direction: column;
}

/* Header with pulse icon */
.sync-modal-header-center {
    text-align: center;
    margin-bottom: 20px;
}

.sync-icon-pulse-wrapper {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 0 0 8px rgba(79, 70, 229, 0.08);
}

.sync-spin-icon {
    animation: spin 2s linear infinite;
}

.sync-modal-title {
    font-size: 19px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.sync-modal-subtitle {
    font-size: 13px;
    color: #6b7280;
}

/* Big percentage display */
.sync-progress-counter-area {
    text-align: center;
    margin-bottom: 12px;
}

.sync-big-percent {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

/* Progress bar */
.sync-progressbar-track {
    width: 100%;
    height: 10px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 22px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sync-progressbar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #06b6d4);
    border-radius: 999px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

/* 4 Steps Pipeline */
.sync-pipeline-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 24px;
    padding: 0 8px;
}

.sync-pipeline-steps::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 32px;
    right: 32px;
    height: 2px;
    background: #e2e8f0;
    z-index: 1;
}

.sync-step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 2;
}

.sync-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

.sync-step-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    transition: color 0.25s ease;
}

.sync-step-item.active .sync-step-dot {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    transform: scale(1.08);
}
.sync-step-item.active .sync-step-label {
    color: var(--primary);
    font-weight: 700;
}

.sync-step-item.completed .sync-step-dot {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}
.sync-step-item.completed .sync-step-label {
    color: #059669;
}

/* Live Status Box */
.sync-live-message-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.sync-live-spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.sync-live-text-wrap {
    flex: 1;
    min-width: 0;
}

.sync-live-main {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sync-live-sub {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subtle Technical Log Section */
.sync-tech-log-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.btn-toggle-tech-log {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s ease;
}
.btn-toggle-tech-log:hover {
    color: #475569;
}

.sync-tech-log-body {
    width: 100%;
    max-height: 140px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 11px;
    background: #0f172a;
    color: #38bdf8;
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 8px;
    line-height: 1.5;
}

/* ==========================================================================
   TELEGRAM REPORT CARD STYLES
   ========================================================================== */
.telegram-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.telegram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.telegram-brand {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #e11d48;
}

.telegram-success-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.telegram-title {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.telegram-meta-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 16px;
    font-size: 13.5px;
    color: #374151;
}

.telegram-meta-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.meta-bullet {
    color: #6b7280;
    font-weight: 700;
}

.meta-label {
    font-weight: 600;
    color: #374151;
}

.meta-val {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #111827;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
}

.telegram-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px dashed #e2e8f0;
}
.telegram-section-heading span {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Metric Cards Grid */
.telegram-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

@media (min-width: 500px) {
    .telegram-metrics-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .metric-total { grid-column: span 2; }
    .metric-created { grid-column: span 2; }
    .metric-ready { grid-column: span 2; }
    .metric-error { grid-column: span 3; }
    .metric-disc { grid-column: span 3; }
}

.telegram-metric-card {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.telegram-metric-card .metric-label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.telegram-metric-card .metric-value {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.metric-subdetail {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.85;
    font-weight: 500;
}

.metric-total {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #334155;
}
.metric-total .metric-value {
    color: #0f172a;
}

.metric-created {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}
.metric-created .metric-value {
    color: #15803d;
}

.metric-ready {
    background: #fefce8;
    border-color: #fef08a;
    color: #854d0e;
}
.metric-ready .metric-value {
    color: #a16207;
}

.metric-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}
.metric-error .metric-value {
    color: #b91c1c;
}

.metric-disc {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}
.metric-disc .metric-value {
    color: #c2410c;
}

/* Auto Voucher Box */
.telegram-auto-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
}

/* Unmapped Products Box */
.telegram-unmapped-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}

.unmapped-title {
    font-size: 13px;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 10px;
}

.unmapped-items-list {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.unmapped-row {
    font-size: 12.5px;
    color: #374151;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
}

.unmapped-sku {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    color: #1d4ed8;
    background: #eff6ff;
    padding: 1px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

.unmapped-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #fcd34d;
}

.btn-link-mapping {
    background: none;
    border: none;
    color: #d97706;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.btn-link-mapping:hover {
    color: #b45309;
}

/* Callout */
.telegram-callout {
    background: #f8fafc;
    border-left: 3px solid #f59e0b;
    padding: 10px 14px;
    font-size: 13px;
    color: #4b5563;
    border-radius: 0 6px 6px 0;
}

/* Modal Actions */
.sync-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.badge-count-pill {
    background: #ffffff;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    line-height: 1;
}

/* Error Card */
.sync-error-card {
    text-align: center;
    padding: 20px 0;
}
.sync-error-icon {
    font-size: 40px;
    margin-bottom: 12px;
}
.sync-error-title {
    font-size: 18px;
    font-weight: 700;
    color: #b91c1c;
    margin-bottom: 8px;
}
.sync-error-desc {
    font-size: 13.5px;
    color: #4b5563;
    max-width: 420px;
    margin: 0 auto;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   MODULE: CẤU HÌNH & QUẢN LÝ THÔNG TIN DOANH NGHIỆP (MULTI-COMPANY)
   ========================================================================== */

/* Banner giới thiệu đầu trang */
.company-banner-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #eff6ff 100%);
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 20px 24px;
    box-shadow: 0 4px 20px -2px rgba(37, 99, 235, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    position: relative;
    overflow: hidden;
}
.company-banner-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 100%;
    background: radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
    pointer-events: none;
}
.company-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

/* Thẻ thống kê (Stats Cards) */
.company-stat-card {
    padding: 18px 22px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.company-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.07);
}
.company-stat-card.stat-purple {
    background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
    border-color: #e9d5ff;
}
.company-stat-card.stat-emerald {
    background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%);
    border-color: #a7f3d0;
}
.company-stat-card.stat-blue {
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    border-color: #bfdbfe;
}
.company-stat-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-purple .company-stat-icon-wrap {
    background: #f3e8ff;
    color: #7e22ce;
}
.stat-emerald .company-stat-icon-wrap {
    background: #d1fae5;
    color: #047857;
}
.stat-blue .company-stat-icon-wrap {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Thẻ Công Ty (Company Master Card) */
.company-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1.5px solid #e2e8f0;
    box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.company-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px -4px rgba(15, 23, 42, 0.09);
    border-color: #cbd5e1;
}
.company-card.is-primary {
    border-color: #93c5fd;
    box-shadow: 0 6px 20px -2px rgba(37, 99, 235, 0.08);
}
.company-card.is-primary:hover {
    border-color: #60a5fa;
    box-shadow: 0 18px 36px -4px rgba(37, 99, 235, 0.14);
}
.company-card-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.company-card.is-primary .company-card-header {
    background: linear-gradient(135deg, #f0f7ff 0%, #e0effe 100%);
    border-bottom-color: #bfdbfe;
}
.company-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.25);
}
.company-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}
.company-section-box {
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    line-height: 1.5;
}
.company-section-bank {
    padding: 12px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #bbf7d0;
    font-size: 13px;
}
.company-section-shipping {
    padding: 12px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    font-size: 13px;
}
.company-copy-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 12.5px;
    color: #0f172a;
    cursor: pointer;
    transition: all 0.15s ease;
}
.company-copy-chip:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #2563eb;
}
.company-card-footer {
    padding: 14px 20px;
    background: #fafafa;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   MODERN COMPANY FORM MODAL STYLES (Redesigned Enterprise UI)
   ========================================================================== */
.company-modal-dialog {
    width: 92vw;
    max-width: 920px;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(226, 232, 240, 0.9);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: companyModalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes companyModalPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.company-modal-header {
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.company-modal-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.company-modal-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    flex-shrink: 0;
}

.company-modal-title {
    margin: 0;
    font-size: 18.5px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.3px;
}

.company-modal-subtitle {
    margin: 2px 0 0 0;
    font-size: 13px;
    color: #64748b;
}

.company-modal-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.company-modal-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
}

/* Tabs Bar */
.company-modal-tabs-wrapper {
    padding: 0 28px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
}

.company-modal-tabs {
    display: flex;
    gap: 10px;
}

.company-modal-tab {
    padding: 12px 18px;
    border: none;
    background: transparent;
    font-size: 13.5px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2.5px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-bottom: -1px;
}

.company-modal-tab:hover {
    color: #1e293b;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
}

.company-modal-tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    font-weight: 700;
}

.company-tab-badge {
    background: #e0e7ff;
    color: #4338ca;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Body */
.company-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.company-modal-body::-webkit-scrollbar {
    width: 6px;
}
.company-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.company-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
}

.company-tab-pane {
    display: none;
    flex-direction: column;
    gap: 16px;
    animation: compTabFade 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.company-tab-pane.active {
    display: flex;
}

@keyframes compTabFade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Section Card */
.company-form-card {
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    padding: 18px 22px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.company-form-card-title {
    margin: 0;
    font-size: 12px;
    font-weight: 800;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modern Input Groups */
.modern-fg {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modern-fg-label {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 4px;
}

.modern-fg-label .req {
    color: #ef4444;
}

.modern-fg-label .info-tip {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    margin-left: 4px;
}

.modern-input-ctrl {
    width: 100%;
    height: 42px;
    padding: 9px 14px;
    border-radius: 9px;
    border: 1.5px solid #e2e8f0;
    background: #fbfcfe;
    font-size: 13.5px;
    color: #0f172a;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-sizing: border-box;
}

.modern-input-ctrl:focus {
    background: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.modern-input-ctrl.mono {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.modern-input-ctrl.highlight {
    font-weight: 600;
}

.modern-textarea-ctrl {
    width: 100%;
    min-height: 72px;
    padding: 10px 14px;
    border-radius: 9px;
    border: 1.5px solid #e2e8f0;
    background: #fbfcfe;
    font-size: 13px;
    color: #0f172a;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
    line-height: 1.5;
    resize: vertical;
}

.modern-textarea-ctrl:focus {
    background: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Grid Layout Helpers */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 14px;
}

/* Bank Account Cards */
.comp-bank-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1.5px solid #e2e8f0;
    padding: 16px 18px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.02);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
}

.comp-bank-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.comp-bank-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px dashed #f1f5f9;
}

.comp-bank-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
}

.btn-del-bank {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 5px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
}

.btn-del-bank:hover {
    background: #fca5a5;
    color: #991b1b;
}

.comp-bank-card-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.3fr 1.5fr 1.5fr;
    gap: 12px;
}

.btn-add-bank-dashed {
    width: 100%;
    border: 2px dashed #cbd5e1;
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
    color: #4f46e5;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-add-bank-dashed:hover {
    border-color: #4f46e5;
    background: #eef2ff;
}

/* Default Company Switcher */
.company-switch-card {
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border: 1.5px solid #bfdbfe;
    border-radius: 12px;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.company-switch-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.12);
}

.company-switch-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-switch-icon {
    font-size: 22px;
}

.company-switch-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e3a8a;
}

.company-switch-desc {
    font-size: 12px;
    color: #64748b;
    margin-top: 1px;
}

/* Footer */
.company-modal-footer {
    padding: 16px 28px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-cancel-modal {
    padding: 9px 20px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 13.5px;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-modal:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-save-modal {
    padding: 10px 26px;
    border-radius: 9px;
    font-weight: 700;
    font-size: 13.5px;
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-save-modal:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.4);
}

/* ==========================================================================
   MODULE TIMELINE QUẢN LÝ NHẮC VIỆC (DAY - WEEK - MONTH VIEWS)
   ========================================================================== */
.timeline-wrapper {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.timeline-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 12px;
}

.timeline-nav-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-timeline-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-timeline-nav:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.btn-timeline-today-shortcut {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-timeline-today-shortcut:hover:not(.disabled) {
    background: #eef2ff;
    color: #4f46e5;
    border-color: #c7d2fe;
}

.btn-timeline-today-shortcut.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.timeline-title-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.badge-timeline-today {
    background: #e0e7ff;
    color: #4338ca;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.timeline-view-switcher {
    display: inline-flex;
    background: #f3f4f6;
    padding: 3px;
    border-radius: 8px;
    gap: 4px;
}

.btn-timeline-view {
    border: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-timeline-view.active {
    background: #ffffff;
    color: #4f46e5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timeline-sub-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 12px;
}

.timeline-stats-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    color: #374151;
}

.stat-pill-label {
    font-weight: 500;
}

.stat-pill-num {
    font-weight: 700;
    color: #111827;
}

.timeline-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    color: #6b7280;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dot-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-completed {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.dot-pending {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.dot-overdue {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.dot-delayed {
    background: #f97316;
    box-shadow: 0 0 6px rgba(249, 115, 22, 0.4);
}

.dot-periodic {
    background: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

.timeline-body-container {
    position: relative;
    min-height: 480px;
}

/* Loading & Empty States */
.timeline-loading-state,
.timeline-error-state,
.timeline-empty-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.timeline-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: timeline-spin 0.8s linear infinite;
}

@keyframes timeline-spin {
    to { transform: rotate(360deg); }
}

/* ================= DAY VIEW STYLES (TRỤC ĐƯỜNG NGANG - XEN KẼ TRÊN / DƯỚI) ================= */
.timeline-horizontal-board {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

.h-board-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.h-board-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #475569;
}

.h-board-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-scroll-h {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-scroll-h:hover {
    background: #eef2ff;
    color: #4f46e5;
    border-color: #c7d2fe;
}

.timeline-horizontal-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    padding: 30px 20px;
    background: #ffffff;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
}

.timeline-horizontal-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.timeline-horizontal-scroll-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.timeline-horizontal-scroll-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.timeline-horizontal-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.timeline-horizontal-track {
    position: relative;
    min-width: max-content;
    min-height: 520px;
    display: flex;
    align-items: center;
    padding: 0 40px;
}

/* ĐƯỜNG TRỤC NGANG TRUNG TÂM */
.timeline-central-axis-line {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 50%;
    height: 4px;
    background: linear-gradient(90deg, #6366f1 0%, #3b82f6 50%, #06b6d4 100%);
    border-radius: 4px;
    transform: translateY(-50%);
    z-index: 1;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.2);
}

.axis-cap-label {
    position: absolute;
    top: -10px;
    font-size: 10px;
    font-weight: 700;
    background: #e0e7ff;
    color: #4338ca;
    padding: 2px 7px;
    border-radius: 8px;
    border: 1px solid #c7d2fe;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.axis-cap-label.start {
    left: -5px;
}

.axis-cap-label.end {
    right: -5px;
}

.timeline-nodes-wrapper {
    display: flex;
    gap: 36px;
    align-items: center;
    position: relative;
    z-index: 2;
    min-height: 480px;
}

/* TỪNG NODE TRÊN ĐƯỜNG NGANG */
.h-timeline-node {
    width: 290px;
    flex-shrink: 0;
    position: relative;
    height: 480px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* CHẤM MỐC THỜI GIAN TRÒN TRỰC TIẾP TRÊN TRỤC NGANG */
.h-axis-milestone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    z-index: 5;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px #ffffff, 0 2px 8px rgba(0, 0, 0, 0.16);
}

.h-axis-milestone:hover {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 0 4px #ffffff, 0 4px 14px rgba(0, 0, 0, 0.25);
}

.h-milestone-inner {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffffff;
}

/* NHÃN GIỜ GẮN TRÊN / DƯỚI CHẤM TRỤC */
.h-axis-time-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    padding: 2px 8px;
    border-radius: 12px;
    z-index: 3;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.h-axis-time-badge.time-below {
    top: calc(50% + 20px);
}

.h-axis-time-badge.time-above {
    bottom: calc(50% + 20px);
}

/* NHÁNH NỐI TỪ CHẤM ĐẾN CARD */
.h-node-stem {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.h-node-stem.stem-down {
    bottom: 50%;
    height: 38px;
}

.h-node-stem.stem-up {
    top: 50%;
    height: 38px;
}

.h-stem-line {
    width: 2px;
    flex: 1;
    opacity: 0.8;
}

.h-stem-arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.h-node-stem.stem-down .h-stem-arrow {
    border-top: 6px solid;
}

.h-node-stem.stem-up .h-stem-arrow {
    border-bottom: 6px solid;
}

/* THẺ CÔNG VIỆC TRÊN TRỤC NGANG */
.h-task-card {
    position: absolute;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 4;
}

.h-task-card.card-above {
    bottom: calc(50% + 42px);
}

.h-task-card.card-below {
    top: calc(50% + 42px);
}

.h-task-card.card-above:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: #cbd5e1;
}

.h-task-card.card-below:hover {
    transform: translateY(4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: #cbd5e1;
}

.h-card-accent {
    height: 4px;
    width: 100%;
}

.h-card-inner {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.h-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.h-card-time {
    font-size: 11px;
    font-weight: 700;
    color: #4f46e5;
}

.h-card-dept {
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
}

.h-card-code {
    font-size: 10.5px;
    font-family: monospace;
    font-weight: 700;
    color: #64748b;
}

.h-card-title {
    font-size: 12.5px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.h-card-desc {
    font-size: 11px;
    color: #64748b;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f1f5f9;
}

.h-card-assignee {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #475569;
    font-weight: 500;
}

.h-assignee-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4338ca;
    font-size: 9.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.h-assignee-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h-status-badge {
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.h-status-badge.dot-completed { background: #ecfdf5; color: #047857; }
.h-status-badge.dot-pending { background: #fffbeb; color: #b45309; }
.h-status-badge.dot-overdue { background: #fef2f2; color: #dc2626; }
.h-status-badge.dot-delayed { background: #fff7ed; color: #c2410c; }
.h-status-badge.dot-periodic { background: #eff6ff; color: #1d4ed8; }

/* ================= WEEK VIEW STYLES ================= */
.timeline-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    min-width: 980px;
    overflow-x: auto;
}

.week-column {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.week-column.is-today-col {
    border-top: 3px solid #4f46e5;
    background: #fafbff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.week-col-header {
    padding: 12px 10px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.week-col-header:hover {
    background: #f1f5f9;
}

.week-col-day-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #1e293b;
}

.week-col-date-badge {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.week-col-date-badge.today-pill {
    color: #4338ca;
    font-weight: 700;
}

.week-col-summary {
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 4px;
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.badge-mini-done {
    background: #ecfdf5;
    color: #047857;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
}

.badge-mini-overdue {
    background: #fef2f2;
    color: #dc2626;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
}

.week-col-body {
    padding: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 700px;
}

.week-task-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.week-task-item:hover {
    transform: translateY(-1px);
    border-color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.week-task-item.is-done {
    opacity: 0.7;
    background: #f8fafc;
}

.week-task-top {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}

.week-task-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.week-task-time {
    font-size: 11px;
    font-weight: 700;
    color: #4f46e5;
}

.week-task-code {
    font-size: 10px;
    font-family: monospace;
    color: #94a3b8;
    margin-left: auto;
}

.week-task-title {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.week-task-bottom {
    margin-top: 6px;
    font-size: 10.5px;
    color: #64748b;
}

.week-empty-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 140px;
    color: #cbd5e1;
    font-size: 11.5px;
    gap: 4px;
}

/* ================= MONTH VIEW STYLES ================= */
.timeline-month-calendar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.month-calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.month-header-cell {
    padding: 10px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
}

.month-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e2e8f0;
}

.month-day-cell {
    background: #ffffff;
    min-height: 110px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background 0.15s ease;
}

.month-day-cell:hover {
    background: #f8fafc;
}

.month-day-cell.is-pad {
    background: #fbfcfd;
    opacity: 0.45;
    cursor: default;
}

.month-day-cell.is-today-cell {
    background: #fefefe;
    border: 2px solid #4f46e5;
}

.month-cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.month-day-number {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.month-day-number.today-circle {
    background: #4f46e5;
    color: #ffffff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.month-cell-dots-bar {
    display: flex;
    gap: 3px;
    align-items: center;
}

.month-cell-tasks {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    overflow: hidden;
}

.month-task-pill {
    background: #f1f5f9;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.month-task-pill:hover {
    background: #e2e8f0;
}

.month-task-pill.is-done {
    opacity: 0.6;
    text-decoration: line-through;
}

.pill-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pill-time {
    font-size: 9.5px;
    font-weight: 700;
    color: #4f46e5;
    flex-shrink: 0;
}

.pill-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
}

.month-more-link {
    font-size: 10.5px;
    font-weight: 600;
    color: #4f46e5;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    text-align: center;
}

.month-more-link:hover {
    text-decoration: underline;
    background: #e0e7ff;
}

/* ==================== DOCUMENT TEMPLATES & A4 CONTRACT STYLES ==================== */
.template-package-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
}

.template-package-card:hover {
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

.template-package-card.active {
    border-color: #4f46e5;
    background: #f8faff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.12);
}

.btn-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 11.5px;
    color: #334155;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-file-chip:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
}

.cccd-upload-box {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cccd-upload-box:hover {
    border-color: #6366f1;
    background: #f5f7ff;
}

.table-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 12.5px;
    background: transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
    box-sizing: border-box;
}

.table-input:hover {
    border-color: #cbd5e1;
    background: #fff;
}

.table-input:focus {
    outline: none;
    border-color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.btn-icon-danger {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.btn-icon-danger:hover {
    background: #fee2e2;
}

.doc-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.doc-tab-btn:hover {
    color: #1e293b;
    background: #e2e8f0;
}

.doc-tab-btn.active {
    color: #ffffff;
    background: #4f46e5;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.a4-preview-card {
    background: #cbd5e1;
    border-radius: 12px;
    padding: 30px 20px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Simulated A4 Paper in Browser (Khổ chuẩn Word HĐ-KHOAN.docx) */
.a4-document {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
    padding: 20mm 20mm 20mm 30mm; /* Lề chuẩn Word HĐ-KHOAN.docx: Trên 20, Phải 20, Dưới 20, Trái 30mm */
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 1.2;
    color: #000000;
    box-sizing: border-box;
    position: relative;
}

.a4-document p {
    text-align: justify;
    text-justify: inter-word;
    font-size: 12pt;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 2px;
}

.a4-document .national-title,
.a4-document .national-title p,
.a4-document .title-bold,
.a4-document .title-italic,
.a4-document .doc-title-box,
.a4-document .doc-title-box p,
.a4-document .doc-title-box h1,
.a4-document .doc-title-box h2 {
    text-align: center !important;
}

.a4-document .national-title {
    margin-bottom: 8px;
}

.a4-document .title-bold {
    font-weight: bold !important;
    font-size: 12pt;
    letter-spacing: 0.2px;
    margin: 0;
    line-height: 1.2;
}

.a4-document .title-italic {
    font-style: italic !important;
    font-size: 12pt;
    margin: 2px 0 0 0;
    line-height: 1.2;
}

.a4-document .divider-line {
    width: 140px;
    height: 1px;
    background: #000;
    margin: 3px auto 0 auto;
}

.a4-document .doc-title-box {
    text-align: center;
    margin: 10px 0 8px 0;
}

.a4-document .main-title,
.a4-document .doc-main-title {
    font-size: 16pt;
    font-weight: bold;
    text-transform: uppercase;
    margin: 0;
    text-align: center;
    line-height: 1.25;
}

.a4-document .sub-title,
.a4-document .doc-sub-title {
    font-style: italic;
    font-size: 12pt;
    margin-top: 2px;
    margin-bottom: 2px;
    text-align: center;
    line-height: 1.2;
}

.a4-document .doc-number,
.a4-document .location-date {
    font-size: 12pt;
    margin-top: 2px;
    margin-bottom: 4px;
    text-align: center;
    line-height: 1.2;
}

.a4-document .intro-line,
.a4-document .legal-basis {
    font-size: 12pt;
    line-height: 1.2;
    margin-bottom: 2px;
}

.a4-document .party-block {
    margin-bottom: 3px;
}

.a4-document .party-header {
    font-weight: bold;
    font-size: 12pt;
    margin-top: 3px;
    margin-bottom: 1px;
}

.a4-document .party-details {
    padding-left: 28px; /* Đúng chuẩn indent 1cm như mẫu Word HĐ-KHOAN */
}

.a4-document .party-details p {
    font-size: 12pt;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 2px;
}

.a4-document .id-row {
    display: flex;
    align-items: baseline;
    font-size: 12pt;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 2px;
}

.a4-document .id-col-1 {
    width: 50%;
    flex: 1;
}

.a4-document .id-col-2 {
    width: 50%;
    flex: 1;
}

.cccd-preview-container {
    position: relative;
    cursor: zoom-in;
    display: inline-block;
    max-width: 100%;
}

.cccd-preview-container:hover .cccd-zoom-overlay {
    opacity: 1;
}

.cccd-zoom-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.a4-document .rep-row {
    display: flex;
    align-items: baseline;
    font-size: 12pt;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 2px;
}

.a4-document .rep-col-1 {
    width: 55%;
    flex-shrink: 0;
}

.a4-document .rep-col-2 {
    width: 45%;
    flex-shrink: 0;
}

.a4-document .contract-clause {
    margin-top: 7px;
    margin-bottom: 7px;
    line-height: 1.35;
}

.a4-document .contract-clause p {
    line-height: 1.35;
    margin-bottom: 3px;
}

.a4-document .clause-title {
    font-weight: bold;
    font-size: 12pt;
    margin-top: 6px;
    margin-bottom: 3px;
}

.page-break-before {
    page-break-before: always !important;
    break-before: page !important;
    padding-top: 20mm !important;
    margin-top: 0 !important;
}

.a4-document .same-line-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1px;
}

.a4-document .same-line-row span {
    font-size: 12pt;
    line-height: 1.2;
}

.a4-document .legal-basis-list {
    list-style: none;
    padding: 0;
    margin: 6px 0;
}

.a4-document .legal-basis-list li {
    font-style: italic;
    font-size: 12pt;
    line-height: 1.2;
    margin-bottom: 2px;
    text-align: justify;
}

.a4-document .party-info-table {
    width: 100%;
    margin-bottom: 6px;
    border-collapse: collapse;
}

.a4-document .party-info-table td {
    padding: 2px 0;
    vertical-align: top;
    font-size: 12pt;
    line-height: 1.2;
    text-align: left;
}

.a4-document .doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
}

.a4-document .doc-table th, 
.a4-document .doc-table td {
    border: 1px solid #000;
    padding: 3px 5px;
    font-size: 11pt;
    line-height: 1.2;
}

.a4-document .doc-table th {
    text-align: center;
    font-weight: bold;
    background: #f2f2f2;
}

.a4-document .text-right,
.a4-document .doc-table td.text-right,
.a4-document .doc-table th.text-right {
    text-align: right !important;
}

.a4-document .text-center,
.a4-document .doc-table td.text-center,
.a4-document .doc-table th.text-center {
    text-align: center !important;
}

/* Bảng Chữ Ký Chân Trang 100% Chiều Rộng - Chia Đều Tuyệt Đối 50% - 50% */
.a4-document .doc-signature-table {
    width: 100% !important;
    border: none !important;
    border-collapse: collapse !important;
    margin-top: 14px !important;
    page-break-inside: avoid !important;
}

.a4-document .doc-signature-table td {
    width: 50% !important;
    text-align: center !important;
    vertical-align: top !important;
    border: none !important;
    padding: 0 !important;
}

.a4-document .doc-signature-table p {
    text-align: center !important;
    line-height: 1.2 !important;
    margin-bottom: 2px !important;
}

.a4-document .sig-role {
    font-weight: bold !important;
    font-size: 12pt !important;
}

.a4-document .sig-note {
    font-weight: bold !important;
    font-size: 12pt !important;
    font-style: normal !important;
    margin-bottom: 40px !important;
}

.a4-document .sig-name {
    font-weight: bold !important;
    font-size: 12pt !important;
}



















/* ============================================================================
   MOBILE & TABLET RESPONSIVE SYSTEM (<= 1024px, <= 768px, <= 640px)
   Desktop (> 1024px) remains 100% untouched.
   ============================================================================ */

/* Desktop default: hide mobile-only controls */
.mobile-topbar,
.sidebar-backdrop,
.sidebar-mobile-close,
.drp-mobile-nav-btn {
    display: none;
}

/* Anti-Squish SVG Icons & Buttons (Mục 8.5 css-standards-skill) */
.btn svg,
.inv-subnav-btn svg,
.nav-item svg,
.nav-group-title svg,
.daterange-trigger-btn svg,
.mobile-topbar svg {
    flex-shrink: 0;
}

.data-table th.sticky-col-check,
.data-table td.sticky-col-check,
.data-table th.sticky-col-stt,
.data-table td.sticky-col-stt,
.data-table th.sticky-col-switch,
.data-table td.sticky-col-switch {
    padding-left: 6px;
    padding-right: 6px;
}

/* 1. TABLET & PHONE LANDSCAPE (<= 1024px) */
@media (max-width: 1024px) {
    html, body {
        overflow-x: hidden;
        height: auto !important;
        min-height: 100dvh;
    }

    body.mobile-drawer-open {
        overflow: hidden !important;
    }

    /* Release outer scroll lock so touch scrolling works naturally */
    .app-container {
        display: flex;
        flex-direction: column;
        height: auto !important;
        min-height: 100dvh;
        overflow: visible !important;
    }

    .main-content {
        width: 100%;
        min-width: 0;
        height: auto !important;
        overflow: visible !important;
    }

    .tab-content {
        padding: 14px 16px 28px !important;
        height: auto !important;
        overflow-y: visible !important;
        overflow-x: hidden;
    }

    /* Sticky Mobile Top Bar (52px) */
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        height: 52px;
        padding: 0 12px;
        background: #0f172a;
        color: #ffffff;
        position: sticky;
        top: 0;
        z-index: 950;
        box-shadow: 0 2px 10px rgba(15, 23, 42, 0.22);
    }

    .mobile-menu-btn,
    .mobile-quick-sync-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        background: rgba(255, 255, 255, 0.08);
        color: #f8fafc;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.18s ease, transform 0.12s ease;
    }

    .mobile-menu-btn:active,
    .mobile-quick-sync-btn:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.16);
    }

    .mobile-topbar-brand {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        flex: 1;
        font-size: 14.5px;
        font-weight: 700;
        color: #f8fafc;
    }

    .mobile-topbar-brand img {
        width: 22px;
        height: 22px;
        object-fit: contain;
        flex-shrink: 0;
    }

    .mobile-topbar-brand span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Off-Canvas Drawer Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 84vw);
        height: 100dvh;
        z-index: 1200;
        transform: translateX(-105%);
        transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 12px 0 32px rgba(0, 0, 0, 0.4);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar .logo {
        padding: 14px 16px;
        justify-content: space-between;
        font-size: 17px;
    }

    .sidebar-mobile-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        background: rgba(255, 255, 255, 0.08);
        color: #cbd5e1;
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        flex-shrink: 0;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(2px);
        z-index: 1150;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Compact Page Header */
    .header {
        padding: 14px 16px 12px !important;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .page-title {
        font-size: 18px !important;
        line-height: 1.3;
        margin-bottom: 2px;
    }

    .page-desc {
        font-size: 12.5px !important;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
    }

    /* KPI Grid: 3 columns on Tablet & Phone Landscape */
    .stats-grid,
    #tab-drafts .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .stat-card,
    #tab-drafts .stat-card {
        padding: 12px 14px !important;
        min-width: 0;
    }

    .stat-value,
    #tab-drafts .stat-value {
        font-size: 22px !important;
    }

    /* Horizontal Touch Scroll for Sub-Tab Navigation Bars */
    .inv-subnav,
    .recon-subnav,
    .company-modal-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px !important;
        padding-bottom: 2px;
    }

    .inv-subnav::-webkit-scrollbar,
    .recon-subnav::-webkit-scrollbar,
    .company-modal-tabs::-webkit-scrollbar {
        display: none;
    }

    .inv-subnav-btn,
    .marketplace-subtab-btn,
    .carrier-subtab-btn,
    .doc-tab-btn,
    .btn-subtab {
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        padding: 9px 12px !important;
        font-size: 13px !important;
    }

    /* Release fixed calc(100vh - 320px) squeeze so tables show full rows in landscape & portrait */
    .tab-content .card[style*="max-height"],
    .tab-content div[style*="max-height: calc(100vh"],
    #inv-table-wrapper,
    #disputes-table-container,
    #reverse-table-container,
    #direct-table-container {
        max-height: none !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure any card directly wrapping a wide table can scroll horizontally */
    .tab-content .card:has(> table),
    #inv-table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* 2. MOBILE PHONES & NARROW VIEWPORTS (<= 768px) */
@media (max-width: 768px) {
    /* Free up 150px+ of horizontal table space by unpinning auxiliary left columns */
    .data-table th.sticky-col-check,
    .data-table td.sticky-col-check,
    .data-table th.sticky-col-stt,
    .data-table td.sticky-col-stt,
    .data-table th.sticky-col-switch,
    .data-table td.sticky-col-switch {
        position: static !important;
        left: auto !important;
    }

    .data-table th.sticky-col-sku,
    .data-table td.sticky-col-sku {
        position: sticky !important;
        left: 0 !important;
        width: 165px !important;
        max-width: 165px;
        overflow: hidden;
        text-overflow: ellipsis;
        box-shadow: 2px 0 6px -1px rgba(0, 0, 0, 0.08);
    }

    .data-table th.sticky-col-switch,
    .data-table td.sticky-col-switch,
    .data-table th.sticky-col-stt,
    .data-table td.sticky-col-stt,
    .data-table th.sticky-col-check,
    .data-table td.sticky-col-check {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    .data-table th {
        padding: 9px 10px !important;
        font-size: 11px !important;
    }

    .data-table td {
        padding: 9px 10px !important;
        font-size: 12.5px !important;
    }

    /* Prevent hardcoded min-widths & input widths from causing horizontal page overflow */
    .tab-content div[style*="min-width: 260px"],
    .tab-content div[style*="min-width: 280px"],
    .tab-content div[style*="min-width: 300px"],
    .tab-content div[style*="min-width: 320px"],
    .tab-content div[style*="min-width: 340px"] {
        min-width: 0 !important;
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    #filter-inventory-search,
    #filter-audit-sessions-search,
    #filter-input-search,
    .tab-content input.input-field,
    .tab-content select.input-field {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Filter Pill Strips scroll smoothly in 1 row */
    div:has(> .inv-filter-btn),
    div:has(> .session-filter-btn) {
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    div:has(> .inv-filter-btn)::-webkit-scrollbar,
    div:has(> .session-filter-btn)::-webkit-scrollbar {
        display: none;
    }

    .inv-filter-btn,
    .session-filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Pagination Bar clean 2-row stack on Mobile */
    #pagination-inventory-orders,
    .pagination-top-bar {
        padding: 8px 12px !important;
    }

    .ace-pagination-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .ace-pagination-info {
        font-size: 12px;
        line-height: 1.45;
    }

    .ace-pagination-controls {
        justify-content: flex-start;
        width: 100%;
        gap: 5px !important;
    }

    .page-nav-btn,
    .page-num-btn {
        min-width: 32px;
        min-height: 32px;
        padding: 4px 8px !important;
        font-size: 12.5px !important;
    }

    .ace-pagination-size {
        margin-left: auto !important;
        padding: 5px 8px !important;
        font-size: 12px !important;
    }

    /* Modals & Dialogs fit mobile viewport */
    .modal {
        padding: 8px;
    }

    .modal-content,
    .sync-modal-content,
    .company-modal-dialog,
    .modal > div[style*="width"] {
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        max-height: 90dvh !important;
        margin: 0 auto !important;
    }

    .modal-header {
        padding: 12px 16px !important;
    }

    .modal div[style*="grid-template-columns: repeat(4"],
    .modal div[style*="grid-template-columns: repeat(3"],
    .modal div[style*="grid-template-columns: repeat(2"],
    .modal div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Floating Batch Action Bar */
    .floating-batch-bar {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        bottom: 12px;
        padding: 8px 12px;
        gap: 8px;
        border-radius: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }

    .floating-batch-bar .btn-batch-action,
    .floating-batch-bar .batch-count-badge {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* PremiumDatePicker Centered Single-Calendar Mobile Sheet */
    .daterange-popover {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -46%) !important;
        width: calc(100vw - 20px) !important;
        max-width: 370px !important;
        max-height: 88dvh !important;
        flex-direction: column !important;
        z-index: 2000 !important;
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55), 0 0 0 100vmax rgba(15, 23, 42, 0.45) !important;
    }

    .daterange-popover.visible {
        transform: translate(-50%, -50%) !important;
    }

    .drp-presets {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #2e3446;
        padding: 8px 10px !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 0;
    }

    .drp-presets::-webkit-scrollbar {
        display: none;
    }

    .drp-preset-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 6px 11px !important;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.06);
        font-size: 12px !important;
    }

    .drp-calendars-wrapper {
        padding: 12px !important;
        gap: 10px !important;
        overflow-y: auto;
    }

    .drp-inputs-header {
        justify-content: space-between;
        gap: 8px;
        padding-bottom: 8px;
    }

    .drp-date-input {
        flex: 1;
        width: auto !important;
        min-width: 0;
        font-size: 12.5px;
        padding: 6px 8px;
    }

    .drp-calendars {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .drp-calendar {
        width: 100% !important;
        max-width: 320px;
    }

    .drp-calendar:nth-child(2),
    .drp-desktop-spacer {
        display: none !important;
    }

    .drp-mobile-nav-btn {
        display: inline-flex !important;
    }
}

/* 3. PORTRAIT PHONES (<= 640px) */
@media (max-width: 640px) {
    .tab-content {
        padding: 10px 12px 24px !important;
    }

    .header {
        padding: 12px !important;
    }

    .page-title {
        font-size: 16.5px !important;
    }

    .stats-grid,
    #tab-drafts .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .stat-card,
    #tab-drafts .stat-card {
        padding: 10px 12px !important;
        border-radius: 10px !important;
    }

    .stat-card h3,
    #tab-drafts .stat-card h3 {
        font-size: 10.5px !important;
        margin-bottom: 4px !important;
        letter-spacing: 0.2px !important;
    }

    .stat-value,
    #tab-drafts .stat-value {
        font-size: 18px !important;
    }

    #tab-drafts .stat-card-active::after {
        content: "✓" !important;
        padding: 1px 6px !important;
        top: 6px !important;
        right: 6px !important;
        font-size: 10px !important;
    }
}


/* ==================== VCB <-> EASYBOOKS (TK 11211) 2-WAY RECONCILIATION ==================== */
:root {
    --eb-rec-ok-bg: #ecfdf5;
    --eb-rec-ok-border: #a7f3d0;
    --eb-rec-ok-text: #047857;
    --eb-rec-warn-bg: #fffbeb;
    --eb-rec-warn-border: #fde68a;
    --eb-rec-warn-text: #b45309;
    --eb-rec-err-bg: #fef2f2;
    --eb-rec-err-border: #fecaca;
    --eb-rec-err-text: #b91c1c;
    --eb-rec-info-bg: #eef2ff;
    --eb-rec-info-border: #c7d2fe;
}

.eb-rec-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 19px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: var(--bg-card);
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

.eb-rec-kpi-grid {
    display: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 4px;
}

.eb-rec-kpi-card {
    padding: 14px 16px;
    border-left: 4px solid var(--primary);
    background: var(--bg-card);
}

.eb-rec-kpi-card.kpi-ok {
    border-left-color: var(--success);
    background: var(--eb-rec-ok-bg);
}

.eb-rec-kpi-card.kpi-warn {
    border-left-color: var(--warning);
    background: var(--eb-rec-warn-bg);
}

.eb-rec-kpi-card.kpi-danger {
    border-left-color: var(--danger);
    background: var(--eb-rec-err-bg);
}

.eb-rec-toolbar {
    padding: 10px 14px;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
}

.eb-rec-toolbar-left,
.eb-rec-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.eb-rec-toolbar-left {
    flex: 1;
    min-width: 0;
}

.eb-rec-search {
    min-width: 240px;
    max-width: 320px;
    flex: 1;
    height: 34px;
    padding: 6px 10px;
    font-size: 12.5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
}

.eb-rec-select,
.eb-rec-date {
    height: 34px;
    padding: 4px 8px;
    font-size: 12.5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
}

.eb-rec-btn-sm {
    height: 34px;
    padding: 0 11px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.eb-rec-banner {
    margin-top: 10px;
    padding: 9px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.eb-rec-banner-ok {
    background: var(--eb-rec-ok-bg);
    border: 1px solid var(--eb-rec-ok-border);
    color: var(--eb-rec-ok-text);
}

.eb-rec-banner-warn {
    background: var(--eb-rec-warn-bg);
    border: 1px solid var(--eb-rec-warn-border);
    color: var(--eb-rec-warn-text);
}

.eb-rec-muted {
    color: var(--text-muted);
}

.eb-rec-wrap {
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.45;
}

.eb-rec-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.eb-rec-badge-ok {
    background: var(--eb-rec-ok-bg);
    color: var(--eb-rec-ok-text);
    border: 1px solid var(--eb-rec-ok-border);
}

.eb-rec-badge-warn {
    background: var(--eb-rec-warn-bg);
    color: var(--eb-rec-warn-text);
    border: 1px solid var(--eb-rec-warn-border);
}

.eb-rec-badge-danger {
    background: var(--eb-rec-err-bg);
    color: var(--eb-rec-err-text);
    border: 1px solid var(--eb-rec-err-border);
}

.eb-rec-badge-muted {
    background: var(--bg-main);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.eb-rec-dir {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.eb-rec-dir-in {
    background: var(--eb-rec-ok-bg);
    color: var(--eb-rec-ok-text);
}

.eb-rec-dir-out {
    background: var(--eb-rec-err-bg);
    color: var(--eb-rec-err-text);
}

.eb-rec-num-in,
.eb-rec-num-ok {
    color: var(--eb-rec-ok-text);
}

.eb-rec-num-out,
.eb-rec-num-err {
    color: var(--eb-rec-err-text);
}

.eb-rec-voucher-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--eb-rec-info-bg);
    border: 1px solid var(--eb-rec-info-border);
    color: var(--primary);
    font-weight: 700;
    font-size: 12px;
}

.eb-rec-pdf-link {
    display: inline-block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.eb-rec-pdf-link:hover {
    text-decoration: underline;
}

.eb-rec-row-issue {
    background: var(--eb-rec-err-bg) !important;
}

.eb-rec-month-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.eb-rec-month-row:hover {
    background: var(--bg-main);
}

#table-eb-reconcile th[data-sort] {
    cursor: pointer;
    user-select: none;
}

.eb-rec-sort-icon {
    font-size: 11px;
    margin-left: 3px;
    color: var(--text-muted);
}

.eb-rec-th-sorted .eb-rec-sort-icon {
    color: var(--primary);
    font-weight: 800;
}

.fee-matrix-row {
    cursor: pointer;
    transition: background-color 0.18s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.18s ease;
}

.fee-matrix-row:hover {
    background: var(--primary-light) !important;
}

.fee-matrix-row.fee-matrix-row-active {
    background: var(--primary-light) !important;
    box-shadow: inset 4px 0 0 var(--primary);
}

.fee-matrix-row-total {
    cursor: pointer;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.fee-matrix-row-total:hover {
    background: #e2e8f0 !important;
}

.fee-matrix-row-total.fee-matrix-row-active {
    box-shadow: inset 4px 0 0 var(--primary);
}

/* Fee Invoices & Monthly FCT Matrix Responsive Layout */
.fee-summary-toolbar {
    background: var(--bg-tertiary, #f8fafc);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px 20px;
}

.fee-summary-metrics {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

.fee-summary-metric-val {
    font-size: 17px;
    font-weight: 800;
    margin-top: 2px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.fee-summary-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.fee-table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.fee-recon-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.fee-recon-table-monthly {
    min-width: 1640px;
}

.fee-recon-table-invoices {
    min-width: 1580px;
}

.fee-recon-table thead th {
    padding: 11px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.fee-recon-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-variant-numeric: tabular-nums;
    vertical-align: middle;
}

.fee-recon-table tbody tr:last-child td {
    border-bottom: none;
}

.fee-num-cell {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.fee-num-cell > div {
    white-space: nowrap;
}

.fee-period-cell {
    white-space: nowrap;
    min-width: 142px;
}

.fee-status-cell {
    text-align: center;
    min-width: 245px;
    white-space: nowrap;
}

.fee-dossier-cell {
    text-align: center;
    min-width: 235px;
    white-space: nowrap;
}

/* Sticky Left & Right Columns for Horizontal Scroll */
.fee-recon-table thead th.fee-sticky-left,
.fee-recon-table thead th.fee-sticky-left-2 {
    position: sticky;
    z-index: 6;
    background: #f8fafc;
}

.fee-recon-table thead th.fee-sticky-right {
    position: sticky;
    right: 0;
    z-index: 6;
    background: #f8fafc;
    box-shadow: -3px 0 6px -2px rgba(15, 23, 42, 0.08);
}

.fee-recon-table tbody td.fee-sticky-left,
.fee-recon-table tbody td.fee-sticky-left-2 {
    position: sticky;
    z-index: 4;
}

.fee-recon-table tbody td.fee-sticky-right {
    position: sticky;
    right: 0;
    z-index: 4;
    box-shadow: -3px 0 6px -2px rgba(15, 23, 42, 0.08);
}

.fee-sticky-l0 {
    left: 0;
}

.fee-sticky-l48 {
    left: 52px;
    box-shadow: 3px 0 6px -2px rgba(15, 23, 42, 0.08);
}

.fee-recon-table-monthly .fee-sticky-left {
    box-shadow: 3px 0 6px -2px rgba(15, 23, 42, 0.08);
}

.fee-row-even td.fee-sticky-left,
.fee-row-even td.fee-sticky-left-2,
.fee-row-even td.fee-sticky-right {
    background-color: #ffffff;
}

.fee-row-odd td.fee-sticky-left,
.fee-row-odd td.fee-sticky-left-2,
.fee-row-odd td.fee-sticky-right {
    background-color: #f8fafc;
}

.fee-matrix-row:hover td,
.fee-matrix-row:hover td.fee-sticky-left,
.fee-matrix-row:hover td.fee-sticky-right,
.fee-matrix-row.fee-matrix-row-active td.fee-sticky-left,
.fee-matrix-row.fee-matrix-row-active td.fee-sticky-right {
    background-color: #eef2ff !important;
}

.fee-matrix-row-total td,
.fee-matrix-row-total td.fee-sticky-left,
.fee-matrix-row-total td.fee-sticky-right {
    background-color: #f1f5f9;
    border-top: 2px solid #cbd5e1;
}

.fee-matrix-row-total:hover td,
.fee-matrix-row-total:hover td.fee-sticky-left,
.fee-matrix-row-total:hover td.fee-sticky-right {
    background-color: #e2e8f0 !important;
}

body.dark-theme .fee-summary-toolbar {
    border-color: var(--border);
}

body.dark-theme .fee-recon-table thead th,
body.dark-theme .fee-recon-table thead th.fee-sticky-left,
body.dark-theme .fee-recon-table thead th.fee-sticky-left-2,
body.dark-theme .fee-recon-table thead th.fee-sticky-right {
    background-color: #1B2234;
    border-color: #2A344D;
    color: #CBD5E1;
}

body.dark-theme .fee-row-even td.fee-sticky-left,
body.dark-theme .fee-row-even td.fee-sticky-left-2,
body.dark-theme .fee-row-even td.fee-sticky-right {
    background-color: #141824;
}

body.dark-theme .fee-row-odd td.fee-sticky-left,
body.dark-theme .fee-row-odd td.fee-sticky-left-2,
body.dark-theme .fee-row-odd td.fee-sticky-right {
    background-color: #1B2234;
}

body.dark-theme .fee-matrix-row:hover td,
body.dark-theme .fee-matrix-row:hover td.fee-sticky-left,
body.dark-theme .fee-matrix-row:hover td.fee-sticky-right,
body.dark-theme .fee-matrix-row.fee-matrix-row-active td.fee-sticky-left,
body.dark-theme .fee-matrix-row.fee-matrix-row-active td.fee-sticky-right {
    background-color: #1E293B !important;
}

@media (max-width: 768px) {
    .fee-recon-table thead th.fee-sticky-right,
    .fee-recon-table tbody td.fee-sticky-right,
    .fee-recon-table thead th.fee-sticky-left-2,
    .fee-recon-table tbody td.fee-sticky-left-2 {
        position: static;
        box-shadow: none;
    }
}

/* ==================== TAB: NGUYÊN PHỤ LIỆU ĐẦU VÀO & TỒN KHO ==================== */
#tab-input-materials .im-subtab-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

#tab-input-materials .im-money-summary {
    font-size: 12.5px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: 8px;
}

#tab-input-materials .im-text-success {
    color: #059669;
}

#tab-input-materials .im-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
}

#tab-input-materials .im-toolbar-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 280px;
    flex-wrap: wrap;
}

#tab-input-materials .im-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#tab-input-materials .im-meta-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

#tab-input-materials .im-fallback-warn {
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 500;
}

#tab-input-materials .im-table-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 335px);
}

#tab-input-materials .im-table-scroll {
    overflow: auto;
    flex: 1;
    min-height: 260px;
}

#table-input-materials {
    width: 100%;
    min-width: 1380px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

#table-input-materials thead th {
    position: sticky;
    top: 0;
    z-index: 12;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

#table-input-materials thead th[data-sort] {
    cursor: pointer;
    user-select: none;
}

#table-input-materials thead th[data-sort]:hover {
    background: #eff6ff;
}

#table-input-materials thead th.im-sorted {
    color: #2563eb;
}

#table-input-materials .im-sort-arrow {
    font-size: 10px;
    opacity: 0.65;
    margin-left: 3px;
}

#table-input-materials tbody tr.im-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#table-input-materials tbody tr.im-row:hover td {
    background-color: #f8fafc;
}

#table-input-materials .im-sticky-stt {
    position: sticky;
    left: 0;
    z-index: 6;
    background: var(--bg-card);
}

#table-input-materials thead th.im-sticky-stt {
    z-index: 15;
    background: #f8fafc;
}

#table-input-materials .im-sticky-code {
    position: sticky;
    left: 46px;
    z-index: 6;
    background: var(--bg-card);
    box-shadow: 2px 0 6px -2px rgba(15, 23, 42, 0.08);
}

#table-input-materials thead th.im-sticky-code {
    z-index: 15;
    background: #f8fafc;
}

#table-input-materials .im-code-main {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--primary);
}

#table-input-materials .im-tag-row {
    display: flex;
    gap: 4px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.im-src-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.im-src-eb { background: #dbeafe; color: #1e40af; }
.im-src-inv { background: #fef3c7; color: #92400e; }
.im-src-adj { background: #fce7f3; color: #9d174d; }

.im-name-main {
    font-weight: 600;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.im-name-sub {
    font-size: 11.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
    margin-top: 2px;
}

.im-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 9999px;
    white-space: nowrap;
}

.im-badge-raw { background: #ede9fe; color: #5b21b6; }
.im-badge-aux { background: #e0f2fe; color: #0369a1; }
.im-badge-warn { background: #fef3c7; color: #b45309; }
.im-badge-pend { background: #ffedd5; color: #c2410c; }
.im-badge-eb { background: #dcfce7; color: #166534; }
.im-badge-out { background: #e0e7ff; color: #3730a3; }
.im-badge-excl { background: #f1f5f9; color: #475569; }

.im-stock-pill {
    display: inline-block;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 6px;
}

.im-stock-pos { background: #ecfdf5; color: #047857; }
.im-stock-zero { background: #f1f5f9; color: #475569; }
.im-stock-neg { background: #fef2f2; color: #b91c1c; }

.im-pending-qty {
    color: #d97706;
    font-weight: 700;
}

.im-unconverted-chip {
    display: inline-block;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fef3c7;
    color: #92400e;
    border: 1px dashed #f59e0b;
}

.im-pend-dot {
    color: #d97706;
    font-weight: 600;
}

.im-modal-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.im-modal-kpi {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
}

.im-override-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.im-inline-select {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
}

body.dark-theme #tab-input-materials .im-money-summary,
body.dark-theme #tab-input-materials .im-table-card,
body.dark-theme #table-input-materials .im-sticky-stt,
body.dark-theme #table-input-materials .im-sticky-code {
    background: #141824;
    border-color: #2A344D;
    color: #E2E8F0;
}

body.dark-theme #table-input-materials thead th,
body.dark-theme #table-input-materials thead th.im-sticky-stt,
body.dark-theme #table-input-materials thead th.im-sticky-code {
    background: #1B2234;
    border-color: #2A344D;
    color: #CBD5E1;
}

body.dark-theme #table-input-materials thead th[data-sort]:hover {
    background: #232D45;
}

body.dark-theme #table-input-materials tbody tr.im-row:hover td {
    background-color: #1E293B;
}

body.dark-theme .im-name-main,
body.dark-theme #table-input-materials .im-code-main {
    color: #F1F5F9;
}

body.dark-theme .im-modal-kpi,
body.dark-theme .im-override-form {
    background: #1B2234;
    border-color: #2A344D;
}

body.dark-theme .im-stock-pos { background: rgba(16, 185, 129, 0.16); color: #34d399; }
body.dark-theme .im-stock-zero { background: #1e293b; color: #94a3b8; }
body.dark-theme .im-stock-neg { background: rgba(239, 68, 68, 0.18); color: #f87171; }
body.dark-theme .im-badge-raw { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
body.dark-theme .im-badge-aux { background: rgba(14, 165, 233, 0.2); color: #7dd3fc; }
body.dark-theme .im-badge-eb { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
body.dark-theme .im-badge-pend { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
body.dark-theme .im-badge-warn { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
body.dark-theme .im-fallback-warn { background: rgba(245, 158, 11, 0.15); color: #fcd34d; border-color: #b45309; }

@media (max-width: 1024px) {
    #tab-input-materials .im-table-card {
        max-height: none;
    }
    #table-input-materials .im-sticky-stt,
    #table-input-materials .im-sticky-code,
    #table-input-materials thead th.im-sticky-stt,
    #table-input-materials thead th.im-sticky-code {
        position: static;
        box-shadow: none;
    }
    .im-modal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .im-override-form {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}



